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
748a4066
Commit
748a4066
authored
Oct 13, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
select cloud provider based on avaliable credentials
parent
ade73225
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
6 deletions
+26
-6
PlannerService.java
...main/java/nl/uva/sne/drip/api/service/PlannerService.java
+24
-2
PlannerController0.java
.../java/nl/uva/sne/drip/api/v0/rest/PlannerController0.java
+1
-2
PlannerController.java
...n/java/nl/uva/sne/drip/api/v1/rest/PlannerController.java
+1
-2
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/service/PlannerService.java
View file @
748a4066
...
@@ -34,6 +34,7 @@ import nl.uva.sne.drip.drip.commons.data.internal.MessageParameter;
...
@@ -34,6 +34,7 @@ import nl.uva.sne.drip.drip.commons.data.internal.MessageParameter;
import
nl.uva.sne.drip.drip.commons.data.v1.external.PlanResponse
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.PlanResponse
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.ToscaRepresentation
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.ToscaRepresentation
;
import
nl.uva.sne.drip.commons.utils.Converter
;
import
nl.uva.sne.drip.commons.utils.Converter
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.CloudCredentials
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.User
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.User
;
import
nl.uva.sne.drip.drip.converter.P2PConverter
;
import
nl.uva.sne.drip.drip.converter.P2PConverter
;
import
nl.uva.sne.drip.drip.converter.SimplePlanContainer
;
import
nl.uva.sne.drip.drip.converter.SimplePlanContainer
;
...
@@ -57,13 +58,16 @@ public class PlannerService {
...
@@ -57,13 +58,16 @@ public class PlannerService {
@Autowired
@Autowired
private
ToscaService
toscaService
;
private
ToscaService
toscaService
;
@Autowired
private
CloudCredentialsService
credentialService
;
@Autowired
@Autowired
private
PlanDao
planDao
;
private
PlanDao
planDao
;
@Value
(
"${message.broker.host}"
)
@Value
(
"${message.broker.host}"
)
private
String
messageBrokerHost
;
private
String
messageBrokerHost
;
public
PlanResponse
getPlan
(
String
toscaId
,
String
vmUser
,
String
cloudProvider
,
String
domainName
)
throws
JSONException
,
UnsupportedEncodingException
,
IOException
,
TimeoutException
,
InterruptedException
{
public
PlanResponse
getPlan
(
String
toscaId
)
throws
JSONException
,
UnsupportedEncodingException
,
IOException
,
TimeoutException
,
InterruptedException
{
try
(
PlannerCaller
planner
=
new
PlannerCaller
(
messageBrokerHost
))
{
try
(
PlannerCaller
planner
=
new
PlannerCaller
(
messageBrokerHost
))
{
Message
plannerInvokationMessage
=
buildPlannerMessage
(
toscaId
);
Message
plannerInvokationMessage
=
buildPlannerMessage
(
toscaId
);
Message
plannerReturnedMessage
=
(
planner
.
call
(
plannerInvokationMessage
));
Message
plannerReturnedMessage
=
(
planner
.
call
(
plannerInvokationMessage
));
...
@@ -83,8 +87,11 @@ public class PlannerService {
...
@@ -83,8 +87,11 @@ public class PlannerService {
}
}
jsonArrayString
.
append
(
"]"
);
jsonArrayString
.
append
(
"]"
);
String
cloudProvider
=
getBestCloudProvider
();
String
domainName
=
getBestDomain
(
cloudProvider
);
// SimplePlanContainer simplePlan = P2PConverter.convert(jsonArrayString.toString(), "vm_user", "Ubuntu 16.04", clusterType);
// SimplePlanContainer simplePlan = P2PConverter.convert(jsonArrayString.toString(), "vm_user", "Ubuntu 16.04", clusterType);
SimplePlanContainer
simplePlan
=
P2PConverter
.
transfer
(
jsonArrayString
.
toString
(),
vmUser
,
domainName
,
cloudProvider
);
SimplePlanContainer
simplePlan
=
P2PConverter
.
transfer
(
jsonArrayString
.
toString
(),
"vm_user"
,
domainName
,
cloudProvider
);
PlanResponse
topLevel
=
new
PlanResponse
();
PlanResponse
topLevel
=
new
PlanResponse
();
topLevel
.
setTimestamp
(
System
.
currentTimeMillis
());
topLevel
.
setTimestamp
(
System
.
currentTimeMillis
());
...
@@ -253,4 +260,19 @@ public class PlannerService {
...
@@ -253,4 +260,19 @@ public class PlannerService {
return
false
;
return
false
;
}
}
private
String
getBestCloudProvider
()
{
List
<
CloudCredentials
>
creds
=
credentialService
.
findAll
();
return
creds
.
get
(
0
).
getCloudProviderName
();
}
private
String
getBestDomain
(
String
cloudProvider
)
{
switch
(
cloudProvider
.
trim
().
toLowerCase
())
{
case
"ec2"
:
return
"Virginia"
;
case
"egi"
:
return
"CESNET"
;
}
return
null
;
}
}
}
drip-api/src/main/java/nl/uva/sne/drip/api/v0/rest/PlannerController0.java
View file @
748a4066
...
@@ -61,12 +61,11 @@ public class PlannerController0 {
...
@@ -61,12 +61,11 @@ public class PlannerController0 {
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
Result
plan
(
@RequestBody
Plan
plan0
)
{
Result
plan
(
@RequestBody
Plan
plan0
)
{
try
{
try
{
String
yaml
=
plan0
.
file
;
String
yaml
=
plan0
.
file
;
yaml
=
yaml
.
replaceAll
(
"\\\\n"
,
"\n"
);
yaml
=
yaml
.
replaceAll
(
"\\\\n"
,
"\n"
);
String
id
=
toscaService
.
saveYamlString
(
yaml
,
null
);
String
id
=
toscaService
.
saveYamlString
(
yaml
,
null
);
nl
.
uva
.
sne
.
drip
.
drip
.
commons
.
data
.
v1
.
external
.
PlanResponse
plan1
=
plannerService
.
getPlan
(
id
,
"vm_user"
,
"EC2"
,
"Virginia"
);
nl
.
uva
.
sne
.
drip
.
drip
.
commons
.
data
.
v1
.
external
.
PlanResponse
plan1
=
plannerService
.
getPlan
(
id
);
Result
r
=
new
Result
();
Result
r
=
new
Result
();
r
.
info
=
(
"INFO"
);
r
.
info
=
(
"INFO"
);
r
.
status
=
(
"Success"
);
r
.
status
=
(
"Success"
);
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/v1/rest/PlannerController.java
View file @
748a4066
...
@@ -87,8 +87,7 @@ public class PlannerController {
...
@@ -87,8 +87,7 @@ public class PlannerController {
String
plan
(
@PathVariable
(
"tosca_id"
)
String
toscaId
)
{
String
plan
(
@PathVariable
(
"tosca_id"
)
String
toscaId
)
{
try
{
try
{
PlanResponse
plan
=
plannerService
.
getPlan
(
toscaId
,
PlanResponse
plan
=
plannerService
.
getPlan
(
toscaId
);
"vm_user"
,
"EC2"
,
"Virginia"
);
if
(
plan
==
null
)
{
if
(
plan
==
null
)
{
throw
new
NotFoundException
(
"Could not make plan"
);
throw
new
NotFoundException
(
"Could not make plan"
);
}
}
...
...
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