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
f2c80f09
Commit
f2c80f09
authored
Mar 07, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added javadoc
parent
aae36e4a
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
1099 additions
and
47 deletions
+1099
-47
MOG.yaml
doc/composer_files/MOG.yaml
+0
-0
tosca_output_app_52.yaml
doc/input_tosca_files/tosca_output_app_52.yaml
+833
-0
pom.xml
drip-api/pom.xml
+19
-1
CloudConfigurationController.java
...l/uva/sne/drip/api/rest/CloudConfigurationController.java
+41
-8
DeployController.java
.../main/java/nl/uva/sne/drip/api/rest/DeployController.java
+22
-1
PlannerController.java
...main/java/nl/uva/sne/drip/api/rest/PlannerController.java
+32
-2
ProvisionController.java
...in/java/nl/uva/sne/drip/api/rest/ProvisionController.java
+23
-1
ToscaController.java
...c/main/java/nl/uva/sne/drip/api/rest/ToscaController.java
+24
-4
UserController.java
...rc/main/java/nl/uva/sne/drip/api/rest/UserController.java
+20
-4
UserPublicKeysController.java
...va/nl/uva/sne/drip/api/rest/UserPublicKeysController.java
+44
-11
UserScriptController.java
...n/java/nl/uva/sne/drip/api/rest/UserScriptController.java
+33
-11
UserScript.java
...c/main/java/nl/uva/sne/drip/commons/types/UserScript.java
+1
-1
Consumer.java
.../main/java/nl/uva/sne/drip/drip/provisioner/Consumer.java
+7
-3
No files found.
doc/MOG.yaml
→
doc/
composer_files/
MOG.yaml
View file @
f2c80f09
File moved
doc/input_tosca_files/tosca_output_app_52.yaml
0 → 100644
View file @
f2c80f09
This diff is collapsed.
Click to expand it.
drip-api/pom.xml
View file @
f2c80f09
...
@@ -100,7 +100,7 @@
...
@@ -100,7 +100,7 @@
<scope>
test
</scope>
<scope>
test
</scope>
<type>
jar
</type>
<type>
jar
</type>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
javax
</groupId>
<groupId>
javax
</groupId>
<artifactId>
javaee-web-api
</artifactId>
<artifactId>
javaee-web-api
</artifactId>
...
@@ -175,6 +175,24 @@
...
@@ -175,6 +175,24 @@
</execution>
</execution>
</executions>
</executions>
</plugin>
</plugin>
<plugin>
<groupId>
com.webcohesion.enunciate
</groupId>
<artifactId>
enunciate-maven-plugin
</artifactId>
<version>
2.8.0
</version>
<executions>
<execution>
<goals>
<goal>
docs
</goal>
</goals>
<configuration>
<!-- the directory where to put the docs -->
<docsDir>
${project.build.directory}/docs
</docsDir>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</plugins>
</build>
</build>
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/rest/CloudConfigurationController.java
View file @
f2c80f09
...
@@ -45,6 +45,10 @@ import org.springframework.web.multipart.MultipartFile;
...
@@ -45,6 +45,10 @@ import org.springframework.web.multipart.MultipartFile;
/**
/**
*
*
* This controller is responsible for handling CloudCredentials.
* CloudCredentials are a represntation of the credentials that are used by the
* provisoner to request for resources (VMs)
*
* @author S. Koulouzis
* @author S. Koulouzis
*/
*/
@RestController
@RestController
...
@@ -55,22 +59,34 @@ public class CloudConfigurationController {
...
@@ -55,22 +59,34 @@ 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","logineKeys":[{"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+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..kBHfF2/htIs20d1UVL\n+PK+aXKwguI6bxLGZ3of0UH+mGsSl0mkp7kYZCm..OTQtfeRqP8rDSC7DgA\nkHc5ajYqh04AzNFaxjRo+M3IGICUaOdKnXd0Fda..QwfoaX4QlRTgLqb7AN\nZTzM9WbmnYoXrx17kZlT3lsCgYEAm757XI3WJVj..WoLj1+v48WyoxZpcai\nuv9bT4Cj+lXRS+gdKHK+SH7J3x2CRHVS+WH/SVC..DxuybvebDoT0TkKiCj\nBWQaGzCaJqZa+POHK0klvS+9ln0/6k539p95tfX..X4TCzbVG6+gJiX0ysz\nYfehn5MCgYEAkMiKuWHCsVyCab3RUf6XA9gd3qY..fCTIGtS1tR5PgFIV+G\nengiVoWc/hkj8SBHZz1n1xLN7KDf8ySU06MDggB..hJ+gXJKy+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"}'
* Post the cloud credentials.
*
* @param cloudCredentials
* @return the CloudCredentials id
*/
@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
c
c
)
{
String
postConf
(
@RequestBody
CloudCredentials
c
loudCredentials
)
{
if
(
c
c
.
getKey
()
==
null
)
{
if
(
c
loudCredentials
.
getKey
()
==
null
)
{
throw
new
NullKeyException
();
throw
new
NullKeyException
();
}
}
if
(
c
c
.
getKeyIdAlias
()
==
null
)
{
if
(
c
loudCredentials
.
getKeyIdAlias
()
==
null
)
{
throw
new
NullKeyIDException
();
throw
new
NullKeyIDException
();
}
}
cloudCredentialsDao
.
save
(
c
c
);
cloudCredentialsDao
.
save
(
c
loudCredentials
);
return
c
c
.
getId
();
return
c
loudCredentials
.
getId
();
}
}
/**
* Upload the login keys for a cloud provider. The cloud credentials have to
* be created
*
* @param file
* @param id
* @return the CloudCredentials id
*/
@RequestMapping
(
value
=
"/upload/{id}"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/upload/{id}"
,
method
=
RequestMethod
.
POST
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
...
@@ -106,6 +122,12 @@ public class CloudConfigurationController {
...
@@ -106,6 +122,12 @@ public class CloudConfigurationController {
return
null
;
return
null
;
}
}
/**
* Get the cloud credentials
*
* @param id the id of the cloud credentials
* @return the cloud credentials
*/
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
...
@@ -117,6 +139,12 @@ public class CloudConfigurationController {
...
@@ -117,6 +139,12 @@ public class CloudConfigurationController {
return
cc
;
return
cc
;
}
}
/**
* Delete the cloud credentials
*
* @param id the id of the cloud credentials
* @return the id of the cloud credentials
*/
@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
...
@@ -125,7 +153,12 @@ public class CloudConfigurationController {
...
@@ -125,7 +153,12 @@ public class CloudConfigurationController {
return
"Deleted :"
+
id
;
return
"Deleted :"
+
id
;
}
}
@RequestMapping
(
value
=
"/ids"
)
/**
* Gets all the IDs of the stored cloud credentials
*
* @return a list of stored IDs
*/
@RequestMapping
(
value
=
"/ids"
,
method
=
RequestMethod
.
GET
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
List
<
String
>
getIds
()
{
List
<
String
>
getIds
()
{
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/rest/DeployController.java
View file @
f2c80f09
...
@@ -53,7 +53,8 @@ import org.springframework.web.bind.annotation.PathVariable;
...
@@ -53,7 +53,8 @@ import org.springframework.web.bind.annotation.PathVariable;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
/**
/**
*
* This controller is responsible for deploying a cluster on provisoned resources.
*
* @author S. Koulouzis
* @author S. Koulouzis
*/
*/
@RestController
@RestController
...
@@ -73,6 +74,12 @@ public class DeployController {
...
@@ -73,6 +74,12 @@ public class DeployController {
@Autowired
@Autowired
private
ClusterCredentialService
clusterCredentialService
;
private
ClusterCredentialService
clusterCredentialService
;
/**
* Deploys a cluster on a provisioned resources.
* @param provisionID
* @param clusterType
* @return the id of the cluster credentials
*/
@RequestMapping
(
value
=
"/deploy/{id}/"
,
method
=
RequestMethod
.
GET
,
params
=
{
"cluster"
})
@RequestMapping
(
value
=
"/deploy/{id}/"
,
method
=
RequestMethod
.
GET
,
params
=
{
"cluster"
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
...
@@ -101,6 +108,11 @@ public class DeployController {
...
@@ -101,6 +108,11 @@ public class DeployController {
return
null
;
return
null
;
}
}
/**
* Gets the cluster credentials.
* @param id
* @return the cluster credentials
*/
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
...
@@ -112,6 +124,10 @@ public class DeployController {
...
@@ -112,6 +124,10 @@ public class DeployController {
return
clusterC
;
return
clusterC
;
}
}
/**
* Gets the IDs of all the stored cluster credentials
* @return a list of all the IDs
*/
@RequestMapping
(
value
=
"/ids"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/ids"
,
method
=
RequestMethod
.
GET
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
...
@@ -124,6 +140,11 @@ public class DeployController {
...
@@ -124,6 +140,11 @@ public class DeployController {
return
ids
;
return
ids
;
}
}
/**
* Deletes a cluster credential
* @param id. The id of the cluster credential
* @return the id f the deleted cluster credential
*/
@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/PlannerController.java
View file @
f2c80f09
...
@@ -37,7 +37,9 @@ import nl.uva.sne.drip.commons.types.Plan;
...
@@ -37,7 +37,9 @@ import nl.uva.sne.drip.commons.types.Plan;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
/**
/**
*
* This controller is responsible for planing the type of resources to be provisopned
* based on a TOSCA description.
*
* @author S. Koulouzis
* @author S. Koulouzis
*/
*/
@RestController
@RestController
...
@@ -50,6 +52,12 @@ public class PlannerController {
...
@@ -50,6 +52,12 @@ public class PlannerController {
@Autowired
@Autowired
private
PlannerService
plannerService
;
private
PlannerService
plannerService
;
/**
* Plans resources (number, size of VMs etc).
* @param toscaId. The id of the TOSCA description
* @return the id of the created plan
*/
@RequestMapping
(
value
=
"/plan/{tosca_id}"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/plan/{tosca_id}"
,
method
=
RequestMethod
.
GET
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
...
@@ -68,6 +76,12 @@ public class PlannerController {
...
@@ -68,6 +76,12 @@ public class PlannerController {
return
null
;
return
null
;
}
}
/**
* Gets a plan
* @param id. The id iof the plan
* @param format. The format (yml,json)
* @return the plan
*/
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
,
params
=
{
"format"
})
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
,
params
=
{
"format"
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
...
@@ -80,6 +94,12 @@ public class PlannerController {
...
@@ -80,6 +94,12 @@ public class PlannerController {
return
null
;
return
null
;
}
}
/**
* Gets the ID of the TOSCA description that was used to generate the plan.
* The plan is represented by its ID
* @param id. The plan id
* @return the TOSCA description ID
*/
@RequestMapping
(
value
=
"/tosca/{id}"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/tosca/{id}"
,
method
=
RequestMethod
.
GET
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
...
@@ -87,6 +107,11 @@ public class PlannerController {
...
@@ -87,6 +107,11 @@ public class PlannerController {
return
plannerService
.
getToscaID
(
id
);
return
plannerService
.
getToscaID
(
id
);
}
}
/**
* Deletes the plan.
* @param id . The ID of the plan
* @return The ID of the deleted plan
*/
@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
...
@@ -95,7 +120,12 @@ public class PlannerController {
...
@@ -95,7 +120,12 @@ public class PlannerController {
return
"Deleted : "
+
id
;
return
"Deleted : "
+
id
;
}
}
@RequestMapping
(
value
=
"/ids"
)
/**
* Gets the IDs of all the stored plans
* @return a list of IDs
*/
@RequestMapping
(
value
=
"/ids"
,
method
=
RequestMethod
.
GET
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
List
<
String
>
getIds
()
{
List
<
String
>
getIds
()
{
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/rest/ProvisionController.java
View file @
f2c80f09
...
@@ -67,7 +67,8 @@ import org.springframework.web.bind.annotation.PathVariable;
...
@@ -67,7 +67,8 @@ import org.springframework.web.bind.annotation.PathVariable;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
/**
/**
*
* This controller is responsible for obtaining resources from cloud providers
* based the plan generated by the planner
* @author S. Koulouzis
* @author S. Koulouzis
*/
*/
@RestController
@RestController
...
@@ -93,6 +94,11 @@ public class ProvisionController {
...
@@ -93,6 +94,11 @@ public class ProvisionController {
@Autowired
@Autowired
private
SimplePlannerService
planService
;
private
SimplePlannerService
planService
;
/**
* Gets the ProvisionInfo
* @param id. The id of the ProvisionInfo
* @return the requested ProvisionInfo
*/
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
...
@@ -100,6 +106,11 @@ public class ProvisionController {
...
@@ -100,6 +106,11 @@ public class ProvisionController {
return
provisionService
.
getDao
().
findOne
(
id
);
return
provisionService
.
getDao
().
findOne
(
id
);
}
}
/**
* Deletes the ProvisionInfo
* @param id. The ID of the ProvisionInfo to be deleted
* @return the ID of the deleted ProvisionInfo
*/
@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
...
@@ -112,6 +123,11 @@ public class ProvisionController {
...
@@ -112,6 +123,11 @@ public class ProvisionController {
throw
new
NotFoundException
();
throw
new
NotFoundException
();
}
}
/**
* Gets the IDs of all the stored ProvisionInfo
* @return a list of IDs
*/
@RequestMapping
(
value
=
"/ids"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/ids"
,
method
=
RequestMethod
.
GET
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
...
@@ -124,6 +140,12 @@ public class ProvisionController {
...
@@ -124,6 +140,12 @@ public class ProvisionController {
return
ids
;
return
ids
;
}
}
/**
* Provison the resources specified by a plan.
* @param req. The ProvisionInfo. This is a container the plan ID,
* cloud credent ID, etc.
* @return The ID of the provisioned ProvisionInfo
*/
@RequestMapping
(
value
=
"/provision"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/provision"
,
method
=
RequestMethod
.
POST
)
@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/ToscaController.java
View file @
f2c80f09
...
@@ -37,7 +37,8 @@ import nl.uva.sne.drip.api.service.ToscaService;
...
@@ -37,7 +37,8 @@ import nl.uva.sne.drip.api.service.ToscaService;
import
nl.uva.sne.drip.api.service.UserService
;
import
nl.uva.sne.drip.api.service.UserService
;
/**
/**
*
* This controller is responsible for storing TOSCA descriptions that can be used
* by the planner.
* @author S. Koulouzis
* @author S. Koulouzis
*/
*/
@RestController
@RestController
...
@@ -48,7 +49,11 @@ public class ToscaController {
...
@@ -48,7 +49,11 @@ public class ToscaController {
@Autowired
@Autowired
private
ToscaService
toscaService
;
private
ToscaService
toscaService
;
// curl -X POST -F "file=@DRIP/input.yaml" localhost:8080/drip-api/upload
/**
* Uploads and stores a TOSCA description file
* @param file. The TOSCA description file
* @return the ID of the TOSCA description
*/
@RequestMapping
(
value
=
"/upload"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/upload"
,
method
=
RequestMethod
.
POST
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
...
@@ -64,7 +69,13 @@ public class ToscaController {
...
@@ -64,7 +69,13 @@ public class ToscaController {
return
null
;
return
null
;
}
}
// curl http://localhost:8080/drip-api/tosca/589e1160d9925f9dc127e882/?fromat=yaml
/**
* Gets the TOSCA description.
* @param id the ID TOSCA description.
* @param format. the format to display the TOSCA description.
* @return the TOSCA description.
*/
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
,
params
=
{
"format"
})
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
,
params
=
{
"format"
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
...
@@ -77,6 +88,11 @@ public class ToscaController {
...
@@ -77,6 +88,11 @@ public class ToscaController {
return
null
;
return
null
;
}
}
/**
* Deletes the TOSCA description.
* @param id. The ID of TOSCA description to delete.
* @return The ID of the deleted TOSCA description.
*/
@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
...
@@ -85,7 +101,11 @@ public class ToscaController {
...
@@ -85,7 +101,11 @@ public class ToscaController {
return
"Deleted : "
+
id
;
return
"Deleted : "
+
id
;
}
}
// http://localhost:8080/drip-api/tosca/ids
/**
* Gets the IDs of all the stored TOSCA descriptionss.
* @return a list of all the IDs
*/
@RequestMapping
(
value
=
"/ids"
)
@RequestMapping
(
value
=
"/ids"
)
@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 @
f2c80f09
...
@@ -20,8 +20,6 @@ import java.util.List;
...
@@ -20,8 +20,6 @@ import java.util.List;
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
;
import
nl.uva.sne.drip.api.exception.BadRequestException
;
import
nl.uva.sne.drip.api.exception.NotFoundException
;
import
nl.uva.sne.drip.api.exception.PasswordNullException
;
import
nl.uva.sne.drip.api.exception.PasswordNullException
;
import
nl.uva.sne.drip.api.exception.UserExistsException
;
import
nl.uva.sne.drip.api.exception.UserExistsException
;
import
nl.uva.sne.drip.api.exception.UserNotFoundException
;
import
nl.uva.sne.drip.api.exception.UserNotFoundException
;
...
@@ -40,6 +38,7 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
...
@@ -40,6 +38,7 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
/**
/**
* This controller is responsible for handling user accounts
*
*
* @author S. Koulouzis
* @author S. Koulouzis
*/
*/
...
@@ -55,7 +54,7 @@ public class UserController {
...
@@ -55,7 +54,7 @@ public class UserController {
* Register new user. A normal user cannot create accounts, only the user
* Register new user. A normal user cannot create accounts, only the user
* with the 'ADMIN' role can do that.
* with the 'ADMIN' role can do that.
*
*
* @param user
* @param user
. The user to register
* @return Response on success: The ID of the newly register user. Response
* @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
* on fail: If the user name already exists, or the user name is 'null' or
* the password is 'null' there will be a 'BadRequestException'
* the password is 'null' there will be a 'BadRequestException'
...
@@ -91,6 +90,12 @@ public class UserController {
...
@@ -91,6 +90,12 @@ public class UserController {
return
this
.
register
(
user
);
return
this
.
register
(
user
);
}
}
/**
* Gets the user.
*
* @param id. The ID of the user to retrive
* @return the requested user.
*/
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
@RolesAllowed
({
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
...
@@ -107,6 +112,12 @@ public class UserController {
...
@@ -107,6 +112,12 @@ public class UserController {
return
null
;
return
null
;
}
}
/**
* Deletes a user
*
* @param id. The ID of the user to delete
* @return The ID of the deleted user
*/
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
DELETE
)
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
DELETE
)
@RolesAllowed
({
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
...
@@ -117,13 +128,18 @@ public class UserController {
...
@@ -117,13 +128,18 @@ public class UserController {
throw
new
UserNotFoundException
(
"User "
+
id
+
" not found"
);
throw
new
UserNotFoundException
(
"User "
+
id
+
" not found"
);
}
}
service
.
getDao
().
delete
(
user
);
service
.
getDao
().
delete
(
user
);
return
"Deleted : "
+
id
;
return
"Deleted : "
+
id
;
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
Logger
.
getLogger
(
UserController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
Logger
.
getLogger
(
UserController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
return
null
;
return
null
;
}
}
/**
* Gets the IDs of all the stored users
*
* @return a list of all the IDs
*/
@RequestMapping
(
value
=
"/ids"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/ids"
,
method
=
RequestMethod
.
GET
)
@RolesAllowed
({
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/rest/UserPublicKeysController.java
View file @
f2c80f09
...
@@ -30,7 +30,6 @@ import org.springframework.web.bind.annotation.RequestParam;
...
@@ -30,7 +30,6 @@ import org.springframework.web.bind.annotation.RequestParam;
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
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
nl.uva.sne.drip.api.dao.UserKeyDao
;
import
nl.uva.sne.drip.api.exception.BadRequestException
;
import
nl.uva.sne.drip.api.exception.BadRequestException
;
import
nl.uva.sne.drip.api.exception.NotFoundException
;
import
nl.uva.sne.drip.api.exception.NotFoundException
;
import
nl.uva.sne.drip.api.service.UserKeyService
;
import
nl.uva.sne.drip.api.service.UserKeyService
;
...
@@ -39,6 +38,9 @@ import org.springframework.web.bind.annotation.PathVariable;
...
@@ -39,6 +38,9 @@ import org.springframework.web.bind.annotation.PathVariable;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
/**
/**
* This controller is responsible for handling user public keys. These keys can
* be used by the provisoner to allow the user to login to the VMs from the
* machine the keys correspond to.
*
*
* @author S. Koulouzis
* @author S. Koulouzis
*/
*/
...
@@ -51,6 +53,12 @@ public class UserPublicKeysController {
...
@@ -51,6 +53,12 @@ public class UserPublicKeysController {
private
UserKeyService
service
;
private
UserKeyService
service
;
// curl -v -X POST -F "file=@.ssh/id_dsa.pub" localhost:8080/drip-api/user_key/upload
// curl -v -X POST -F "file=@.ssh/id_dsa.pub" localhost:8080/drip-api/user_key/upload
/**
* Uploads a public key (id_dsa.pub,id_rsa.pub)
*
* @param file the public key file
* @return the ID of the stored public key
*/
@RequestMapping
(
value
=
"/upload"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/upload"
,
method
=
RequestMethod
.
POST
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
...
@@ -78,30 +86,44 @@ public class UserPublicKeysController {
...
@@ -78,30 +86,44 @@ public class UserPublicKeysController {
}
}
// curl -H "Content-Type: application/json" -X POST -d '{"key":"ssh-rsa AAAAB3NzaDWBqs75i849MytgwgQcRYMcsXIki0yeYTKABH6JqoiyFBHtYlyh/EV1t6cujb9LyNP4J5EN4fPbtwKYvxecd0LojSPxl4wjQlfrHyg6iKUYB7hVzGqACMvgYZHrtHPfrdEmOGPplPVPpoaX2j+u0BZ0yYhrWMKjzyYZKa68yy5N18+Gq+1p83HfUDwIU9wWaUYdgEvDujqF6b8p3z6LDx9Ob+RanSMZSt+b8eZRcd+F2Oy/gieJEJ8kc152VIOv8UY1xB3hVEwVnSRGgrAsa+9PChfF6efXUGWiKf8KBlWgBOYsSTsOY4ks9zkXMnbcTdC+o7xspOkyIcWjv us@u\n","name":"id_rsa.pub"}' localhost:8080/drip-api/user_key/
// curl -H "Content-Type: application/json" -X POST -d '{"key":"ssh-rsa AAAAB3NzaDWBqs75i849MytgwgQcRYMcsXIki0yeYTKABH6JqoiyFBHtYlyh/EV1t6cujb9LyNP4J5EN4fPbtwKYvxecd0LojSPxl4wjQlfrHyg6iKUYB7hVzGqACMvgYZHrtHPfrdEmOGPplPVPpoaX2j+u0BZ0yYhrWMKjzyYZKa68yy5N18+Gq+1p83HfUDwIU9wWaUYdgEvDujqF6b8p3z6LDx9Ob+RanSMZSt+b8eZRcd+F2Oy/gieJEJ8kc152VIOv8UY1xB3hVEwVnSRGgrAsa+9PChfF6efXUGWiKf8KBlWgBOYsSTsOY4ks9zkXMnbcTdC+o7xspOkyIcWjv us@u\n","name":"id_rsa.pub"}' localhost:8080/drip-api/user_key/
/**
* Posts the LoginKey and stores it. The LoginKey is a container for public
* key contents. The public key contents are represented in the 'key' field.
* All new lines in the 'key' field have to be replaced with the '\n'
* character.
*
* @param key. The LoginKey
* @return the ID of the LoginKey
*/
@RequestMapping
(
method
=
RequestMethod
.
POST
)
@RequestMapping
(
method
=
RequestMethod
.
POST
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
String
postKey
(
@RequestBody
LoginKey
uk
)
{
String
postKey
(
@RequestBody
LoginKey
key
)
{
LoginKey
.
Type
type
=
uk
.
getType
();
LoginKey
.
Type
type
=
key
.
getType
();
if
(
type
!=
null
&&
type
.
equals
(
LoginKey
.
Type
.
PRIVATE
))
{
if
(
type
!=
null
&&
type
.
equals
(
LoginKey
.
Type
.
PRIVATE
))
{
throw
new
BadRequestException
(
"Key can't be private"
);
throw
new
BadRequestException
(
"Key can't be private"
);
}
}
if
(
uk
.
getKey
()
==
null
)
{
if
(
key
.
getKey
()
==
null
)
{
throw
new
BadRequestException
(
"Key can't be empty"
);
throw
new
BadRequestException
(
"Key can't be empty"
);
}
}
String
originalName
=
uk
.
getName
();
String
originalName
=
key
.
getName
();
if
(
originalName
==
null
)
{
if
(
originalName
==
null
)
{
originalName
=
"id.pub"
;
originalName
=
"id.pub"
;
}
}
String
name
=
System
.
currentTimeMillis
()
+
"_"
+
originalName
;
String
name
=
System
.
currentTimeMillis
()
+
"_"
+
originalName
;
uk
.
setName
(
name
);
key
.
setName
(
name
);
uk
.
setType
(
LoginKey
.
Type
.
PUBLIC
);
key
.
setType
(
LoginKey
.
Type
.
PUBLIC
);
service
.
getDao
().
save
(
uk
);
service
.
getDao
().
save
(
key
);
return
uk
.
getId
();
return
key
.
getId
();
}
}
//curl localhost:8080/drip-api/user_key/58a20be263d4a5898835676e
/**
* Gets the LoginKey.
*
* @param id . The ID of the LoginKey to return
* @return The LoginKey
*/
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
...
@@ -114,7 +136,12 @@ public class UserPublicKeysController {
...
@@ -114,7 +136,12 @@ public class UserPublicKeysController {
}
}
// localhost:8080/drip-api/user_key/ids
// localhost:8080/drip-api/user_key/ids
@RequestMapping
(
value
=
"/ids"
)
/**
* Gets the IDs of all the stored LoginKey
*
* @return a list of all the IDs
*/
@RequestMapping
(
value
=
"/ids"
,
method
=
RequestMethod
.
GET
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
List
<
String
>
getIds
()
{
List
<
String
>
getIds
()
{
...
@@ -126,6 +153,12 @@ public class UserPublicKeysController {
...
@@ -126,6 +153,12 @@ public class UserPublicKeysController {
return
ids
;
return
ids
;
}
}
/**
* Deletes a LoginKey
*
* @param id. The ID of the LoginKey to deleted.
* @return The ID of the deleted LoginKey
*/
@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/UserScriptController.java
View file @
f2c80f09
...
@@ -20,7 +20,6 @@ import java.util.ArrayList;
...
@@ -20,7 +20,6 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.List
;
import
java.util.logging.Level
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
java.util.logging.Logger
;
import
org.json.JSONException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
@@ -30,10 +29,13 @@ import org.springframework.web.bind.annotation.ResponseBody;
...
@@ -30,10 +29,13 @@ import org.springframework.web.bind.annotation.ResponseBody;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
nl.uva.sne.drip.api.dao.UserScriptDao
;
import
nl.uva.sne.drip.api.dao.UserScriptDao
;
import
nl.uva.sne.drip.api.exception.NotFoundException
;
import
nl.uva.sne.drip.commons.types.UserScript
;
import
nl.uva.sne.drip.commons.types.UserScript
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
/**
/**
* This controller is responsible for handling user scripts. These user can be
* used by the provisoner to run on the created VMs.
*
*
* @author S. Koulouzis
* @author S. Koulouzis
*/
*/
...
@@ -46,9 +48,15 @@ public class UserScriptController {
...
@@ -46,9 +48,15 @@ public class UserScriptController {
private
UserScriptDao
dao
;
private
UserScriptDao
dao
;
// curl -v -X POST -F "file=@script.sh" localhost:8080/drip-api/rest/user_script/upload
// curl -v -X POST -F "file=@script.sh" localhost:8080/drip-api/rest/user_script/upload
/**
* Uploads a script
*
* @param file. The file of the script
* @return the ID of the stopred script
*/
@RequestMapping
(
value
=
"/upload"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/upload"
,
method
=
RequestMethod
.
POST
)
public
@ResponseBody
public
@ResponseBody
String
uploadUserScript
(
@RequestParam
(
"file"
)
MultipartFile
file
)
throws
JSONException
{
String
uploadUserScript
(
@RequestParam
(
"file"
)
MultipartFile
file
)
{
if
(!
file
.
isEmpty
())
{
if
(!
file
.
isEmpty
())
{
try
{
try
{
String
originalFileName
=
file
.
getOriginalFilename
();
String
originalFileName
=
file
.
getOriginalFilename
();
...
@@ -70,19 +78,33 @@ public class UserScriptController {
...
@@ -70,19 +78,33 @@ public class UserScriptController {
return
null
;
return
null
;
}
}
// @RequestMapping(method = RequestMethod.POST)
/**
// public @ResponseBody
* Gets a script
// String postConf(UserScript us) {
*
// String name = System.currentTimeMillis() + "_" + us.getName();
* @param id. The ID of the script to return
// us.setName(name);
* @return the script
// dao.save(us);
*/
// return us.getId();
// }
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
public
UserScript
get
(
@PathVariable
(
"id"
)
String
id
)
{
public
@ResponseBody
UserScript
get
(
@PathVariable
(
"id"
)
String
id
)
{
return
dao
.
findOne
(
id
);
return
dao
.
findOne
(
id
);
}
}
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
DELETE
)
public
String
delete
(
@PathVariable
(
"id"
)
String
id
)
{
UserScript
script
=
dao
.
findOne
(
id
);
if
(
script
==
null
)
{
throw
new
NotFoundException
();
}
dao
.
delete
(
id
);
return
"Deleted: "
+
id
;
}
/**
* Gets the IDs of all the stored scripts
*
* @return a list of all the IDs
*/
@RequestMapping
(
value
=
"/ids"
)
@RequestMapping
(
value
=
"/ids"
)
public
@ResponseBody
public
@ResponseBody
List
<
String
>
getIds
()
{
List
<
String
>
getIds
()
{
...
...
drip-commons/src/main/java/nl/uva/sne/drip/commons/types/UserScript.java
View file @
f2c80f09
/*
@ResponseBody
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
...
...
drip-provisioner/src/main/java/nl/uva/sne/drip/drip/provisioner/Consumer.java
View file @
f2c80f09
...
@@ -149,7 +149,7 @@ public class Consumer extends DefaultConsumer {
...
@@ -149,7 +149,7 @@ public class Consumer extends DefaultConsumer {
File
ec2ConfFile
=
null
;
File
ec2ConfFile
=
null
;
File
geniConfFile
=
null
;
File
geniConfFile
=
null
;
//loop through the parameters in a message to find the input files
//loop through the parameters in a message to find the input files
String
logDir
,
mainTopologyPath
,
sshKeyFilePath
,
scriptPath
;
String
logDir
,
mainTopologyPath
,
sshKeyFilePath
=
null
,
scriptPath
=
null
;
ArrayList
<
TopologyElement
>
topologyInfoArray
=
new
ArrayList
();
ArrayList
<
TopologyElement
>
topologyInfoArray
=
new
ArrayList
();
List
<
String
>
certificateNames
=
new
ArrayList
();
List
<
String
>
certificateNames
=
new
ArrayList
();
...
@@ -180,10 +180,14 @@ public class Consumer extends DefaultConsumer {
...
@@ -180,10 +180,14 @@ public class Consumer extends DefaultConsumer {
logDir
=
getLogDirPath
(
parameters
,
tempInputDirPath
);
logDir
=
getLogDirPath
(
parameters
,
tempInputDirPath
);
File
sshKey
=
getSSHKey
(
parameters
,
tempInputDirPath
);
File
sshKey
=
getSSHKey
(
parameters
,
tempInputDirPath
);
sshKeyFilePath
=
sshKey
.
getAbsolutePath
();
if
(
sshKey
!=
null
)
{
sshKeyFilePath
=
sshKey
.
getAbsolutePath
();
}
File
scriptFile
=
getSciptFile
(
parameters
,
tempInputDirPath
);
File
scriptFile
=
getSciptFile
(
parameters
,
tempInputDirPath
);
scriptPath
=
scriptFile
.
getAbsolutePath
();
if
(
scriptFile
!=
null
)
{
scriptPath
=
scriptFile
.
getAbsolutePath
();
}
File
curDir
=
new
File
(
tempInputDirPath
);
File
curDir
=
new
File
(
tempInputDirPath
);
for
(
File
f
:
curDir
.
listFiles
())
{
for
(
File
f
:
curDir
.
listFiles
())
{
...
...
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