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
eaece803
Commit
eaece803
authored
8 years ago
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug with ymal format
parent
e6b13acf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
28 deletions
+42
-28
DeployController.java
.../main/java/nl/uva/sne/drip/api/rest/DeployController.java
+10
-3
ProvisionController.java
...in/java/nl/uva/sne/drip/api/rest/ProvisionController.java
+27
-22
DRIPCaller.java
...api/src/main/java/nl/uva/sne/drip/api/rpc/DRIPCaller.java
+4
-2
PlannerService.java
...main/java/nl/uva/sne/drip/api/service/PlannerService.java
+1
-1
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/rest/DeployController.java
View file @
eaece803
...
@@ -81,8 +81,8 @@ public class DeployController {
...
@@ -81,8 +81,8 @@ public class DeployController {
try
(
DRIPCaller
deployer
=
new
DeployerCaller
(
messageBrokerHost
);)
{
try
(
DRIPCaller
deployer
=
new
DeployerCaller
(
messageBrokerHost
);)
{
Message
deployerInvokationMessage
=
buildDeployerMessage
(
provisionID
,
clusterType
.
toLowerCase
());
Message
deployerInvokationMessage
=
buildDeployerMessage
(
provisionID
,
clusterType
.
toLowerCase
());
// Message response = deployer.unmarshall
(deployer.call(deployerInvokationMessage));
Message
response
=
(
deployer
.
call
(
deployerInvokationMessage
));
Message
response
=
generateFakeResponse
();
//
Message response = generateFakeResponse();
List
<
MessageParameter
>
params
=
response
.
getParameters
();
List
<
MessageParameter
>
params
=
response
.
getParameters
();
ClusterCredentials
clusterCred
=
new
ClusterCredentials
();
ClusterCredentials
clusterCred
=
new
ClusterCredentials
();
for
(
MessageParameter
p
:
params
)
{
for
(
MessageParameter
p
:
params
)
{
...
@@ -105,7 +105,11 @@ public class DeployController {
...
@@ -105,7 +105,11 @@ public class DeployController {
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
ClusterCredentials
get
(
@PathVariable
(
"id"
)
String
id
)
{
ClusterCredentials
get
(
@PathVariable
(
"id"
)
String
id
)
{
return
clusterCredentialService
.
getDao
().
findOne
(
id
);
ClusterCredentials
clusterC
=
clusterCredentialService
.
getDao
().
findOne
(
id
);
if
(
clusterC
==
null
)
{
throw
new
NotFoundException
();
}
return
clusterC
;
}
}
@RequestMapping
(
value
=
"/ids"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/ids"
,
method
=
RequestMethod
.
GET
)
...
@@ -134,6 +138,9 @@ public class DeployController {
...
@@ -134,6 +138,9 @@ public class DeployController {
private
Message
buildDeployerMessage
(
String
provisionID
,
String
clusterType
)
{
private
Message
buildDeployerMessage
(
String
provisionID
,
String
clusterType
)
{
ProvisionInfo
pro
=
provisionService
.
getDao
().
findOne
(
provisionID
);
ProvisionInfo
pro
=
provisionService
.
getDao
().
findOne
(
provisionID
);
if
(
pro
==
null
)
{
throw
new
NotFoundException
();
}
String
cloudConfID
=
pro
.
getCloudConfID
();
String
cloudConfID
=
pro
.
getCloudConfID
();
CloudCredentials
cCred
=
cloudCredentialsDao
.
findOne
(
cloudConfID
);
CloudCredentials
cCred
=
cloudCredentialsDao
.
findOne
(
cloudConfID
);
List
<
LoginKey
>
loginKeys
=
cCred
.
getLoginKeys
();
List
<
LoginKey
>
loginKeys
=
cCred
.
getLoginKeys
();
...
...
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/rest/ProvisionController.java
View file @
eaece803
...
@@ -20,6 +20,7 @@ import nl.uva.sne.drip.commons.types.ProvisionInfo;
...
@@ -20,6 +20,7 @@ import nl.uva.sne.drip.commons.types.ProvisionInfo;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -46,7 +47,6 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -46,7 +47,6 @@ import org.springframework.web.bind.annotation.RestController;
import
nl.uva.sne.drip.api.exception.BadRequestException
;
import
nl.uva.sne.drip.api.exception.BadRequestException
;
import
nl.uva.sne.drip.api.exception.CloudCredentialsNotFoundException
;
import
nl.uva.sne.drip.api.exception.CloudCredentialsNotFoundException
;
import
nl.uva.sne.drip.api.exception.ExceptionHandler
;
import
nl.uva.sne.drip.api.exception.ExceptionHandler
;
import
nl.uva.sne.drip.api.exception.InternalServerErrorException
;
import
nl.uva.sne.drip.api.exception.NotFoundException
;
import
nl.uva.sne.drip.api.exception.NotFoundException
;
import
nl.uva.sne.drip.api.exception.PlanNotFoundException
;
import
nl.uva.sne.drip.api.exception.PlanNotFoundException
;
import
nl.uva.sne.drip.api.rpc.DRIPCaller
;
import
nl.uva.sne.drip.api.rpc.DRIPCaller
;
...
@@ -61,6 +61,7 @@ import nl.uva.sne.drip.commons.types.DeployParameter;
...
@@ -61,6 +61,7 @@ import nl.uva.sne.drip.commons.types.DeployParameter;
import
nl.uva.sne.drip.commons.types.LoginKey
;
import
nl.uva.sne.drip.commons.types.LoginKey
;
import
nl.uva.sne.drip.commons.types.Plan
;
import
nl.uva.sne.drip.commons.types.Plan
;
import
nl.uva.sne.drip.commons.types.UserScript
;
import
nl.uva.sne.drip.commons.types.UserScript
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.commons.io.FilenameUtils
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
...
@@ -131,10 +132,12 @@ public class ProvisionController {
...
@@ -131,10 +132,12 @@ public class ProvisionController {
Message
provisionerInvokationMessage
=
buildProvisionerMessage
(
req
);
Message
provisionerInvokationMessage
=
buildProvisionerMessage
(
req
);
Message
response
=
(
provisioner
.
call
(
provisionerInvokationMessage
));
Message
response
=
(
provisioner
.
call
(
provisionerInvokationMessage
));
// Message response = generateFakeResponse(System.getProperty("user.home")
// Message response = generateFakeResponse();
// + File.separator + "workspace" + File.separator + "DRIP"
// + File.separator + "doc" + File.separator + "json_samples" +
// File.separator + "ec2_provisioner_provisoned2.json");
List
<
MessageParameter
>
params
=
response
.
getParameters
();
List
<
MessageParameter
>
params
=
response
.
getParameters
();
for
(
MessageParameter
p
:
params
)
{
for
(
MessageParameter
p
:
params
)
{
String
name
=
p
.
getName
();
String
name
=
p
.
getName
();
if
(
name
.
toLowerCase
().
contains
(
"exception"
))
{
if
(
name
.
toLowerCase
().
contains
(
"exception"
))
{
...
@@ -170,8 +173,8 @@ public class ProvisionController {
...
@@ -170,8 +173,8 @@ public class ProvisionController {
}
}
req
.
setDeployParameters
(
deployParameters
);
req
.
setDeployParameters
(
deployParameters
);
}
}
provisionService
.
getDao
().
save
(
req
);
}
}
provisionService
.
getDao
().
save
(
req
);
return
req
.
getId
();
return
req
.
getId
();
}
catch
(
IOException
|
TimeoutException
|
JSONException
|
InterruptedException
ex
)
{
}
catch
(
IOException
|
TimeoutException
|
JSONException
|
InterruptedException
ex
)
{
Logger
.
getLogger
(
ProvisionController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
Logger
.
getLogger
(
ProvisionController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
...
@@ -321,23 +324,25 @@ public class ProvisionController {
...
@@ -321,23 +324,25 @@ public class ProvisionController {
}
}
private
Message
generateFakeResponse
()
throws
IOException
,
TimeoutException
,
InterruptedException
,
JSONException
{
private
Message
generateFakeResponse
(
String
path
)
throws
IOException
,
TimeoutException
,
InterruptedException
,
JSONException
{
String
strResponse
=
"{\"creationDate\":1488368936945,\"parameters\":["
// String strResponse = "{\"creationDate\":1488368936945,\"parameters\":["
+
"{\"name\":\"f293ff03-4b82-49e2-871a-899aadf821ce\","
// + "{\"name\":\"f293ff03-4b82-49e2-871a-899aadf821ce\","
+
"\"encoding\":\"UTF-8\",\"value\":"
// + "\"encoding\":\"UTF-8\",\"value\":"
+
"\"publicKeyPath: /tmp/Input-4007028381500/user.pem\\nuserName: "
// + "\"publicKeyPath: /tmp/Input-4007028381500/user.pem\\nuserName: "
+
"zh9314\\nsubnets:\\n- {name: s1, subnet: 192.168.10.0, "
// + "zh9314\\nsubnets:\\n- {name: s1, subnet: 192.168.10.0, "
+
"netmask: 255.255.255.0}\\ncomponents:\\n- "
// + "netmask: 255.255.255.0}\\ncomponents:\\n- "
+
"name: faab6756-61b6-4800-bffa-ae9d859a9d6c\\n "
// + "name: faab6756-61b6-4800-bffa-ae9d859a9d6c\\n "
+
"type: Switch.nodes.Compute\\n nodetype: t2.medium\\n "
// + "type: Switch.nodes.Compute\\n nodetype: t2.medium\\n "
+
"OStype: Ubuntu 16.04\\n domain: ec2.us-east-1.amazonaws.com\\n "
// + "OStype: Ubuntu 16.04\\n domain: ec2.us-east-1.amazonaws.com\\n "
+
"script: /tmp/Input-4007028381500/guiscipt.sh\\n "
// + "script: /tmp/Input-4007028381500/guiscipt.sh\\n "
+
"installation: null\\n role: master\\n "
// + "installation: null\\n role: master\\n "
+
"dockers: mogswitch/InputDistributor\\n "
// + "dockers: mogswitch/InputDistributor\\n "
+
"public_address: 54.144.0.91\\n instanceId: i-0e78cbf853328b820\\n "
// + "public_address: 54.144.0.91\\n instanceId: i-0e78cbf853328b820\\n "
+
"ethernet_port:\\n - {name: p1, subnet_name: s1, "
// + "ethernet_port:\\n - {name: p1, subnet_name: s1, "
+
"address: 192.168.10.10}\\n- name: 1c75eedf-8497-46fe-aeb8-dab6a62154cb\\n "
// + "address: 192.168.10.10}\\n- name: 1c75eedf-8497-46fe-aeb8-dab6a62154cb\\n "
+
"type: Switch.nodes.Compute\\n nodetype: t2.medium\\n OStype: Ubuntu 16.04\\n domain: ec2.us-east-1.amazonaws.com\\n script: /tmp/Input-4007028381500/guiscipt.sh\\n installation: null\\n role: slave\\n dockers: mogswitch/ProxyTranscoder\\n public_address: 34.207.254.160\\n instanceId: i-0a99ea18fcc77ed7a\\n ethernet_port:\\n - {name: p1, subnet_name: s1, address: 192.168.10.11}\\n\"},{\"name\":\"kubernetes\",\"encoding\":\"UTF-8\",\"value\":\"54.144.0.91 ubuntu /tmp/Input-4007028381500/Virginia.pem master\\n34.207.254.160 ubuntu /tmp/Input-4007028381500/Virginia.pem slave\\n\"}]}"
;
// + "type: Switch.nodes.Compute\\n nodetype: t2.medium\\n OStype: Ubuntu 16.04\\n domain: ec2.us-east-1.amazonaws.com\\n script: /tmp/Input-4007028381500/guiscipt.sh\\n installation: null\\n role: slave\\n dockers: mogswitch/ProxyTranscoder\\n public_address: 34.207.254.160\\n instanceId: i-0a99ea18fcc77ed7a\\n ethernet_port:\\n - {name: p1, subnet_name: s1, address: 192.168.10.11}\\n\"},{\"name\":\"kubernetes\",\"encoding\":\"UTF-8\",\"value\":\"54.144.0.91 ubuntu /tmp/Input-4007028381500/Virginia.pem master\\n34.207.254.160 ubuntu /tmp/Input-4007028381500/Virginia.pem slave\\n\"}]}";
// String strResponse = "{\"creationDate\":1488805337447,\"parameters\":[{\"name\":\"2e5dafb6-5a1c-4a66-9dca-5841f99ea735\",\"encoding\":\"UTF-8\",\"value\":\"publicKeyPath: /tmp/Input-11594765342486/user.pem\\nuserName: zh9314\\nsubnets:\\n- {name: s1, subnet: 192.168.10.0, netmask: 255.255.255.0}\\ncomponents:\\n- name: 8fcc1788d9ee462c826572c79fdb2a6a\\n type: Switch.nodes.Compute\\n nodeType: t2.medium\\n OStype: Ubuntu 16.04\\n script: /tmp/Input-11594765342486/guiscipt.sh\\n domain: ec2.us-east-1.amazonaws.com\\n installation: null\\n clusterType: swarm\\n role: master\\n dockers: mogswitch/ProxyTranscoder:1.0\\n public_address: 34.207.73.18\\n instanceId: i-0e82b5624a0df99b1\\n ethernet_port:\\n - {name: p1, subnet_name: s1, address: 192.168.10.10}\\n- name: 8fcc1788d9ee462c826572c79fdb2a6a\\n type: Switch.nodes.Compute\\n nodeType: t2.medium\\n OStype: Ubuntu 16.04\\n script: /tmp/Input-11594765342486/guiscipt.sh\\n domain: ec2.us-east-1.amazonaws.com\\n installation: null\\n clusterType: swarm\\n role: slave\\n dockers: mogswitch/ProxyTranscoder:1.0\\n public_address: 34.207.73.18\\n instanceId: i-0e82b5624a0df99b1\\n ethernet_port:\\n - {name: p1, subnet_name: s1, address: 192.168.10.11}\\n\"},{\"name\":\"kubernetes\",\"encoding\":\"UTF-8\",\"value\":\"34.207.73.18 ubuntu /tmp/Input-11594765342486/Virginia.pem master\\n34.207.73.18 ubuntu /tmp/Input-11594765342486/Virginia.pem slave\\n\"}]}";
String
strResponse
=
FileUtils
.
readFileToString
(
new
File
(
path
));
ObjectMapper
mapper
=
new
ObjectMapper
();
ObjectMapper
mapper
=
new
ObjectMapper
();
mapper
.
configure
(
JsonParser
.
Feature
.
ALLOW_SINGLE_QUOTES
,
true
);
mapper
.
configure
(
JsonParser
.
Feature
.
ALLOW_SINGLE_QUOTES
,
true
);
...
...
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/rpc/DRIPCaller.java
View file @
eaece803
...
@@ -122,8 +122,10 @@ public abstract class DRIPCaller implements AutoCloseable {
...
@@ -122,8 +122,10 @@ public abstract class DRIPCaller implements AutoCloseable {
}
}
});
});
String
resp
=
response
.
take
();
String
resp
=
response
.
take
();
String
clean
=
resp
.
replaceAll
(
"'null'"
,
"null"
).
replaceAll
(
"\'"
,
"\""
).
replaceAll
(
" "
,
""
);
String
clean
=
resp
;
if
(
resp
.
contains
(
"'null'"
))
{
clean
=
resp
.
replaceAll
(
"'null'"
,
"null"
).
replaceAll
(
"\'"
,
"\""
).
replaceAll
(
" "
,
""
);
}
if
(
clean
.
contains
(
"\"value\":{\""
))
{
if
(
clean
.
contains
(
"\"value\":{\""
))
{
return
Converter
.
string2Message
(
clean
);
return
Converter
.
string2Message
(
clean
);
}
}
...
...
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/service/PlannerService.java
View file @
eaece803
...
@@ -78,7 +78,7 @@ public class PlannerService {
...
@@ -78,7 +78,7 @@ public class PlannerService {
}
}
jsonArrayString
.
append
(
"]"
);
jsonArrayString
.
append
(
"]"
);
SimplePlanContainer
simplePlan
=
P2PConverter
.
convert
(
jsonArrayString
.
toString
(),
"
zh9314
"
,
"Ubuntu 16.04"
,
"swarm"
);
SimplePlanContainer
simplePlan
=
P2PConverter
.
convert
(
jsonArrayString
.
toString
(),
"
vm_user
"
,
"Ubuntu 16.04"
,
"swarm"
);
Plan
topLevel
=
new
Plan
();
Plan
topLevel
=
new
Plan
();
topLevel
.
setLevel
(
0
);
topLevel
.
setLevel
(
0
);
topLevel
.
setToscaID
(
toscaId
);
topLevel
.
setToscaID
(
toscaId
);
...
...
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