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
21c571a1
Commit
21c571a1
authored
Sep 13, 2019
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
try to attach outputs to TOSCA. Attach all keys to TOSCA outputs
parent
7f94f332
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
139 additions
and
137 deletions
+139
-137
ProvisionService.java
...in/java/nl/uva/sne/drip/api/service/ProvisionService.java
+139
-137
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/service/ProvisionService.java
View file @
21c571a1
...
@@ -420,12 +420,12 @@ public class ProvisionService {
...
@@ -420,12 +420,12 @@ public class ProvisionService {
provisionResponse
=
new
ProvisionResponse
();
provisionResponse
=
new
ProvisionResponse
();
}
}
Map
<
String
,
Object
>
kvMap
=
null
;
//
Map<String, Object> kvMap = null;
KeyPair
userKey
=
new
KeyPair
();
//
KeyPair userKey = new KeyPair();
KeyPair
deployerKey
=
new
KeyPair
();
//
KeyPair deployerKey = new KeyPair();
Map
<
String
,
Key
>
privateCloudKeys
=
new
HashMap
<>();
//
Map<String, Key> privateCloudKeys = new HashMap<>();
Map
<
String
,
Key
>
publicCloudKeys
=
new
HashMap
<>();
//
Map<String, Key> publicCloudKeys = new HashMap<>();
PlanResponse
plan
=
addCloudCredentialsOnTOSCAPlan
(
provisionRequest
);
PlanResponse
plan
=
addCloudCredentialsOnTOSCAPlan
(
provisionRequest
);
Map
<
String
,
Object
>
toscaPlan
=
plan
.
getKeyValue
();
Map
<
String
,
Object
>
toscaPlan
=
plan
.
getKeyValue
();
...
@@ -442,8 +442,7 @@ public class ProvisionService {
...
@@ -442,8 +442,7 @@ public class ProvisionService {
Logger
.
getLogger
(
ProvisionController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
Logger
.
getLogger
(
ProvisionController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
throw
ex
;
throw
ex
;
}
}
switch
(
name
)
{
if
(
name
.
equals
(
"deploy_parameters"
))
{
case
"deploy_parameters"
:
String
value
=
p
.
getValue
();
String
value
=
p
.
getValue
();
String
[]
lines
=
value
.
split
(
"\n"
);
String
[]
lines
=
value
.
split
(
"\n"
);
if
(
value
.
length
()
<
2
)
{
if
(
value
.
length
()
<
2
)
{
...
@@ -470,67 +469,71 @@ public class ProvisionService {
...
@@ -470,67 +469,71 @@ public class ProvisionService {
Map
<
String
,
Object
>
properties
=
(
Map
<
String
,
Object
>)
vmList
.
get
(
i
).
get
(
"properties"
);
Map
<
String
,
Object
>
properties
=
(
Map
<
String
,
Object
>)
vmList
.
get
(
i
).
get
(
"properties"
);
properties
.
put
(
"user_name"
,
deployUser
);
properties
.
put
(
"user_name"
,
deployUser
);
}
}
if
(
name
.
contains
(
"_key"
))
{
break
;
case
"public_user_key"
:
Key
key
=
new
Key
();
key
.
setKey
(
p
.
getValue
());
key
.
setName
(
p
.
getAttributes
().
get
(
"name"
));
key
.
setType
(
Key
.
KeyType
.
PUBLIC
);
userKey
.
setPublicKey
(
key
);
break
;
case
"private_user_key"
:
key
=
new
Key
();
key
.
setKey
(
p
.
getValue
());
key
.
setName
(
p
.
getAttributes
().
get
(
"name"
));
key
.
setType
(
Key
.
KeyType
.
PRIVATE
);
userKey
.
setPrivateKey
(
key
);
break
;
case
"private_deployer_key"
:
key
=
new
Key
();
key
.
setKey
(
p
.
getValue
());
key
.
setName
(
p
.
getAttributes
().
get
(
"name"
));
key
.
setType
(
Key
.
KeyType
.
PRIVATE
);
deployerKey
.
setPrivateKey
(
key
);
break
;
case
"public_deployer_key"
:
key
=
new
Key
();
key
.
setKey
(
p
.
getValue
());
key
.
setName
(
p
.
getAttributes
().
get
(
"name"
));
key
.
setType
(
Key
.
KeyType
.
PUBLIC
);
deployerKey
.
setPublicKey
(
key
);
break
;
case
"public_cloud_key"
:
key
=
new
Key
();
key
.
setKey
(
p
.
getValue
());
key
.
setName
(
p
.
getAttributes
().
get
(
"name"
));
key
.
setType
(
Key
.
KeyType
.
PUBLIC
);
key
.
setAttributes
(
p
.
getAttributes
());
publicCloudKeys
.
put
(
p
.
getAttributes
().
get
(
"key_pair_id"
),
key
);
break
;
case
"private_cloud_key"
:
key
=
new
Key
();
key
.
setKey
(
p
.
getValue
());
key
.
setName
(
p
.
getAttributes
().
get
(
"name"
));
key
.
setType
(
Key
.
KeyType
.
PRIVATE
);
key
.
setAttributes
(
p
.
getAttributes
());
privateCloudKeys
.
put
(
p
.
getAttributes
().
get
(
"key_pair_id"
),
key
);
break
;
default
:
value
=
p
.
getValue
();
if
(
kvMap
==
null
)
{
kvMap
=
new
HashMap
();
}
kvMap
.
put
(
name
,
Converter
.
ymlString2Map
(
value
));
break
;
}
for
(
String
nodeName
:
nodeNames
)
{
for
(
String
nodeName
:
nodeNames
)
{
Map
<
String
,
Object
>
keyOutput
=
TOSCAUtils
.
buildTOSCAOutput
(
nodeName
,
p
.
getValue
());
Map
<
String
,
Object
>
keyOutput
=
TOSCAUtils
.
buildTOSCAOutput
(
nodeName
,
p
.
getValue
());
outputs
.
put
(
name
,
keyOutput
);
outputs
.
put
(
name
,
keyOutput
);
}
}
}
}
}
// switch (name) {
// case "deploy_parameters":
// break;
// case "public_user_key":
// Key key = new Key();
// key.setKey(p.getValue());
// key.setName(p.getAttributes().get("name"));
// key.setType(Key.KeyType.PUBLIC);
// userKey.setPublicKey(key);
// break;
// case "private_user_key":
// key = new Key();
// key.setKey(p.getValue());
// key.setName(p.getAttributes().get("name"));
// key.setType(Key.KeyType.PRIVATE);
// userKey.setPrivateKey(key);
// break;
// case "private_deployer_key":
// key = new Key();
// key.setKey(p.getValue());
// key.setName(p.getAttributes().get("name"));
// key.setType(Key.KeyType.PRIVATE);
// deployerKey.setPrivateKey(key);
// break;
// case "public_deployer_key":
// key = new Key();
// key.setKey(p.getValue());
// key.setName(p.getAttributes().get("name"));
// key.setType(Key.KeyType.PUBLIC);
// deployerKey.setPublicKey(key);
// break;
// case "public_cloud_key":
// key = new Key();
// key.setKey(p.getValue());
// key.setName(p.getAttributes().get("name"));
// key.setType(Key.KeyType.PUBLIC);
// key.setAttributes(p.getAttributes());
// publicCloudKeys.put(p.getAttributes().get("key_pair_id"), key);
// break;
//
// case "private_cloud_key":
// key = new Key();
// key.setKey(p.getValue());
// key.setName(p.getAttributes().get("name"));
// key.setType(Key.KeyType.PRIVATE);
// key.setAttributes(p.getAttributes());
// privateCloudKeys.put(p.getAttributes().get("key_pair_id"), key);
// break;
//
// default:
// value = p.getValue();
// if (kvMap == null) {
// kvMap = new HashMap();
// }
// kvMap.put(name, Converter.ymlString2Map(value));
// break;
// }
}
topologyTemplate
.
put
(
"outputs"
,
outputs
);
topologyTemplate
.
put
(
"outputs"
,
outputs
);
List
<
String
>
userKeyIds
=
null
;
List
<
String
>
userKeyIds
=
null
;
...
@@ -540,49 +543,48 @@ public class ProvisionService {
...
@@ -540,49 +543,48 @@ public class ProvisionService {
// userKeyIds = provisionResponse.getUserKeyPairIDs();
// userKeyIds = provisionResponse.getUserKeyPairIDs();
}
}
if
(
saveUserKeys
)
{
// if (saveUserKeys) {
if
(
userKeyIds
!=
null
&&
!
userKeyIds
.
isEmpty
())
{
// if (userKeyIds != null && !userKeyIds.isEmpty()) {
}
else
{
// } else {
userKeyIds
=
new
ArrayList
<>();
// userKeyIds = new ArrayList<>();
if
(
userKey
.
getPublicKey
()
!=
null
)
{
// if (userKey.getPublicKey() != null) {
userKey
=
keyPairService
.
save
(
userKey
);
// userKey = keyPairService.save(userKey);
userKeyIds
.
add
(
userKey
.
getId
());
// userKeyIds.add(userKey.getId());
}
// }
}
// }
}
// }
ArrayList
<
String
>
deployerKeyIds
=
null
;
// ArrayList<String> deployerKeyIds = null;
if
(
saveDeployerKeyI
)
{
// if (saveDeployerKeyI) {
deployerKeyIds
=
new
ArrayList
<>();
// deployerKeyIds = new ArrayList<>();
if
(
deployerKey
.
getPublicKey
()
!=
null
)
{
// if (deployerKey.getPublicKey() != null) {
deployerKey
=
keyPairService
.
save
(
deployerKey
);
// deployerKey = keyPairService.save(deployerKey);
deployerKeyIds
.
add
(
deployerKey
.
getId
());
// deployerKeyIds.add(deployerKey.getId());
}
// }
}
// }
// ArrayList<String> cloudKeyPairIDs = new ArrayList<>();
ArrayList
<
String
>
cloudKeyPairIDs
=
new
ArrayList
<>();
// List<KeyPair> allPirs = keyPairService.findAll();
List
<
KeyPair
>
allPirs
=
keyPairService
.
findAll
();
// for (String id : publicCloudKeys.keySet()) {
for
(
String
id
:
publicCloudKeys
.
keySet
())
{
// boolean save = true;
boolean
save
=
true
;
// String key_pair_id = privateCloudKeys.get(id).getAttributes().get("key_pair_id");
String
key_pair_id
=
privateCloudKeys
.
get
(
id
).
getAttributes
().
get
(
"key_pair_id"
);
// for (KeyPair p : allPirs) {
for
(
KeyPair
p
:
allPirs
)
{
// Key pk = p.getPrivateKey();
Key
pk
=
p
.
getPrivateKey
();
// if (pk != null && pk.getAttributes() != null && pk.getAttributes().containsKey("key_pair_id")) {
if
(
pk
!=
null
&&
pk
.
getAttributes
()
!=
null
&&
pk
.
getAttributes
().
containsKey
(
"key_pair_id"
))
{
// if (key_pair_id.equals(pk.getAttributes().get("key_pair_id"))) {
if
(
key_pair_id
.
equals
(
pk
.
getAttributes
().
get
(
"key_pair_id"
)))
{
// save = false;
save
=
false
;
// break;
break
;
// }
}
// }
}
// }
}
// if (save) {
if
(
save
)
{
// KeyPair cloudPair = new KeyPair();
KeyPair
cloudPair
=
new
KeyPair
();
// cloudPair.setPrivateKey(privateCloudKeys.get(id));
cloudPair
.
setPrivateKey
(
privateCloudKeys
.
get
(
id
));
// cloudPair.setPublicKey(publicCloudKeys.get(id));
cloudPair
.
setPublicKey
(
publicCloudKeys
.
get
(
id
));
// cloudPair.setKeyPairId(id);
cloudPair
.
setKeyPairId
(
id
);
// cloudPair = keyPairService.save(cloudPair);
cloudPair
=
keyPairService
.
save
(
cloudPair
);
// cloudKeyPairIDs.add(cloudPair.getId());
cloudKeyPairIDs
.
add
(
cloudPair
.
getId
());
// }
}
//
// }
}
// ArrayList<String> existingCloudKeyPairIDs = provisionResponse.getCloudKeyPairIDs();
// ArrayList<String> existingCloudKeyPairIDs = provisionResponse.getCloudKeyPairIDs();
// if (existingCloudKeyPairIDs != null) {
// if (existingCloudKeyPairIDs != null) {
// existingCloudKeyPairIDs.addAll(cloudKeyPairIDs);
// existingCloudKeyPairIDs.addAll(cloudKeyPairIDs);
...
@@ -594,17 +596,17 @@ public class ProvisionService {
...
@@ -594,17 +596,17 @@ public class ProvisionService {
// provisionResponse.setDeployParameters(deployParameters);
// provisionResponse.setDeployParameters(deployParameters);
// provisionResponse.setKvMap(kvMap);
// provisionResponse.setKvMap(kvMap);
provisionResponse
.
setKvMap
(
toscaPlan
);
provisionResponse
.
setKvMap
(
toscaPlan
);
if
(
provisionRequest
!=
null
)
{
//
if (provisionRequest != null) {
// provisionResponse.setCloudCredentialsIDs(provisionRequest.getCloudCredentialsIDs());
//
//
provisionResponse.setCloudCredentialsIDs(provisionRequest.getCloudCredentialsIDs());
provisionResponse
.
setPlanID
(
provisionRequest
.
getPlanID
());
//
provisionResponse.setPlanID(provisionRequest.getPlanID());
}
//
}
//
if
(
userKeyIds
!=
null
)
{
//
if (userKeyIds != null) {
// provisionResponse.setUserKeyPairIDs(userKeyIds);
//
//
provisionResponse.setUserKeyPairIDs(userKeyIds);
}
//
}
if
(
deployerKeyIds
!=
null
)
{
//
if (deployerKeyIds != null) {
// provisionResponse.setDeployerKeyPairIDs(deployerKeyIds);
//
//
provisionResponse.setDeployerKeyPairIDs(deployerKeyIds);
}
//
}
provisionResponse
=
save
(
provisionResponse
);
provisionResponse
=
save
(
provisionResponse
);
return
provisionResponse
;
return
provisionResponse
;
...
...
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