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
c36da2cd
Commit
c36da2cd
authored
Mar 10, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
provision with API v0.0 works
parent
ba93249a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
24 deletions
+66
-24
ClusterCredentialService.java
...nl/uva/sne/drip/api/service/ClusterCredentialService.java
+30
-5
PlannerService.java
...main/java/nl/uva/sne/drip/api/service/PlannerService.java
+11
-3
ProvisionService.java
...in/java/nl/uva/sne/drip/api/service/ProvisionService.java
+4
-0
DeployController.java
...in/java/nl/uva/sne/drip/api/v1/rest/DeployController.java
+20
-15
ClusterCredentials.java
.../nl/uva/sne/drip/commons/v1/types/ClusterCredentials.java
+1
-1
control_agent.pyc
drip-deployer/control_agent.pyc
+0
-0
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/service/ClusterCredentialService.java
View file @
c36da2cd
...
...
@@ -15,8 +15,15 @@
*/
package
nl
.
uva
.
sne
.
drip
.
api
.
service
;
import
java.util.List
;
import
nl.uva.sne.drip.api.dao.ClusterCredentialsDao
;
import
nl.uva.sne.drip.commons.v1.types.ClusterCredentials
;
import
nl.uva.sne.drip.commons.v1.types.User
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PostAuthorize
;
import
org.springframework.security.access.prepost.PostFilter
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.stereotype.Service
;
/**
...
...
@@ -24,15 +31,33 @@ import org.springframework.stereotype.Service;
* @author S. Koulouzis
*/
@Service
@PreAuthorize
(
"isAuthenticated()"
)
public
class
ClusterCredentialService
{
@Autowired
private
ClusterCredentialsDao
dao
;
/**
* @return the dao
*/
public
ClusterCredentialsDao
getDao
()
{
return
dao
;
@PostAuthorize
(
"(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))"
)
public
ClusterCredentials
findOne
(
String
id
)
{
return
dao
.
findOne
(
id
);
}
@PostFilter
(
"(filterObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))"
)
public
List
<
ClusterCredentials
>
findAll
()
{
return
dao
.
findAll
();
}
@PostAuthorize
(
"(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))"
)
public
ClusterCredentials
delete
(
String
id
)
{
ClusterCredentials
cred
=
dao
.
findOne
(
id
);
dao
.
delete
(
cred
);
return
cred
;
}
public
ClusterCredentials
save
(
ClusterCredentials
clusterCred
)
{
User
user
=
(
User
)
SecurityContextHolder
.
getContext
().
getAuthentication
().
getPrincipal
();
String
owner
=
user
.
getUsername
();
clusterCred
.
setOwner
(
owner
);
return
dao
.
save
(
clusterCred
);
}
}
drip-api/src/main/java/nl/uva/sne/drip/api/service/PlannerService.java
View file @
c36da2cd
...
...
@@ -40,6 +40,8 @@ import nl.uva.sne.drip.drip.converter.SimplePlanContainer;
import
org.json.JSONException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.security.access.prepost.PostAuthorize
;
import
org.springframework.security.access.prepost.PostFilter
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.stereotype.Service
;
...
...
@@ -131,7 +133,7 @@ public class PlannerService {
}
public
String
get
(
String
id
,
String
fromat
)
throws
JSONException
{
Plan
plan
=
planDao
.
findOne
(
id
);
Plan
plan
=
findOne
(
id
);
if
(
plan
==
null
)
{
throw
new
NotFoundException
();
}
...
...
@@ -139,7 +141,7 @@ public class PlannerService {
Map
<
String
,
Object
>
map
=
plan
.
getKeyValue
();
Set
<
String
>
ids
=
plan
.
getLoweLevelPlanIDs
();
for
(
String
lowID
:
ids
)
{
Map
<
String
,
Object
>
lowLevelMap
=
planDao
.
findOne
(
lowID
).
getKeyValue
();
Map
<
String
,
Object
>
lowLevelMap
=
findOne
(
lowID
).
getKeyValue
();
if
(
lowLevelMap
!=
null
)
{
map
.
putAll
(
lowLevelMap
);
}
...
...
@@ -161,9 +163,10 @@ public class PlannerService {
}
public
String
getToscaID
(
String
id
)
{
return
planDao
.
findOne
(
id
).
getToscaID
();
return
findOne
(
id
).
getToscaID
();
}
@PostFilter
(
"(filterObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))"
)
public
List
<
Plan
>
findAll
()
{
List
<
Plan
>
all
=
planDao
.
findAll
();
List
<
Plan
>
topLevel
=
new
ArrayList
<>();
...
...
@@ -182,12 +185,17 @@ public class PlannerService {
return
planDao
.
save
(
plan
);
}
@PostAuthorize
(
"(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))"
)
public
Plan
findOne
(
String
lowiID
)
{
return
planDao
.
findOne
(
lowiID
);
}
@PostAuthorize
(
"(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))"
)
public
Plan
delete
(
String
id
)
{
Plan
plan
=
planDao
.
findOne
(
id
);
if
(
plan
==
null
)
{
throw
new
NotFoundException
();
}
planDao
.
delete
(
plan
);
return
plan
;
}
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/service/ProvisionService.java
View file @
c36da2cd
...
...
@@ -36,6 +36,7 @@ import nl.uva.sne.drip.api.dao.ProvisionInfoDao;
import
nl.uva.sne.drip.api.exception.BadRequestException
;
import
nl.uva.sne.drip.api.exception.CloudCredentialsNotFoundException
;
import
nl.uva.sne.drip.api.exception.ExceptionHandler
;
import
nl.uva.sne.drip.api.exception.NotFoundException
;
import
nl.uva.sne.drip.api.exception.PlanNotFoundException
;
import
nl.uva.sne.drip.api.rpc.DRIPCaller
;
import
nl.uva.sne.drip.api.rpc.ProvisionerCaller
;
...
...
@@ -95,6 +96,9 @@ public class ProvisionService {
@PostAuthorize
(
"(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))"
)
public
ProvisionInfo
findOne
(
String
id
)
{
ProvisionInfo
provisionInfo
=
dao
.
findOne
(
id
);
if
(
provisionInfo
==
null
)
{
throw
new
NotFoundException
();
}
return
provisionInfo
;
}
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/v1/rest/DeployController.java
View file @
c36da2cd
...
...
@@ -53,8 +53,9 @@ import org.springframework.web.bind.annotation.PathVariable;
import
org.springframework.web.bind.annotation.RequestParam
;
/**
* This controller is responsible for deploying a cluster on provisoned resources.
*
* This controller is responsible for deploying a cluster on provisoned
* resources.
*
* @author S. Koulouzis
*/
@RestController
...
...
@@ -75,10 +76,11 @@ public class DeployController {
private
ClusterCredentialService
clusterCredentialService
;
/**
* Deploys a cluster on a provisioned resources.
* @param provisionID
* Deploys a cluster on a provisioned resources.
*
* @param provisionID
* @param clusterType
* @return the id of the cluster credentials
* @return the id of the cluster credentials
*/
@RequestMapping
(
value
=
"/deploy/{id}/"
,
method
=
RequestMethod
.
GET
,
params
=
{
"cluster"
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
...
...
@@ -97,7 +99,7 @@ public class DeployController {
if
(
name
.
equals
(
"credential"
))
{
String
value
=
p
.
getValue
();
clusterCred
.
setContents
(
value
);
clusterCredentialService
.
getDao
().
save
(
clusterCred
);
clusterCredentialService
.
save
(
clusterCred
);
return
clusterCred
.
getId
();
}
}
...
...
@@ -109,7 +111,8 @@ public class DeployController {
}
/**
* Gets the cluster credentials.
* Gets the cluster credentials.
*
* @param id
* @return the cluster credentials
*/
...
...
@@ -117,7 +120,7 @@ public class DeployController {
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
ClusterCredentials
get
(
@PathVariable
(
"id"
)
String
id
)
{
ClusterCredentials
clusterC
=
clusterCredentialService
.
getDao
().
findOne
(
id
);
ClusterCredentials
clusterC
=
clusterCredentialService
.
findOne
(
id
);
if
(
clusterC
==
null
)
{
throw
new
NotFoundException
();
}
...
...
@@ -126,13 +129,14 @@ public class DeployController {
/**
* Gets the IDs of all the stored cluster credentials
* @return a list of all the IDs
*
* @return a list of all the IDs
*/
@RequestMapping
(
value
=
"/ids"
,
method
=
RequestMethod
.
GET
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
List
<
String
>
getIds
()
{
List
<
ClusterCredentials
>
all
=
clusterCredentialService
.
getDao
().
findAll
();
List
<
ClusterCredentials
>
all
=
clusterCredentialService
.
findAll
();
List
<
String
>
ids
=
new
ArrayList
<>(
all
.
size
());
for
(
ClusterCredentials
pi
:
all
)
{
ids
.
add
(
pi
.
getId
());
...
...
@@ -141,17 +145,18 @@ public class DeployController {
}
/**
* Deletes a cluster credential
* @param id. The id of the cluster credential
* @return the id f the deleted cluster credential
* 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
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
String
delete
(
@PathVariable
(
"id"
)
String
id
)
{
ClusterCredentials
cred
=
clusterCredentialService
.
getDao
().
findOne
(
id
);
ClusterCredentials
cred
=
clusterCredentialService
.
findOne
(
id
);
if
(
cred
!=
null
)
{
provision
Service
.
delete
(
id
);
clusterCredential
Service
.
delete
(
id
);
return
"Deleted : "
+
id
;
}
throw
new
NotFoundException
();
...
...
drip-api/src/main/java/nl/uva/sne/drip/commons/v1/types/ClusterCredentials.java
View file @
c36da2cd
...
...
@@ -24,7 +24,7 @@ import org.springframework.data.annotation.Id;
*
* @author S. Koulouzis
*/
public
class
ClusterCredentials
{
public
class
ClusterCredentials
extends
OwnedObject
{
@Id
private
String
id
;
...
...
drip-deployer/control_agent.pyc
View file @
c36da2cd
No preview for this file type
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