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
8e2940de
Commit
8e2940de
authored
Feb 16, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added cloud certs in the message
parent
8f0cfc5f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
12 deletions
+43
-12
PlannerController.java
...main/java/nl/uva/sne/drip/api/rest/PlannerController.java
+36
-10
Consumer.java
.../main/java/nl/uva/sne/drip/drip/provisioner/Consumer.java
+7
-2
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/rest/PlannerController.java
View file @
8e2940de
...
...
@@ -108,7 +108,6 @@ public class PlannerController {
return
null
;
}
private
Message
buildPlannerMessage
(
String
toscaId
)
throws
JSONException
,
UnsupportedEncodingException
,
IOException
{
ToscaRepresentation
t2
=
dao
.
findOne
(
toscaId
);
Map
<
String
,
Object
>
map
=
t2
.
getKvMap
();
...
...
@@ -141,26 +140,56 @@ public class PlannerController {
private
Message
buildProvisionerMessage
(
Message
plannerReturnedMessage
,
String
cloudConfID
)
throws
IOException
,
JsonProcessingException
,
JSONException
{
Message
invokationMessage
=
new
Message
();
List
<
Parameter
>
parameters
=
new
ArrayList
();
CloudCredentials
cred
=
cloudCredentialsDao
.
findOne
(
cloudConfID
);
Parameter
conf
=
buildCloudConfParam
(
cred
);
parameters
.
add
(
conf
);
List
<
Parameter
>
certs
=
buildCertificatesParam
(
cred
);
parameters
.
addAll
(
certs
);
List
<
Parameter
>
topologies
=
buildTopologyParams
(
plannerReturnedMessage
);
parameters
.
addAll
(
topologies
);
invokationMessage
.
setParameters
(
parameters
);
invokationMessage
.
setCreationDate
((
System
.
currentTimeMillis
()));
return
invokationMessage
;
}
private
Parameter
buildCloudConfParam
(
CloudCredentials
cred
)
throws
JsonProcessingException
,
JSONException
,
IOException
{
Parameter
conf
=
new
Parameter
();
String
charset
=
"UTF-8"
;
CloudCredentials
cred
=
cloudCredentialsDao
.
findOne
(
cloudConfID
);
Properties
prop
=
Converter
.
Object2Properties
(
cred
);
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
prop
.
store
(
baos
,
null
);
byte
[]
bytes
=
baos
.
toByteArray
();
conf
.
setName
(
"ec2.conf"
);
conf
.
setValue
(
new
String
(
bytes
,
charset
));
parameters
.
add
(
conf
);
return
conf
;
}
private
List
<
Parameter
>
buildCertificatesParam
(
CloudCredentials
cred
)
{
List
<
LoginKey
>
loginKeys
=
cred
.
getLogineKys
();
for
(
LoginKey
lk
:
loginKeys
){
List
<
Parameter
>
parameters
=
new
ArrayList
<>();
for
(
LoginKey
lk
:
loginKeys
)
{
String
domainName
=
lk
.
getAttributes
().
get
(
"domain_name"
);
if
(
domainName
==
null
)
{
domainName
=
lk
.
getAttributes
().
get
(
"domain_name "
);
}
Parameter
cert
=
new
Parameter
();
cert
.
setName
(
"certificate"
);
cert
.
setValue
(
charset
);
cert
.
setValue
(
lk
.
getKey
());
Map
<
String
,
String
>
attributes
=
new
HashMap
<>();
attributes
.
put
(
"filename"
,
domainName
);
cert
.
setAttributes
(
attributes
);
parameters
.
add
(
cert
);
}
return
parameters
;
}
private
List
<
Parameter
>
buildTopologyParams
(
Message
plannerReturnedMessage
)
{
List
<
Parameter
>
returnedParams
=
plannerReturnedMessage
.
getParameters
();
List
<
Parameter
>
parameters
=
new
ArrayList
();
for
(
Parameter
param
:
returnedParams
)
{
Parameter
topology
=
new
Parameter
();
String
name
=
param
.
getName
();
...
...
@@ -181,9 +210,6 @@ public class PlannerController {
}
parameters
.
add
(
topology
);
}
invokationMessage
.
setParameters
(
parameters
);
invokationMessage
.
setCreationDate
((
System
.
currentTimeMillis
()));
return
invokationMessage
;
return
parameters
;
}
}
drip-provisioner/src/main/java/nl/uva/sne/drip/drip/provisioner/Consumer.java
View file @
8e2940de
...
...
@@ -160,11 +160,9 @@ public class Consumer extends DefaultConsumer {
int
fileLevel
=
Integer
.
valueOf
((
String
)
attribute_level
.
get
(
"level"
));
if
(
fileLevel
==
0
)
/////if the file level is 0, it means that this is the top level description
{
File
topologyFile
=
new
File
(
tempInputDirPath
+
"topology_main"
);
if
(
topologyFile
.
createNewFile
())
{
writeValueToFile
((
String
)
param
.
get
(
Parameter
.
VALUE
),
topologyFile
);
mainTopologyPath
=
topologyFile
.
getAbsolutePath
();
}
else
{
return
null
;
...
...
@@ -187,6 +185,13 @@ public class Consumer extends DefaultConsumer {
}
}
}
else
if
(
name
.
equals
(
"certificate"
))
{
JSONObject
attribute
=
param
.
getJSONObject
(
"attributes"
);
String
fileName
=
(
String
)
attribute
.
get
(
"filename"
);
////This file name does not contain suffix of '.yml' for example
File
certificate
=
new
File
(
tempInputDirPath
+
fileName
+
".pem"
);
if
(
certificate
.
createNewFile
())
{
writeValueToFile
((
String
)
param
.
get
(
Parameter
.
VALUE
),
certificate
);
}
}
else
if
(
name
.
equals
(
"logdir"
))
{
logDir
=
(
String
)
param
.
get
(
Parameter
.
VALUE
);
}
else
if
(
name
.
equals
(
"sshkey"
))
{
...
...
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