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
Show 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 @@
...
@@ -15,8 +15,15 @@
*/
*/
package
nl
.
uva
.
sne
.
drip
.
api
.
service
;
package
nl
.
uva
.
sne
.
drip
.
api
.
service
;
import
java.util.List
;
import
nl.uva.sne.drip.api.dao.ClusterCredentialsDao
;
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.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
;
import
org.springframework.stereotype.Service
;
/**
/**
...
@@ -24,15 +31,33 @@ import org.springframework.stereotype.Service;
...
@@ -24,15 +31,33 @@ import org.springframework.stereotype.Service;
* @author S. Koulouzis
* @author S. Koulouzis
*/
*/
@Service
@Service
@PreAuthorize
(
"isAuthenticated()"
)
public
class
ClusterCredentialService
{
public
class
ClusterCredentialService
{
@Autowired
@Autowired
private
ClusterCredentialsDao
dao
;
private
ClusterCredentialsDao
dao
;
/**
@PostAuthorize
(
"(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))"
)
* @return the dao
public
ClusterCredentials
findOne
(
String
id
)
{
*/
return
dao
.
findOne
(
id
);
public
ClusterCredentialsDao
getDao
()
{
}
return
dao
;
@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;
...
@@ -40,6 +40,8 @@ import nl.uva.sne.drip.drip.converter.SimplePlanContainer;
import
org.json.JSONException
;
import
org.json.JSONException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
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.access.prepost.PreAuthorize
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -131,7 +133,7 @@ public class PlannerService {
...
@@ -131,7 +133,7 @@ public class PlannerService {
}
}
public
String
get
(
String
id
,
String
fromat
)
throws
JSONException
{
public
String
get
(
String
id
,
String
fromat
)
throws
JSONException
{
Plan
plan
=
planDao
.
findOne
(
id
);
Plan
plan
=
findOne
(
id
);
if
(
plan
==
null
)
{
if
(
plan
==
null
)
{
throw
new
NotFoundException
();
throw
new
NotFoundException
();
}
}
...
@@ -139,7 +141,7 @@ public class PlannerService {
...
@@ -139,7 +141,7 @@ public class PlannerService {
Map
<
String
,
Object
>
map
=
plan
.
getKeyValue
();
Map
<
String
,
Object
>
map
=
plan
.
getKeyValue
();
Set
<
String
>
ids
=
plan
.
getLoweLevelPlanIDs
();
Set
<
String
>
ids
=
plan
.
getLoweLevelPlanIDs
();
for
(
String
lowID
:
ids
)
{
for
(
String
lowID
:
ids
)
{
Map
<
String
,
Object
>
lowLevelMap
=
planDao
.
findOne
(
lowID
).
getKeyValue
();
Map
<
String
,
Object
>
lowLevelMap
=
findOne
(
lowID
).
getKeyValue
();
if
(
lowLevelMap
!=
null
)
{
if
(
lowLevelMap
!=
null
)
{
map
.
putAll
(
lowLevelMap
);
map
.
putAll
(
lowLevelMap
);
}
}
...
@@ -161,9 +163,10 @@ public class PlannerService {
...
@@ -161,9 +163,10 @@ public class PlannerService {
}
}
public
String
getToscaID
(
String
id
)
{
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
()
{
public
List
<
Plan
>
findAll
()
{
List
<
Plan
>
all
=
planDao
.
findAll
();
List
<
Plan
>
all
=
planDao
.
findAll
();
List
<
Plan
>
topLevel
=
new
ArrayList
<>();
List
<
Plan
>
topLevel
=
new
ArrayList
<>();
...
@@ -182,12 +185,17 @@ public class PlannerService {
...
@@ -182,12 +185,17 @@ public class PlannerService {
return
planDao
.
save
(
plan
);
return
planDao
.
save
(
plan
);
}
}
@PostAuthorize
(
"(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))"
)
public
Plan
findOne
(
String
lowiID
)
{
public
Plan
findOne
(
String
lowiID
)
{
return
planDao
.
findOne
(
lowiID
);
return
planDao
.
findOne
(
lowiID
);
}
}
@PostAuthorize
(
"(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))"
)
public
Plan
delete
(
String
id
)
{
public
Plan
delete
(
String
id
)
{
Plan
plan
=
planDao
.
findOne
(
id
);
Plan
plan
=
planDao
.
findOne
(
id
);
if
(
plan
==
null
)
{
throw
new
NotFoundException
();
}
planDao
.
delete
(
plan
);
planDao
.
delete
(
plan
);
return
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;
...
@@ -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.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.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
;
import
nl.uva.sne.drip.api.rpc.ProvisionerCaller
;
import
nl.uva.sne.drip.api.rpc.ProvisionerCaller
;
...
@@ -95,6 +96,9 @@ public class ProvisionService {
...
@@ -95,6 +96,9 @@ public class ProvisionService {
@PostAuthorize
(
"(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))"
)
@PostAuthorize
(
"(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))"
)
public
ProvisionInfo
findOne
(
String
id
)
{
public
ProvisionInfo
findOne
(
String
id
)
{
ProvisionInfo
provisionInfo
=
dao
.
findOne
(
id
);
ProvisionInfo
provisionInfo
=
dao
.
findOne
(
id
);
if
(
provisionInfo
==
null
)
{
throw
new
NotFoundException
();
}
return
provisionInfo
;
return
provisionInfo
;
}
}
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/v1/rest/DeployController.java
View file @
c36da2cd
...
@@ -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.
* This controller is responsible for deploying a cluster on provisoned
* resources.
*
*
* @author S. Koulouzis
* @author S. Koulouzis
*/
*/
...
@@ -76,6 +77,7 @@ public class DeployController {
...
@@ -76,6 +77,7 @@ public class DeployController {
/**
/**
* Deploys a cluster on a provisioned resources.
* Deploys a cluster on a provisioned resources.
*
* @param provisionID
* @param provisionID
* @param clusterType
* @param clusterType
* @return the id of the cluster credentials
* @return the id of the cluster credentials
...
@@ -97,7 +99,7 @@ public class DeployController {
...
@@ -97,7 +99,7 @@ public class DeployController {
if
(
name
.
equals
(
"credential"
))
{
if
(
name
.
equals
(
"credential"
))
{
String
value
=
p
.
getValue
();
String
value
=
p
.
getValue
();
clusterCred
.
setContents
(
value
);
clusterCred
.
setContents
(
value
);
clusterCredentialService
.
getDao
().
save
(
clusterCred
);
clusterCredentialService
.
save
(
clusterCred
);
return
clusterCred
.
getId
();
return
clusterCred
.
getId
();
}
}
}
}
...
@@ -110,6 +112,7 @@ public class DeployController {
...
@@ -110,6 +112,7 @@ public class DeployController {
/**
/**
* Gets the cluster credentials.
* Gets the cluster credentials.
*
* @param id
* @param id
* @return the cluster credentials
* @return the cluster credentials
*/
*/
...
@@ -117,7 +120,7 @@ public class DeployController {
...
@@ -117,7 +120,7 @@ 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
)
{
ClusterCredentials
clusterC
=
clusterCredentialService
.
getDao
().
findOne
(
id
);
ClusterCredentials
clusterC
=
clusterCredentialService
.
findOne
(
id
);
if
(
clusterC
==
null
)
{
if
(
clusterC
==
null
)
{
throw
new
NotFoundException
();
throw
new
NotFoundException
();
}
}
...
@@ -126,13 +129,14 @@ public class DeployController {
...
@@ -126,13 +129,14 @@ public class DeployController {
/**
/**
* Gets the IDs of all the stored cluster credentials
* 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
)
@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
()
{
List
<
ClusterCredentials
>
all
=
clusterCredentialService
.
getDao
().
findAll
();
List
<
ClusterCredentials
>
all
=
clusterCredentialService
.
findAll
();
List
<
String
>
ids
=
new
ArrayList
<>(
all
.
size
());
List
<
String
>
ids
=
new
ArrayList
<>(
all
.
size
());
for
(
ClusterCredentials
pi
:
all
)
{
for
(
ClusterCredentials
pi
:
all
)
{
ids
.
add
(
pi
.
getId
());
ids
.
add
(
pi
.
getId
());
...
@@ -142,6 +146,7 @@ public class DeployController {
...
@@ -142,6 +146,7 @@ public class DeployController {
/**
/**
* Deletes a cluster credential
* Deletes a cluster credential
*
* @param id. The id of the cluster credential
* @param id. The id of the cluster credential
* @return the id f the deleted cluster credential
* @return the id f the deleted cluster credential
*/
*/
...
@@ -149,9 +154,9 @@ public class DeployController {
...
@@ -149,9 +154,9 @@ public class DeployController {
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
String
delete
(
@PathVariable
(
"id"
)
String
id
)
{
String
delete
(
@PathVariable
(
"id"
)
String
id
)
{
ClusterCredentials
cred
=
clusterCredentialService
.
getDao
().
findOne
(
id
);
ClusterCredentials
cred
=
clusterCredentialService
.
findOne
(
id
);
if
(
cred
!=
null
)
{
if
(
cred
!=
null
)
{
provision
Service
.
delete
(
id
);
clusterCredential
Service
.
delete
(
id
);
return
"Deleted : "
+
id
;
return
"Deleted : "
+
id
;
}
}
throw
new
NotFoundException
();
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;
...
@@ -24,7 +24,7 @@ import org.springframework.data.annotation.Id;
*
*
* @author S. Koulouzis
* @author S. Koulouzis
*/
*/
public
class
ClusterCredentials
{
public
class
ClusterCredentials
extends
OwnedObject
{
@Id
@Id
private
String
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