Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
446c8c13
Commit
446c8c13
authored
Sep 12, 2019
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add credentials to TOSCA
parent
03b20b8c
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
252 additions
and
354 deletions
+252
-354
ProvisionService.java
...in/java/nl/uva/sne/drip/api/service/ProvisionService.java
+110
-243
ProvisionController.java
...java/nl/uva/sne/drip/api/v1/rest/ProvisionController.java
+13
-13
ProvisionResponse.java
...drip/drip/commons/data/v1/external/ProvisionResponse.java
+43
-23
P2PConverter.java
...ain/java/nl/uva/sne/drip/drip/converter/P2PConverter.java
+17
-10
MessageParsing.java
...l/uva/sne/drip/drip/provisioner/utils/MessageParsing.java
+69
-65
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/service/ProvisionService.java
View file @
446c8c13
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/v1/rest/ProvisionController.java
View file @
446c8c13
...
@@ -153,7 +153,7 @@ public class ProvisionController {
...
@@ -153,7 +153,7 @@ public class ProvisionController {
List
<
String
>
getIds
()
{
List
<
String
>
getIds
()
{
List
<
ProvisionResponse
>
all
=
provisionService
.
findAll
();
List
<
ProvisionResponse
>
all
=
provisionService
.
findAll
();
List
<
String
>
ids
=
new
ArrayList
<>(
all
.
size
());
List
<
String
>
ids
=
new
ArrayList
<>(
all
.
size
());
for
(
ProvisionRe
quest
pi
:
all
)
{
for
(
ProvisionRe
sponse
pi
:
all
)
{
ids
.
add
(
pi
.
getId
());
ids
.
add
(
pi
.
getId
());
}
}
return
ids
;
return
ids
;
...
@@ -181,9 +181,9 @@ public class ProvisionController {
...
@@ -181,9 +181,9 @@ public class ProvisionController {
throw
new
BadRequestException
();
throw
new
BadRequestException
();
}
}
try
{
try
{
req
=
provisionService
.
provisionResources
(
req
,
1
);
ProvisionResponse
resp
=
provisionService
.
provisionResources
(
req
,
1
);
return
re
q
.
getId
();
return
re
sp
.
getId
();
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
if
(
ex
instanceof
nl
.
uva
.
sne
.
drip
.
api
.
exception
.
PlanNotFoundException
if
(
ex
instanceof
nl
.
uva
.
sne
.
drip
.
api
.
exception
.
PlanNotFoundException
...
@@ -210,16 +210,16 @@ public class ProvisionController {
...
@@ -210,16 +210,16 @@ public class ProvisionController {
})
})
public
@ResponseBody
public
@ResponseBody
String
postProvisionResponse
(
@RequestBody
ProvisionResponse
resp
)
{
String
postProvisionResponse
(
@RequestBody
ProvisionResponse
resp
)
{
if
(
resp
.
getCloudCredentialsIDs
()
==
null
||
resp
.
getCloudCredentialsIDs
().
get
(
0
)
==
null
//
if (resp.getCloudCredentialsIDs() == null || resp.getCloudCredentialsIDs().get(0) == null
||
resp
.
getCloudCredentialsIDs
().
get
(
0
).
length
()
<
2
)
{
//
|| resp.getCloudCredentialsIDs().get(0).length() < 2) {
throw
new
BadRequestException
();
//
throw new BadRequestException();
}
//
}
if
(
resp
.
getPlanID
()
==
null
||
resp
.
getPlanID
().
length
()
<
2
)
{
//
if (resp.getPlanID() == null || resp.getPlanID().length() < 2) {
throw
new
BadRequestException
();
//
throw new BadRequestException();
}
//
}
if
(
resp
.
getDeployParameters
()
==
null
||
resp
.
getDeployParameters
().
get
(
0
)
==
null
)
{
//
if (resp.getDeployParameters() == null || resp.getDeployParameters().get(0) == null) {
throw
new
BadRequestException
();
//
throw new BadRequestException();
}
//
}
resp
=
provisionService
.
save
(
resp
);
resp
=
provisionService
.
save
(
resp
);
return
resp
.
getId
();
return
resp
.
getId
();
...
...
drip-commons/src/main/java/nl/uva/sne/drip/drip/commons/data/v1/external/ProvisionResponse.java
View file @
446c8c13
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
package
nl
.
uva
.
sne
.
drip
.
drip
.
commons
.
data
.
v1
.
external
;
package
nl
.
uva
.
sne
.
drip
.
drip
.
commons
.
data
.
v1
.
external
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.webcohesion.enunciate.metadata.DocumentationExample
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -25,36 +26,55 @@ import java.util.List;
...
@@ -25,36 +26,55 @@ import java.util.List;
* @author S. Koulouzis
* @author S. Koulouzis
*/
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
ProvisionResponse
extends
ProvisionRequest
{
public
class
ProvisionResponse
extends
KeyValueHolder
{
private
List
<
DeployParameter
>
deployParameters
;
private
String
planID
;
private
ArrayList
<
String
>
cloudKeyPairIDs
;
/**
/**
* The ID of the plan <code>PlanResponse</code> to provision for.
* The deploy parameters.
*
*
* @return the
deployParameters
* @return the
planID
*/
*/
public
List
<
DeployParameter
>
getDeployParameters
()
{
@DocumentationExample
(
"ASedsfd46b4fDFd83ba1q"
)
return
deployParameters
;
public
String
getPlanID
()
{
return
planID
;
}
}
/**
/**
* @param
deployParameters the deployParameters
to set
* @param
planID the planID
to set
*/
*/
public
void
setDeployParameters
(
List
<
DeployParameter
>
deployParameters
)
{
public
void
setPlanID
(
String
planID
)
{
this
.
deployParameters
=
deployParameters
;
this
.
planID
=
planID
;
}
public
void
setCloudKeyPairIDs
(
ArrayList
<
String
>
cloudKeyPairIDs
)
{
this
.
cloudKeyPairIDs
=
cloudKeyPairIDs
;
}
}
/**
// private List<DeployParameter> deployParameters;
* @return the cloudKeyPairIDs
// private ArrayList<String> cloudKeyPairIDs;
*/
//
public
ArrayList
<
String
>
getCloudKeyPairIDs
()
{
// /**
return
cloudKeyPairIDs
;
// * The deploy parameters.
}
// *
// * @return the deployParameters
// */
// public List<DeployParameter> getDeployParameters() {
// return deployParameters;
// }
//
// /**
// * @param deployParameters the deployParameters to set
// */
// public void setDeployParameters(List<DeployParameter> deployParameters) {
// this.deployParameters = deployParameters;
// }
//
// public void setCloudKeyPairIDs(ArrayList<String> cloudKeyPairIDs) {
// this.cloudKeyPairIDs = cloudKeyPairIDs;
// }
//
// /**
// * @return the cloudKeyPairIDs
// */
// public ArrayList<String> getCloudKeyPairIDs() {
// return cloudKeyPairIDs;
// }
}
}
drip-planner2provisioner/src/main/java/nl/uva/sne/drip/drip/converter/P2PConverter.java
View file @
446c8c13
...
@@ -4,7 +4,6 @@ import java.io.IOException;
...
@@ -4,7 +4,6 @@ import java.io.IOException;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.UUID
;
import
com.fasterxml.jackson.core.JsonParseException
;
import
com.fasterxml.jackson.core.JsonParseException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
...
@@ -25,24 +24,28 @@ import org.json.JSONException;
...
@@ -25,24 +24,28 @@ import org.json.JSONException;
public
class
P2PConverter
{
public
class
P2PConverter
{
public
static
SimplePlanContainer
transfer
(
Map
<
String
,
Object
>
toscaPlanMap
,
public
static
SimplePlanContainer
transfer
(
Map
<
String
,
Object
>
toscaPlanMap
,
String
userName
,
String
domainName
,
String
cloudProvider
)
throws
JsonParseException
,
JsonMappingException
,
IOException
,
JSONException
{
String
userName
,
String
domainName
,
String
cloudProvider
)
throws
JsonParseException
,
JsonMappingException
,
IOException
,
JSONException
{
if
(
cloudProvider
!=
null
)
{
if
(
cloudProvider
!=
null
)
{
cloudProvider
=
cloudProvider
.
toUpperCase
();
cloudProvider
=
cloudProvider
.
toUpperCase
();
}
}
Map
<
String
,
Object
>
topologyTemplate
=
(
Map
<
String
,
Object
>)
((
Map
<
String
,
Object
>)
toscaPlanMap
.
get
(
"topology_template"
)).
get
(
"node_templates"
);
Map
<
String
,
Object
>
topologyTemplate
=
(
Map
<
String
,
Object
>)
((
Map
<
String
,
Object
>)
toscaPlanMap
.
get
(
"topology_template"
)).
get
(
"node_templates"
);
//Get the domain provider and vm list
//Get the domain provider and vm list
Map
<
String
,
Object
>
topologyNode
=
null
;
String
topologyNodeName
=
null
;
List
<
String
>
vmNames
=
new
ArrayList
<>();
List
<
String
>
vmNames
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
topologyTemplate
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
topologyTemplate
.
entrySet
())
{
Map
<
String
,
Object
>
node
=
(
Map
<
String
,
Object
>)
entry
.
getValue
();
Map
<
String
,
Object
>
node
=
(
Map
<
String
,
Object
>)
entry
.
getValue
();
String
type
=
(
String
)
node
.
get
(
"type"
);
String
type
=
(
String
)
node
.
get
(
"type"
);
if
(
type
.
equals
(
"tosca.nodes.ARTICONF.VM.topology"
))
{
if
(
type
.
equals
(
"tosca.nodes.ARTICONF.VM.topology"
))
{
Map
<
String
,
Object
>
properties
=
(
Map
<
String
,
Object
>)
node
.
get
(
"properties"
);
topologyNode
=
node
;
topologyNodeName
=
entry
.
getKey
();
Map
<
String
,
Object
>
properties
=
(
Map
<
String
,
Object
>)
topologyNode
.
get
(
"properties"
);
domainName
=
(
String
)
properties
.
get
(
"domain"
);
domainName
=
(
String
)
properties
.
get
(
"domain"
);
cloudProvider
=
(
String
)
properties
.
get
(
"provider"
);
cloudProvider
=
(
String
)
properties
.
get
(
"provider"
);
List
<
Object
>
requirements
=
(
List
<
Object
>)
n
ode
.
get
(
"requirements"
);
List
<
Object
>
requirements
=
(
List
<
Object
>)
topologyN
ode
.
get
(
"requirements"
);
for
(
Object
requirement
:
requirements
)
{
for
(
Object
requirement
:
requirements
)
{
Map
<
String
,
Object
>
requirementMap
=
(
Map
<
String
,
Object
>)
requirement
;
Map
<
String
,
Object
>
requirementMap
=
(
Map
<
String
,
Object
>)
requirement
;
...
@@ -51,13 +54,16 @@ public class P2PConverter {
...
@@ -51,13 +54,16 @@ public class P2PConverter {
String
nodeName
=
(
String
)
((
Map
<
String
,
Object
>)
requirementMap
.
get
(
requirementEntry
.
getKey
())).
get
(
"node"
);
String
nodeName
=
(
String
)
((
Map
<
String
,
Object
>)
requirementMap
.
get
(
requirementEntry
.
getKey
())).
get
(
"node"
);
vmNames
.
add
(
nodeName
);
vmNames
.
add
(
nodeName
);
}
}
break
;
}
}
}
}
List
<
Object
>
vmList
=
new
ArrayList
<>();
List
<
Object
>
vmList
=
new
ArrayList
<>();
for
(
String
vmName
:
vmNames
)
{
for
(
String
vmName
:
vmNames
)
{
Map
<
String
,
Object
>
vm
=
(
Map
<
String
,
Object
>)
topologyTemplate
.
get
(
vmName
);
Map
<
String
,
Object
>
vm
=
(
Map
<
String
,
Object
>)
topologyTemplate
.
get
(
vmName
);
userName
=
(
String
)
((
Map
<
String
,
Object
>)
vm
.
get
(
"properties"
)).
get
(
"user_name"
);
Map
<
String
,
Object
>
properties
=
(
Map
<
String
,
Object
>)
vm
.
get
(
"properties"
);
vm
.
put
(
"name"
,
vmName
);
userName
=
(
String
)
properties
.
get
(
"user_name"
);
String
hostName
=
(
String
)
properties
.
get
(
"host_name"
);
vm
.
put
(
"name"
,
hostName
);
vmList
.
add
(
vm
);
vmList
.
add
(
vm
);
}
}
...
@@ -71,23 +77,24 @@ public class P2PConverter {
...
@@ -71,23 +77,24 @@ public class P2PConverter {
String
provisionerScalingMode
=
"fixed"
;
String
provisionerScalingMode
=
"fixed"
;
SubTopology
subTopology
=
createSubTopology
(
cloudProvider
);
SubTopology
subTopology
=
createSubTopology
(
cloudProvider
);
subTopologyInfo
.
cloudProvider
=
cloudProvider
;
subTopologyInfo
.
cloudProvider
=
cloudProvider
;
subTopologyInfo
.
topology
=
UUID
.
randomUUID
().
toString
(
);
subTopologyInfo
.
topology
=
topologyNodeName
.
replaceAll
(
"_"
,
""
);
subTopologyInfo
.
domain
=
domainName
;
subTopologyInfo
.
domain
=
domainName
;
subTopologyInfo
.
status
=
"fresh"
;
subTopologyInfo
.
status
=
"fresh"
;
subTopologyInfo
.
statusInfo
=
null
;
subTopologyInfo
.
statusInfo
=
null
;
subTopologyInfo
.
tag
=
provisionerScalingMode
;
subTopologyInfo
.
tag
=
provisionerScalingMode
;
Map
<
String
,
SubTopologyInfo
>
subTopologyInfos
=
new
HashMap
<>();
Map
<
String
,
SubTopologyInfo
>
subTopologyInfos
=
new
HashMap
<>();
int
counter
=
0
;
for
(
Object
element
:
vmList
)
{
for
(
Object
element
:
vmList
)
{
VM
vm
=
createVM
(
element
,
cloudProvider
,
firstVM
);
VM
vm
=
createVM
(
element
,
cloudProvider
,
firstVM
);
firstVM
=
false
;
firstVM
=
false
;
counter
++;
if
(
isScalable
(
element
))
{
if
(
isScalable
(
element
))
{
subTopologyInfo
=
new
SubTopologyInfo
();
subTopologyInfo
=
new
SubTopologyInfo
();
subTopology
=
createSubTopology
(
cloudProvider
);
subTopology
=
createSubTopology
(
cloudProvider
);
provisionerScalingMode
=
"scaling"
;
provisionerScalingMode
=
"scaling"
;
subTopologyInfo
.
cloudProvider
=
cloudProvider
;
subTopologyInfo
.
cloudProvider
=
cloudProvider
;
subTopologyInfo
.
topology
=
UUID
.
randomUUID
().
toString
()
;
subTopologyInfo
.
topology
=
"subTopology"
+
counter
;
subTopologyInfo
.
domain
=
domainName
;
subTopologyInfo
.
domain
=
domainName
;
subTopologyInfo
.
status
=
"fresh"
;
subTopologyInfo
.
status
=
"fresh"
;
subTopologyInfo
.
tag
=
provisionerScalingMode
;
subTopologyInfo
.
tag
=
provisionerScalingMode
;
...
...
drip-provisioner/src/main/java/nl/uva/sne/drip/drip/provisioner/utils/MessageParsing.java
View file @
446c8c13
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment