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 {
List
<
String
>
getIds
()
{
List
<
ProvisionResponse
>
all
=
provisionService
.
findAll
();
List
<
String
>
ids
=
new
ArrayList
<>(
all
.
size
());
for
(
ProvisionRe
quest
pi
:
all
)
{
for
(
ProvisionRe
sponse
pi
:
all
)
{
ids
.
add
(
pi
.
getId
());
}
return
ids
;
...
...
@@ -181,9 +181,9 @@ public class ProvisionController {
throw
new
BadRequestException
();
}
try
{
req
=
provisionService
.
provisionResources
(
req
,
1
);
ProvisionResponse
resp
=
provisionService
.
provisionResources
(
req
,
1
);
return
re
q
.
getId
();
return
re
sp
.
getId
();
}
catch
(
Exception
ex
)
{
if
(
ex
instanceof
nl
.
uva
.
sne
.
drip
.
api
.
exception
.
PlanNotFoundException
...
...
@@ -210,16 +210,16 @@ public class ProvisionController {
})
public
@ResponseBody
String
postProvisionResponse
(
@RequestBody
ProvisionResponse
resp
)
{
if
(
resp
.
getCloudCredentialsIDs
()
==
null
||
resp
.
getCloudCredentialsIDs
().
get
(
0
)
==
null
||
resp
.
getCloudCredentialsIDs
().
get
(
0
).
length
()
<
2
)
{
throw
new
BadRequestException
();
}
if
(
resp
.
getPlanID
()
==
null
||
resp
.
getPlanID
().
length
()
<
2
)
{
throw
new
BadRequestException
();
}
if
(
resp
.
getDeployParameters
()
==
null
||
resp
.
getDeployParameters
().
get
(
0
)
==
null
)
{
throw
new
BadRequestException
();
}
//
if (resp.getCloudCredentialsIDs() == null || resp.getCloudCredentialsIDs().get(0) == null
//
|| resp.getCloudCredentialsIDs().get(0).length() < 2) {
//
throw new BadRequestException();
//
}
//
if (resp.getPlanID() == null || resp.getPlanID().length() < 2) {
//
throw new BadRequestException();
//
}
//
if (resp.getDeployParameters() == null || resp.getDeployParameters().get(0) == null) {
//
throw new BadRequestException();
//
}
resp
=
provisionService
.
save
(
resp
);
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 @@
package
nl
.
uva
.
sne
.
drip
.
drip
.
commons
.
data
.
v1
.
external
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.webcohesion.enunciate.metadata.DocumentationExample
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -25,36 +26,55 @@ import java.util.List;
* @author S. Koulouzis
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
ProvisionResponse
extends
ProvisionRequest
{
private
List
<
DeployParameter
>
deployParameters
;
private
ArrayList
<
String
>
cloudKeyPairIDs
;
/**
* The deploy parameters.
public
class
ProvisionResponse
extends
KeyValueHolder
{
private
String
planID
;
/**
* The ID of the plan <code>PlanResponse</code> to provision for.
*
* @return the
deployParameters
* @return the
planID
*/
public
List
<
DeployParameter
>
getDeployParameters
()
{
return
deployParameters
;
@DocumentationExample
(
"ASedsfd46b4fDFd83ba1q"
)
public
String
getPlanID
()
{
return
planID
;
}
/**
* @param
deployParameters the deployParameters
to set
* @param
planID the planID
to set
*/
public
void
setDeployParameters
(
List
<
DeployParameter
>
deployParameters
)
{
this
.
deployParameters
=
deployParameters
;
}
public
void
setCloudKeyPairIDs
(
ArrayList
<
String
>
cloudKeyPairIDs
)
{
this
.
cloudKeyPairIDs
=
cloudKeyPairIDs
;
public
void
setPlanID
(
String
planID
)
{
this
.
planID
=
planID
;
}
/**
* @return the cloudKeyPairIDs
*/
public
ArrayList
<
String
>
getCloudKeyPairIDs
()
{
return
cloudKeyPairIDs
;
}
// private List<DeployParameter> deployParameters;
// private ArrayList<String> 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;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.UUID
;
import
com.fasterxml.jackson.core.JsonParseException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
...
...
@@ -25,24 +24,28 @@ import org.json.JSONException;
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
{
if
(
cloudProvider
!=
null
)
{
cloudProvider
=
cloudProvider
.
toUpperCase
();
}
Map
<
String
,
Object
>
topologyTemplate
=
(
Map
<
String
,
Object
>)
((
Map
<
String
,
Object
>)
toscaPlanMap
.
get
(
"topology_template"
)).
get
(
"node_templates"
);
//Get the domain provider and vm list
Map
<
String
,
Object
>
topologyNode
=
null
;
String
topologyNodeName
=
null
;
List
<
String
>
vmNames
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
topologyTemplate
.
entrySet
())
{
Map
<
String
,
Object
>
node
=
(
Map
<
String
,
Object
>)
entry
.
getValue
();
String
type
=
(
String
)
node
.
get
(
"type"
);
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"
);
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
)
{
Map
<
String
,
Object
>
requirementMap
=
(
Map
<
String
,
Object
>)
requirement
;
...
...
@@ -51,13 +54,16 @@ public class P2PConverter {
String
nodeName
=
(
String
)
((
Map
<
String
,
Object
>)
requirementMap
.
get
(
requirementEntry
.
getKey
())).
get
(
"node"
);
vmNames
.
add
(
nodeName
);
}
break
;
}
}
List
<
Object
>
vmList
=
new
ArrayList
<>();
for
(
String
vmName
:
vmNames
)
{
Map
<
String
,
Object
>
vm
=
(
Map
<
String
,
Object
>)
topologyTemplate
.
get
(
vmName
);
userName
=
(
String
)
((
Map
<
String
,
Object
>)
vm
.
get
(
"properties"
)).
get
(
"user_name"
);
vm
.
put
(
"name"
,
vmName
);
Map
<
String
,
Object
>
properties
=
(
Map
<
String
,
Object
>)
vm
.
get
(
"properties"
);
userName
=
(
String
)
properties
.
get
(
"user_name"
);
String
hostName
=
(
String
)
properties
.
get
(
"host_name"
);
vm
.
put
(
"name"
,
hostName
);
vmList
.
add
(
vm
);
}
...
...
@@ -71,23 +77,24 @@ public class P2PConverter {
String
provisionerScalingMode
=
"fixed"
;
SubTopology
subTopology
=
createSubTopology
(
cloudProvider
);
subTopologyInfo
.
cloudProvider
=
cloudProvider
;
subTopologyInfo
.
topology
=
UUID
.
randomUUID
().
toString
(
);
subTopologyInfo
.
topology
=
topologyNodeName
.
replaceAll
(
"_"
,
""
);
subTopologyInfo
.
domain
=
domainName
;
subTopologyInfo
.
status
=
"fresh"
;
subTopologyInfo
.
statusInfo
=
null
;
subTopologyInfo
.
tag
=
provisionerScalingMode
;
Map
<
String
,
SubTopologyInfo
>
subTopologyInfos
=
new
HashMap
<>();
int
counter
=
0
;
for
(
Object
element
:
vmList
)
{
VM
vm
=
createVM
(
element
,
cloudProvider
,
firstVM
);
firstVM
=
false
;
counter
++;
if
(
isScalable
(
element
))
{
subTopologyInfo
=
new
SubTopologyInfo
();
subTopology
=
createSubTopology
(
cloudProvider
);
provisionerScalingMode
=
"scaling"
;
subTopologyInfo
.
cloudProvider
=
cloudProvider
;
subTopologyInfo
.
topology
=
UUID
.
randomUUID
().
toString
()
;
subTopologyInfo
.
topology
=
"subTopology"
+
counter
;
subTopologyInfo
.
domain
=
domainName
;
subTopologyInfo
.
status
=
"fresh"
;
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