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
e4ff23bc
Commit
e4ff23bc
authored
Feb 20, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated API for uploads
Update planner controller to save tosca result
parent
40bd8816
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
158 additions
and
67 deletions
+158
-67
CloudConfigurationController.java
...l/uva/sne/drip/api/rest/CloudConfigurationController.java
+58
-2
PlannerController.java
...main/java/nl/uva/sne/drip/api/rest/PlannerController.java
+25
-12
ToscaController.java
...c/main/java/nl/uva/sne/drip/api/rest/ToscaController.java
+19
-41
UserController.java
...rc/main/java/nl/uva/sne/drip/api/rest/UserController.java
+11
-2
drip.properties
drip-api/src/main/resources/drip.properties
+1
-1
CloudCredentials.java
.../java/nl/uva/sne/drip/commons/types/CloudCredentials.java
+10
-8
ToscaRepresentation.java
...va/nl/uva/sne/drip/commons/types/ToscaRepresentation.java
+33
-0
RPCServer.java
...src/main/java/nl/uva/sne/drip/drip/planner/RPCServer.java
+1
-1
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/rest/CloudConfigurationController.java
View file @
e4ff23bc
...
@@ -15,8 +15,13 @@
...
@@ -15,8 +15,13 @@
*/
*/
package
nl
.
uva
.
sne
.
drip
.
api
.
rest
;
package
nl
.
uva
.
sne
.
drip
.
api
.
rest
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
javax.annotation.security.RolesAllowed
;
import
javax.annotation.security.RolesAllowed
;
import
nl.uva.sne.drip.commons.types.CloudCredentials
;
import
nl.uva.sne.drip.commons.types.CloudCredentials
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -26,9 +31,15 @@ import org.springframework.web.bind.annotation.RequestMethod;
...
@@ -26,9 +31,15 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
nl.uva.sne.drip.api.dao.CloudCredentialsDao
;
import
nl.uva.sne.drip.api.dao.CloudCredentialsDao
;
import
nl.uva.sne.drip.api.exception.BadRequestException
;
import
nl.uva.sne.drip.api.exception.NotFoundException
;
import
nl.uva.sne.drip.api.service.UserService
;
import
nl.uva.sne.drip.api.service.UserService
;
import
nl.uva.sne.drip.commons.types.LoginKey
;
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
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.multipart.MultipartFile
;
/**
/**
*
*
...
@@ -42,20 +53,65 @@ public class CloudConfigurationController {
...
@@ -42,20 +53,65 @@ public class CloudConfigurationController {
@Autowired
@Autowired
private
CloudCredentialsDao
cloudCredentialsDao
;
private
CloudCredentialsDao
cloudCredentialsDao
;
// curl -H "Content-Type: application/json" -X POST -d '{"key":"my_secret_password","keyIdAlias":"geni","logineKys":[{"attributes":null,"key":"-----BEGINRSAPUBLICKEY-----\nMIIBCgKCAQEA+xGZ/wcz9ugF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wD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl\nU9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ\n37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=\n-----ENDRSAPRIVATEKEY-----","type":"PRIVATE"}],"cloudProviderName":"exogeni"}' http://localhost:8080/drip-api/configuration
// curl -H "Content-Type: application/json" -X POST -d '{"key":"my_secret_password","keyIdAlias":"geni","logineK
e
ys":[{"attributes":null,"key":"-----BEGINRSAPUBLICKEY-----\nMIIBCgKCAQEA+xGZ/wcz9ugFpP07Nspo6U17l0YhFiFpxxU4pTk3Lifz9R3zsIsu\nERwta7+fWIfxOo208ett/jhskiVodSEt3QBGh4XBipyWopKwZ93HHaDVZAALi/2A\n+xTBtWdEo7XGUujKDvC2/aZKukfjpOiUI8AhLAfjmlcD/UZ1QPh0mHsglRNCmpCw\nmwSXA9VNmhz+PiB+Dml4WWnKW/VHo2ujTXxq7+efMU4H2fny3Se3KYOsFPFGZ1TN\nQSYlFuShWrHPtiLmUdPoP6CV2mML1tk+l7DIIqXrQhLUKDACeM5roMx0kLhUWB8P\n+0uj1CNlNN4JRZlC7xFfqiMbFRU9Z4N6YwIDAQAB\n-----ENDRSAPUBLICKEY-----","type":"PUBLIC"},{"attributes":null,"key":"-----BEGINRSAPRIVATEKEY-----\nMIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp\nwmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5\n1s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh\n3tx4VgMtrQ+WEgCjhoTwo23KMBAuJGSYnRmoBZM3lMfTKevIkAidPExvYCdm5dYq3XToLkkLv5L2\npIIVOFMDG+KESnAFV7l2c+cnzRMW0+b6f8mR1CJzZuxVLL6Q02fvLi55/mbSYxECQQDeAw6fiIQX\nGukBI4eMZZt4nscy2o12KyYner3VpoeE+Np2q+Z3pvAMd/aNzQ/W9WaI+NRfcxUJrmfPwIGm63il\nAkEAxCL5HQb2bQr4ByorcMWm/hEP2MZzROV73yF41hPsRC9m66KrheO9HPTJuo3/9s5p+sqGxOlF\nL0NDt4SkosjgGwJAFklyR1uZ/wPJjj611cdBcztlPdqoxssQGnh85BzCj/u3WqBpE2vjvyyvyI5k\nX6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl\nU9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ\n37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=\n-----ENDRSAPRIVATEKEY-----","type":"PRIVATE"}],"cloudProviderName":"exogeni"}' http://localhost:8080/drip-api/configuration
// curl -H "Content-Type: application/json" -X POST -d '{"key":"AKISAKISAKIS","keyIdAlias":"6J76J76J76J76J76J76J7","logineKys":[{"attributes":{"domain_name":"California"},"type":"PUBLIC","key":"-----BEGINRSAPRIVATEKEY-----\nMIIEpQIBAAKCAQEA3Tz2mr7SZiAMfQyuvBjM9Oi..Z1BjP5CE/Wm/Rr500P\nRK+Lh9x5eJPo5CAZ3/ANBE0sTK0ZsDGMak2m1g7..3VHqIxFTz0Ta1d+NAj\nwnLe4nOb7/eEJbDPkk05ShhBrJGBKKxb8n104o/..PdzbFMIyNjJzBM2o5y\n5A13wiLitEO7nco2WfyYkQzaxCw0AwzlkVHiIyC..71pSzkv6sv+4IDMbT/\nXpCo8L6wTarzrywnQsh+etLD6FtTjYbbrvZ8RQM..Hg2qxraAV++HNBYmNW\ns0duEdjUbJK+ZarypXI9TtnS4o1Ckj7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XJKy+gf3mF5Kmj\nDtkpjGHQzPF6vOe907y5NQLvVFGXUq/FIJZxB8k..fJdHEm2M4=\n-----ENDRSAPRIVATEKEY-----"},{"attributes":{"domain_name":"Virginia"},"type":"PUBLIC","key":"-----BEGINRSAPRIVATEKEY-----\nMIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp\nwmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5\n1s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh\n3tx4VgMtrQ+WEgCjhoTwo23KMBAuJGSYnRmoBZM3lMfTKevIkAidPExvYCdm5dYq3XToLkkLv5L2\npIIVOFMDG+KESnAFV7l2c+cnzRMW0+b6f8mR1CJzZuxVLL6Q02fvLi55/mbSYxECQQDeAw6fiIQX\nGukBI4eMZZt4nscy2o12KyYner3VpoeE+Np2q+Z3pvAMd/aNzQ/W9WaI+NRfcxUJrmfPwIGm63il\nAkEAxCL5HQb2bQr4ByorcMWm/hEP2MZzROV73yF41hPsRC9m66KrheO9HPTJuo3/9s5p+sqGxOlF\nL0NDt4SkosjgGwJAFklyR1uZ/wPJjj611cdBcztlPdqoxssQGnh85BzCj/u3WqBpE2vjvyyvyI5k\nX6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl\nU9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ\n37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=\n-----ENDRSAPRIVATEKEY-----"}],"cloudProviderName":"ec2"}'
// curl -H "Content-Type: application/json" -X POST -d '{"key":"AKISAKISAKIS","keyIdAlias":"6J76J76J76J76J76J76J7","logineKys":[{"attributes":{"domain_name":"California"},"type":"PUBLIC","key":"-----BEGINRSAPRIVATEKEY-----\nMIIEpQIBAAKCAQEA3Tz2mr7SZiAMfQyuvBjM9Oi..Z1BjP5CE/Wm/Rr500P\nRK+Lh9x5eJPo5CAZ3/ANBE0sTK0ZsDGMak2m1g7..3VHqIxFTz0Ta1d+NAj\nwnLe4nOb7/eEJbDPkk05ShhBrJGBKKxb8n104o/..PdzbFMIyNjJzBM2o5y\n5A13wiLitEO7nco2WfyYkQzaxCw0AwzlkVHiIyC..71pSzkv6sv+4IDMbT/\nXpCo8L6wTarzrywnQsh+etLD6FtTjYbbrvZ8RQM..Hg2qxraAV++HNBYmNW\ns0duEdjUbJK+ZarypXI9TtnS4o1Ckj7POfljiQI..IBAFyidxtqRQyv5KrD\nkbJ+q+rsJxQlaipn2M4lGuQJEfIxELFDyd3XpxP..Un/82NZNXlPmRIopXs\n2T91jiLZEUKQw+n73j26adTbteuEaPGSrTZxBLR..yssO0wWomUyILqVeti\n6AkL0NJAuKcucHGqWVgUIa4g1haE0ilcm6dWUDo..fd+PpzdCJf1s4NdUWK\nYV2GJcutGQb+jqT5DTUqAgST7N8M28rwjK6nVMI..BUpP0xpPnuYDyPOw6x\n4hBt8DZQYyduzIXBXRBKNiNdv8fum68/5klHxp6..4HRkMUL958UVeljUsT\nBFQlO9UCgYEA/VqzXVzlz8K36VSTMPEhB5zBATV..PRiXtYK1YpYV4/jSUj\nvvT4hP8uoYNC+BlEMi98LtnxZIh0V4rqHDsScAq..VyeSLH0loKMZgpwFEm\nbEIDnEOD0nKrfT/9K9sPYgvB43wsLEtUujaYw3W..Liy0WKmB8CgYEA34xn\n1QlOOhHBn9Z8qYjoDYhvcj+a89tD9eMPhesfQFw..rsfGcXIonFmWdVygbe\n6Doihc+GIYIq/QP4jgMksE1ADvczJSke92ZfE2i..fitBpQERNJO0BlabfP\nALs5NssKNmLkWS2U2BHCbv4DzDXwiQB37KPOL1c..kB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73yF41hPsRC9m66KrheO9HPTJuo3/9s5p+sqGxOlF\nL0NDt4SkosjgGwJAFklyR1uZ/wPJjj611cdBcztlPdqoxssQGnh85BzCj/u3WqBpE2vjvyyvyI5k\nX6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl\nU9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ\n37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=\n-----ENDRSAPRIVATEKEY-----"}],"cloudProviderName":"ec2"}'
@RequestMapping
(
method
=
RequestMethod
.
POST
)
@RequestMapping
(
method
=
RequestMethod
.
POST
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
String
postConf
(
@RequestBody
CloudCredentials
cc
)
{
String
postConf
(
@RequestBody
CloudCredentials
cc
)
{
if
(
cc
.
getKey
()
==
null
)
{
throw
new
BadRequestException
(
"key can't be null"
);
}
if
(
cc
.
getKeyIdAlias
()
==
null
)
{
throw
new
BadRequestException
(
"keyIdAlias can't be null"
);
}
cloudCredentialsDao
.
save
(
cc
);
cloudCredentialsDao
.
save
(
cc
);
return
cc
.
getId
();
return
cc
.
getId
();
}
}
@RequestMapping
(
value
=
"/upload/{id}"
,
method
=
RequestMethod
.
POST
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
String
addLogineKey
(
@RequestParam
(
"file"
)
MultipartFile
file
,
@PathVariable
(
"id"
)
String
id
)
{
try
{
CloudCredentials
cc
=
cloudCredentialsDao
.
findOne
(
id
);
if
(
cc
==
null
)
{
throw
new
NotFoundException
();
}
if
(
file
.
isEmpty
())
{
throw
new
BadRequestException
(
"Must uplaod a file"
);
}
String
originalFileName
=
file
.
getOriginalFilename
();
byte
[]
bytes
=
file
.
getBytes
();
List
<
LoginKey
>
logInKeys
=
cc
.
getLoginKeys
();
if
(
logInKeys
==
null
)
{
logInKeys
=
new
ArrayList
<>();
}
LoginKey
key
=
new
LoginKey
();
key
.
setKey
(
new
String
(
bytes
,
"UTF-8"
));
if
(
cc
.
getCloudProviderName
().
toLowerCase
().
equals
(
"ec2"
))
{
Map
<
String
,
String
>
attributes
=
new
HashMap
<>();
attributes
.
put
(
"domain_name"
,
FilenameUtils
.
removeExtension
(
originalFileName
));
key
.
setAttributes
(
attributes
);
}
logInKeys
.
add
(
key
);
cc
.
setLogineKeys
(
logInKeys
);
cloudCredentialsDao
.
save
(
cc
);
return
cloudCredentialsDao
.
findOne
(
id
).
getId
();
}
catch
(
IOException
ex
)
{
Logger
.
getLogger
(
CloudConfigurationController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
return
null
;
}
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
CloudCredentials
get
(
@PathVariable
(
"id"
)
String
id
)
{
public
CloudCredentials
get
(
@PathVariable
(
"id"
)
String
id
)
{
return
cloudCredentialsDao
.
findOne
(
id
);
CloudCredentials
cc
=
cloudCredentialsDao
.
findOne
(
id
);
if
(
cc
==
null
)
{
throw
new
NotFoundException
();
}
return
cc
;
}
}
@RequestMapping
(
value
=
"/ids"
)
@RequestMapping
(
value
=
"/ids"
)
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/rest/PlannerController.java
View file @
e4ff23bc
...
@@ -49,7 +49,6 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -49,7 +49,6 @@ import org.springframework.web.bind.annotation.RestController;
import
nl.uva.sne.drip.api.dao.ToscaDao
;
import
nl.uva.sne.drip.api.dao.ToscaDao
;
import
nl.uva.sne.drip.api.rpc.DRIPCaller
;
import
nl.uva.sne.drip.api.rpc.DRIPCaller
;
import
nl.uva.sne.drip.api.rpc.ProvisionerCaller
;
import
nl.uva.sne.drip.api.rpc.ProvisionerCaller
;
import
nl.uva.sne.drip.api.service.PlannerService
;
import
nl.uva.sne.drip.api.service.UserService
;
import
nl.uva.sne.drip.api.service.UserService
;
import
nl.uva.sne.drip.commons.types.CloudCredentials
;
import
nl.uva.sne.drip.commons.types.CloudCredentials
;
import
nl.uva.sne.drip.commons.types.LoginKey
;
import
nl.uva.sne.drip.commons.types.LoginKey
;
...
@@ -67,7 +66,7 @@ public class PlannerController {
...
@@ -67,7 +66,7 @@ public class PlannerController {
@Value
(
"${message.broker.host}"
)
@Value
(
"${message.broker.host}"
)
private
String
messageBrokerHost
;
private
String
messageBrokerHost
;
@Autowired
@Autowired
private
ToscaDao
d
ao
;
private
ToscaDao
toscaD
ao
;
@Autowired
@Autowired
private
CloudCredentialsDao
cloudCredentialsDao
;
private
CloudCredentialsDao
cloudCredentialsDao
;
...
@@ -78,7 +77,7 @@ public class PlannerController {
...
@@ -78,7 +77,7 @@ public class PlannerController {
public
@ResponseBody
public
@ResponseBody
String
plann
(
@PathVariable
(
"tosca_id"
)
String
toscaId
)
{
String
plann
(
@PathVariable
(
"tosca_id"
)
String
toscaId
)
{
DRIPCaller
planner
=
null
;
DRIPCaller
planner
=
null
;
DRIPCaller
provisioner
=
null
;
//
DRIPCaller provisioner = null;
List
<
DRIPCaller
>
dripComponetens
=
new
ArrayList
<>();
List
<
DRIPCaller
>
dripComponetens
=
new
ArrayList
<>();
try
{
try
{
...
@@ -87,13 +86,27 @@ public class PlannerController {
...
@@ -87,13 +86,27 @@ public class PlannerController {
planner
=
new
PlannerCaller
(
messageBrokerHost
);
planner
=
new
PlannerCaller
(
messageBrokerHost
);
dripComponetens
.
add
(
planner
);
dripComponetens
.
add
(
planner
);
Message
plannerReturnedMessage
=
planner
.
call
(
plannerInvokationMessage
);
Message
plannerReturnedMessage
=
planner
.
call
(
plannerInvokationMessage
);
List
<
Parameter
>
toscaFiles
=
plannerReturnedMessage
.
getParameters
();
Message
provisionerInvokationMessage
=
buildProvisionerMessage
(
plannerReturnedMessage
,
"58a7281c55363e65b3c9eb82"
);
ToscaRepresentation
tr
=
new
ToscaRepresentation
();
provisioner
=
new
ProvisionerCaller
(
messageBrokerHost
);
StringBuilder
name
=
new
StringBuilder
();
dripComponetens
.
add
(
provisioner
);
StringBuilder
value
=
new
StringBuilder
();
provisioner
.
call
(
provisionerInvokationMessage
);
String
prefix
=
""
;
for
(
Parameter
p
:
toscaFiles
)
{
return
""
;
Map
<
String
,
String
>
attributess
=
p
.
getAttributes
();
String
level
=
attributess
.
get
(
"level"
);
name
.
append
(
prefix
);
name
.
append
(
p
.
getName
());
value
.
append
(
p
.
getValue
());
value
.
append
(
"\n"
);
}
tr
.
setName
(
name
.
toString
());
tr
.
setKvMap
(
Converter
.
ymlString2Map
(
toscaId
));
toscaDao
.
save
(
tr
);
// Message provisionerInvokationMessage = buildProvisionerMessage(plannerReturnedMessage, "58a7281c55363e65b3c9eb82");
// provisioner = new ProvisionerCaller(messageBrokerHost);
// dripComponetens.add(provisioner);
// provisioner.call(provisionerInvokationMessage);
return
tr
.
getId
();
}
catch
(
JSONException
|
IOException
|
TimeoutException
|
InterruptedException
ex
)
{
}
catch
(
JSONException
|
IOException
|
TimeoutException
|
InterruptedException
ex
)
{
Logger
.
getLogger
(
PlannerController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
Logger
.
getLogger
(
PlannerController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
finally
{
}
finally
{
...
@@ -112,7 +125,7 @@ public class PlannerController {
...
@@ -112,7 +125,7 @@ public class PlannerController {
}
}
private
Message
buildPlannerMessage
(
String
toscaId
)
throws
JSONException
,
UnsupportedEncodingException
,
IOException
{
private
Message
buildPlannerMessage
(
String
toscaId
)
throws
JSONException
,
UnsupportedEncodingException
,
IOException
{
ToscaRepresentation
t2
=
d
ao
.
findOne
(
toscaId
);
ToscaRepresentation
t2
=
toscaD
ao
.
findOne
(
toscaId
);
Map
<
String
,
Object
>
map
=
t2
.
getKvMap
();
Map
<
String
,
Object
>
map
=
t2
.
getKvMap
();
String
ymlStr
=
Converter
.
map2YmlString
(
map
);
String
ymlStr
=
Converter
.
map2YmlString
(
map
);
ymlStr
=
ymlStr
.
replaceAll
(
"\\uff0E"
,
"\\."
);
ymlStr
=
ymlStr
.
replaceAll
(
"\\uff0E"
,
"\\."
);
...
@@ -171,7 +184,7 @@ public class PlannerController {
...
@@ -171,7 +184,7 @@ public class PlannerController {
}
}
private
List
<
Parameter
>
buildCertificatesParam
(
CloudCredentials
cred
)
{
private
List
<
Parameter
>
buildCertificatesParam
(
CloudCredentials
cred
)
{
List
<
LoginKey
>
loginKeys
=
cred
.
getLogin
eK
ys
();
List
<
LoginKey
>
loginKeys
=
cred
.
getLogin
Ke
ys
();
List
<
Parameter
>
parameters
=
new
ArrayList
<>();
List
<
Parameter
>
parameters
=
new
ArrayList
<>();
for
(
LoginKey
lk
:
loginKeys
)
{
for
(
LoginKey
lk
:
loginKeys
)
{
String
domainName
=
lk
.
getAttributes
().
get
(
"domain_name"
);
String
domainName
=
lk
.
getAttributes
().
get
(
"domain_name"
);
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/rest/ToscaController.java
View file @
e4ff23bc
...
@@ -16,12 +16,10 @@
...
@@ -16,12 +16,10 @@
package
nl
.
uva
.
sne
.
drip
.
api
.
rest
;
package
nl
.
uva
.
sne
.
drip
.
api
.
rest
;
import
nl.uva.sne.drip.commons.types.ToscaRepresentation
;
import
nl.uva.sne.drip.commons.types.ToscaRepresentation
;
import
nl.uva.sne.drip.api.rpc.PlannerCaller
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.TimeoutException
;
import
java.util.logging.Level
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
java.util.logging.Logger
;
import
javax.annotation.security.RolesAllowed
;
import
javax.annotation.security.RolesAllowed
;
...
@@ -37,6 +35,7 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -37,6 +35,7 @@ import org.springframework.web.bind.annotation.RestController;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
nl.uva.sne.drip.api.dao.ToscaDao
;
import
nl.uva.sne.drip.api.dao.ToscaDao
;
import
nl.uva.sne.drip.api.exception.BadRequestException
;
import
nl.uva.sne.drip.api.service.UserService
;
import
nl.uva.sne.drip.api.service.UserService
;
/**
/**
...
@@ -48,8 +47,6 @@ import nl.uva.sne.drip.api.service.UserService;
...
@@ -48,8 +47,6 @@ import nl.uva.sne.drip.api.service.UserService;
@Component
@Component
public
class
ToscaController
{
public
class
ToscaController
{
// @Value("${message.broker.host}")
// private String messageBrokerHost;
@Autowired
@Autowired
private
ToscaDao
dao
;
private
ToscaDao
dao
;
...
@@ -58,10 +55,10 @@ public class ToscaController {
...
@@ -58,10 +55,10 @@ public class ToscaController {
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
String
toscaUpload
(
@RequestParam
(
"file"
)
MultipartFile
file
)
{
String
toscaUpload
(
@RequestParam
(
"file"
)
MultipartFile
file
)
{
PlannerCaller
planner
=
null
;
if
(
file
.
isEmpty
())
{
if
(!
file
.
isEmpty
())
{
throw
new
BadRequestException
(
"Must uplaod a file"
);
}
try
{
try
{
String
originalFileName
=
file
.
getOriginalFilename
();
String
originalFileName
=
file
.
getOriginalFilename
();
String
name
=
System
.
currentTimeMillis
()
+
"_"
+
originalFileName
;
String
name
=
System
.
currentTimeMillis
()
+
"_"
+
originalFileName
;
byte
[]
bytes
=
file
.
getBytes
();
byte
[]
bytes
=
file
.
getBytes
();
...
@@ -73,20 +70,11 @@ public class ToscaController {
...
@@ -73,20 +70,11 @@ public class ToscaController {
t
.
setName
(
name
);
t
.
setName
(
name
);
t
.
setKvMap
(
map
);
t
.
setKvMap
(
map
);
dao
.
save
(
t
);
dao
.
save
(
t
);
return
t
.
getId
();
return
t
.
getId
();
}
catch
(
IOException
|
IllegalStateException
ex
)
{
}
catch
(
IOException
|
IllegalStateException
ex
)
{
Logger
.
getLogger
(
ToscaController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
Logger
.
getLogger
(
ToscaController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
finally
{
if
(
planner
!=
null
)
{
try
{
planner
.
close
();
}
catch
(
IOException
|
TimeoutException
ex
)
{
Logger
.
getLogger
(
ToscaController
.
class
.
getName
()).
log
(
Level
.
WARNING
,
null
,
ex
);
}
}
}
}
}
return
null
;
return
null
;
}
}
...
@@ -116,16 +104,6 @@ public class ToscaController {
...
@@ -116,16 +104,6 @@ public class ToscaController {
return
null
;
return
null
;
}
}
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
ToscaRepresentation
getToscaRepresentation
(
@PathVariable
(
"id"
)
String
id
)
{
ToscaRepresentation
tosca
=
dao
.
findOne
(
id
);
return
tosca
;
}
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
DELETE
)
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
DELETE
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/rest/UserController.java
View file @
e4ff23bc
...
@@ -47,6 +47,16 @@ public class UserController {
...
@@ -47,6 +47,16 @@ public class UserController {
@Autowired
@Autowired
private
UserService
service
;
private
UserService
service
;
/**
* Register new user. A normal user cannot create accounts, only the user
* with the 'ADMIN' role can do that.
*
* @param user
* @return Response on success: The ID of the newly register user. Response
* on fail: If the user name already exists, or the user name is 'null' or
* the password is 'null' there will be a 'BadRequestException'
*
*/
@RequestMapping
(
value
=
"/register"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/register"
,
method
=
RequestMethod
.
POST
)
@RolesAllowed
({
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
...
@@ -74,8 +84,7 @@ public class UserController {
...
@@ -74,8 +84,7 @@ public class UserController {
if
(
registeredUser
==
null
)
{
if
(
registeredUser
==
null
)
{
throw
new
NotFoundException
(
"User "
+
user
.
getUsername
()
+
" not found"
);
throw
new
NotFoundException
(
"User "
+
user
.
getUsername
()
+
" not found"
);
}
}
service
.
getDao
().
save
(
user
);
return
this
.
register
(
user
);
return
user
.
getId
();
}
}
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
...
...
drip-api/src/main/resources/drip.properties
View file @
e4ff23bc
message.broker.host
=
172.17.0.
2
message.broker.host
=
172.17.0.
3
db.name
=
drip
db.name
=
drip
db.username
=
drip-user
db.username
=
drip-user
db.password
=
drip-pass
db.password
=
drip-pass
drip-commons/src/main/java/nl/uva/sne/drip/commons/types/CloudCredentials.java
View file @
e4ff23bc
...
@@ -31,9 +31,11 @@ public class CloudCredentials {
...
@@ -31,9 +31,11 @@ public class CloudCredentials {
private
String
key
;
private
String
key
;
private
String
keyIdAlias
;
private
String
keyIdAlias
;
private
List
<
LoginKey
>
logineKys
;
private
List
<
LoginKey
>
loginKeys
;
private
String
cloudProviderName
;
private
String
cloudProviderName
;
...
@@ -74,17 +76,17 @@ public class CloudCredentials {
...
@@ -74,17 +76,17 @@ public class CloudCredentials {
}
}
/**
/**
* @return the login
eK
ys
* @return the login
Ke
ys
*/
*/
public
List
<
LoginKey
>
getLogin
eK
ys
()
{
public
List
<
LoginKey
>
getLogin
Ke
ys
()
{
return
login
eK
ys
;
return
login
Ke
ys
;
}
}
/**
/**
* @param login
eKys the logineK
ys to set
* @param login
Keys the loginKe
ys to set
*/
*/
public
void
setLogineK
ys
(
List
<
LoginKey
>
logineK
ys
)
{
public
void
setLogineK
eys
(
List
<
LoginKey
>
loginKe
ys
)
{
this
.
login
eKys
=
logineK
ys
;
this
.
login
Keys
=
loginKe
ys
;
}
}
/**
/**
...
...
drip-commons/src/main/java/nl/uva/sne/drip/commons/types/ToscaRepresentation.java
View file @
e4ff23bc
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
*/
*/
package
nl
.
uva
.
sne
.
drip
.
commons
.
types
;
package
nl
.
uva
.
sne
.
drip
.
commons
.
types
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
org.springframework.data.mongodb.core.mapping.Document
;
...
@@ -29,10 +30,14 @@ public class ToscaRepresentation {
...
@@ -29,10 +30,14 @@ public class ToscaRepresentation {
@Id
@Id
private
String
id
;
private
String
id
;
private
List
<
String
>
lowerLevelIDs
;
private
String
name
;
private
String
name
;
private
Map
<
String
,
Object
>
kvMap
;
private
Map
<
String
,
Object
>
kvMap
;
private
Integer
level
;
public
final
String
getId
()
{
public
final
String
getId
()
{
return
id
;
return
id
;
}
}
...
@@ -69,4 +74,32 @@ public class ToscaRepresentation {
...
@@ -69,4 +74,32 @@ public class ToscaRepresentation {
this
.
name
=
name
;
this
.
name
=
name
;
}
}
/**
* @return the level
*/
public
Integer
getLevel
()
{
return
level
;
}
/**
* @param level the level to set
*/
public
void
setLevel
(
Integer
level
)
{
this
.
level
=
level
;
}
/**
* @return the lowerLevelIDs
*/
public
List
<
String
>
getLowerLevelIDs
()
{
return
lowerLevelIDs
;
}
/**
* @param lowerLevelIDs the lowerLevelIDs to set
*/
public
void
setLowerLevelIDs
(
List
<
String
>
lowerLevelIDs
)
{
this
.
lowerLevelIDs
=
lowerLevelIDs
;
}
}
}
drip-simple_planner/src/main/java/nl/uva/sne/drip/drip/planner/RPCServer.java
View file @
e4ff23bc
...
@@ -31,7 +31,7 @@ import java.util.logging.Logger;
...
@@ -31,7 +31,7 @@ import java.util.logging.Logger;
public
class
RPCServer
{
public
class
RPCServer
{
private
static
final
String
RPC_QUEUE_NAME
=
"planner_queue"
;
private
static
final
String
RPC_QUEUE_NAME
=
"planner_queue"
;
private
static
final
String
HOST
=
"172.17.0.
2
"
;
private
static
final
String
HOST
=
"172.17.0.
3
"
;
public
static
void
main
(
String
[]
argv
)
{
public
static
void
main
(
String
[]
argv
)
{
start
();
start
();
...
...
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