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
9b8e422c
Commit
9b8e422c
authored
Mar 18, 2020
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use states to manipulate nodes
parent
9f91e794
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
108 additions
and
66 deletions
+108
-66
nodes.yaml
TOSCA/types/nodes.yaml
+20
-0
ToscaHelper.java
.../main/java/nl/uva/sne/drip/commons/utils/ToscaHelper.java
+34
-0
docker-compose.yml
docker-compose.yml
+4
-4
DeployerApiController.java
.../main/java/nl/uva/sne/drip/api/DeployerApiController.java
+0
-1
PlannerApiController.java
...c/main/java/nl/uva/sne/drip/api/PlannerApiController.java
+0
-1
ProvisionerApiController.java
...in/java/nl/uva/sne/drip/api/ProvisionerApiController.java
+0
-2
DRIPService.java
...er/src/main/java/nl/uva/sne/drip/service/DRIPService.java
+30
-44
ServiceTests.java
...r/src/test/java/nl/uva/sne/drip/service/ServiceTests.java
+0
-1
CloudStormService.java
...n/java/nl/uva/sne/drip/provisioner/CloudStormService.java
+20
-13
No files found.
TOSCA/types/nodes.yaml
View file @
9b8e422c
...
...
@@ -162,6 +162,26 @@ node_types:
interfaces
:
CloudsStorm
:
type
:
tosca.interfaces.ARTICONF.CloudsStorm
provision
:
inputs
:
code_type
:
SEQ
object_type
:
SubTopology
delete
:
inputs
:
code_type
:
SEQ
object_type
:
SubTopology
hscale
:
inputs
:
code_type
:
SEQ
object_type
:
SubTopology
stop
:
inputs
:
code_type
:
SEQ
object_type
:
SubTopology
start
:
inputs
:
code_type
:
SEQ
object_type
:
SubTopology
tosca.nodes.ARTICONF.VM.Compute
:
derived_from
:
tosca.nodes.ARTICONF.Infrastructure
...
...
commons/src/main/java/nl/uva/sne/drip/commons/utils/ToscaHelper.java
View file @
9b8e422c
...
...
@@ -61,6 +61,10 @@ public class ToscaHelper {
private
static
final
String
VM_TOPOLOGY
=
"tosca.nodes.ARTICONF.VM.topology"
;
private
Integer
id
;
public
static
enum
NODE_STATES
{
PROVISION
,
DELETE
,
START
,
STOP
,
H_SCALE
,
V_SCALE
,
CONFIGURE
}
@Autowired
public
ToscaHelper
(
String
sureToscaBasePath
)
{
init
(
sureToscaBasePath
);
...
...
@@ -295,4 +299,34 @@ public class ToscaHelper {
}
}
public
NODE_STATES
getNodeCurrentState
(
NodeTemplateMap
node
)
{
return
getNodeState
(
node
,
"current_state"
);
}
public
NodeTemplateMap
setNodeDesiredState
(
NodeTemplateMap
node
,
NODE_STATES
nodeState
)
{
return
setNodeState
(
node
,
"desired_state"
,
nodeState
);
}
public
NODE_STATES
getNodeDesiredState
(
NodeTemplateMap
node
)
{
return
getNodeState
(
node
,
"desired_state"
);
}
private
NODE_STATES
getNodeState
(
NodeTemplateMap
node
,
String
stateName
)
{
if
(
node
.
getNodeTemplate
().
getArtifacts
()
!=
null
)
{
return
NODE_STATES
.
valueOf
((
String
)
node
.
getNodeTemplate
().
getArtifacts
().
get
(
stateName
));
}
return
null
;
}
private
NodeTemplateMap
setNodeState
(
NodeTemplateMap
node
,
String
stateName
,
NODE_STATES
nodeState
)
{
Map
<
String
,
Object
>
artifacts
=
node
.
getNodeTemplate
().
getArtifacts
();
if
(
artifacts
==
null
)
{
artifacts
=
new
HashMap
<>();
}
artifacts
.
put
(
stateName
,
nodeState
.
toString
());
node
.
getNodeTemplate
().
setArtifacts
(
artifacts
);
return
node
;
}
}
docker-compose.yml
View file @
9b8e422c
...
...
@@ -116,10 +116,10 @@ services:
ports
:
-
"
30000:8080"
#
sure-tosca:
#
image: sure-tosca:3.0.0
#
ports:
#
- "8081:8081"
sure-tosca
:
image
:
sure-tosca:3.0.0
ports
:
-
"
8081:8081"
planner
:
depends_on
:
...
...
manager/src/main/java/nl/uva/sne/drip/api/DeployerApiController.java
View file @
9b8e422c
...
...
@@ -12,7 +12,6 @@ import org.springframework.web.bind.annotation.PathVariable;
import
javax.servlet.http.HttpServletRequest
;
import
nl.uva.sne.drip.service.DRIPService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.SpringCodegen"
,
date
=
"2019-10-10T17:15:46.465Z"
)
...
...
manager/src/main/java/nl/uva/sne/drip/api/PlannerApiController.java
View file @
9b8e422c
...
...
@@ -15,7 +15,6 @@ import javax.servlet.http.HttpServletRequest;
import
nl.uva.sne.drip.service.DRIPService
;
import
nl.uva.sne.drip.sure.tosca.client.ApiException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
@Controller
public
class
PlannerApiController
implements
PlannerApi
{
...
...
manager/src/main/java/nl/uva/sne/drip/api/ProvisionerApiController.java
View file @
9b8e422c
package
nl
.
uva
.
sne
.
drip
.
api
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
io.swagger.annotations.*
;
import
java.io.IOException
;
...
...
@@ -19,7 +18,6 @@ import nl.uva.sne.drip.model.Exceptions.TypeExeption;
import
nl.uva.sne.drip.service.DRIPService
;
import
nl.uva.sne.drip.sure.tosca.client.ApiException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.SpringCodegen"
,
date
=
"2019-10-10T17:15:46.465Z"
)
...
...
manager/src/main/java/nl/uva/sne/drip/service/DRIPService.java
View file @
9b8e422c
...
...
@@ -7,20 +7,18 @@ package nl.uva.sne.drip.service;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.TimeoutException
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
nl.uva.sne.drip.api.NotFoundException
;
import
nl.uva.sne.drip.commons.utils.ToscaHelper
;
import
nl.uva.sne.drip.commons.utils.ToscaHelper.NODE_STATES
;
import
nl.uva.sne.drip.model.Exceptions.MissingCredentialsException
;
import
nl.uva.sne.drip.model.Exceptions.MissingVMTopologyException
;
import
nl.uva.sne.drip.model.Exceptions.TypeExeption
;
import
nl.uva.sne.drip.model.Message
;
import
nl.uva.sne.drip.model.NodeTemplateMap
;
import
nl.uva.sne.drip.model.cloud.storm.CloudsStormSubTopology
;
import
nl.uva.sne.drip.model.tosca.Credential
;
import
nl.uva.sne.drip.model.tosca.ToscaTemplate
;
import
nl.uva.sne.drip.rpc.DRIPCaller
;
...
...
@@ -51,14 +49,6 @@ public class DRIPService {
@Autowired
ProvisionerService
provisionerService
;
enum
PROVISIONER_OPERATION
{
PROVISION
,
DELETE
,
START
,
STOP
,
H_SCALE
,
V_SCALE
,
CONFIGURE
}
enum
DELETE_ACTIONS
{
PROVISION
,
DEPLOYMENT
}
@Value
(
"${message.broker.queue.provisioner}"
)
private
String
provisionerQueueName
;
...
...
@@ -93,7 +83,7 @@ public class DRIPService {
if
(
vmTopologies
==
null
)
{
throw
new
MissingVMTopologyException
(
"ToscaTemplate: "
+
toscaTemplate
+
" has no VM topology"
);
}
List
<
Credential
>
credentials
=
null
;
List
<
Credential
>
credentials
;
for
(
NodeTemplateMap
vmTopologyMap
:
vmTopologies
)
{
String
provider
=
helper
.
getTopologyProvider
(
vmTopologyMap
);
if
(
needsCredentials
(
provider
))
{
...
...
@@ -114,31 +104,27 @@ public class DRIPService {
public
String
plan
(
String
id
)
throws
ApiException
,
NotFoundException
,
IOException
,
JsonProcessingException
,
TimeoutException
,
InterruptedException
{
ToscaTemplate
toscaTemplate
=
initExecution
(
id
);
return
execute
(
toscaTemplate
,
plannerQueueName
);
return
execute
(
toscaTemplate
,
plannerQueueName
);
}
public
String
provision
(
String
id
)
throws
MissingCredentialsException
,
ApiException
,
TypeExeption
,
IOException
,
JsonProcessingException
,
TimeoutException
,
InterruptedException
,
NotFoundException
,
MissingVMTopologyException
{
ToscaTemplate
toscaTemplate
=
initExecution
(
id
);
toscaTemplate
=
addCredentials
(
toscaTemplate
);
toscaTemplate
=
setProvisionerOperation
(
toscaTemplate
,
PROVISIONER_OPERATION
.
PROVISION
);
return
execute
(
toscaTemplate
,
provisionerQueueName
);
List
<
NodeTemplateMap
>
vmTopologies
=
helper
.
getVMTopologyTemplates
();
if
(
vmTopologies
==
null
||
vmTopologies
.
isEmpty
())
{
throw
new
MissingVMTopologyException
(
"ToscaTemplate: "
+
toscaTemplate
+
" has no VM Topologies"
);
}
toscaTemplate
=
setDesieredSate
(
toscaTemplate
,
vmTopologies
,
NODE_STATES
.
PROVISION
);
return
execute
(
toscaTemplate
,
provisionerQueueName
);
}
protected
ToscaTemplate
setProvisionerOperation
(
ToscaTemplate
toscaTemplate
,
PROVISIONER_OPERATION
operation
)
throws
IOException
,
JsonProcessingException
,
ApiException
{
List
<
NodeTemplateMap
>
vmTopologies
=
helper
.
getVMTopologyTemplates
();
for
(
NodeTemplateMap
vmTopologyMap
:
vmTopologies
)
{
Map
<
String
,
Object
>
provisionerInterface
=
helper
.
getProvisionerInterfaceFromVMTopology
(
vmTopologyMap
);
if
(
provisionerInterface
==
null
||
!
provisionerInterface
.
containsKey
(
operation
.
toString
().
toLowerCase
()))
{
provisionerInterface
=
new
HashMap
<>();
Map
<
String
,
Object
>
inputsMap
=
new
HashMap
<>();
inputsMap
.
put
(
"code_type"
,
" SEQ"
);
inputsMap
.
put
(
"object_type"
,
" SubTopology"
);
Map
<
String
,
Object
>
provisionMap
=
new
HashMap
<>();
provisionMap
.
put
(
"inputs"
,
inputsMap
);
provisionerInterface
.
put
(
operation
.
toString
().
toLowerCase
(),
provisionMap
);
vmTopologyMap
=
helper
.
setProvisionerInterfaceInVMTopology
(
vmTopologyMap
,
provisionerInterface
);
toscaTemplate
=
helper
.
setNodeInToscaTemplate
(
toscaTemplate
,
vmTopologyMap
);
}
protected
ToscaTemplate
setDesieredSate
(
ToscaTemplate
toscaTemplate
,
List
<
NodeTemplateMap
>
nodes
,
NODE_STATES
nodeState
)
throws
IOException
,
JsonProcessingException
,
ApiException
{
for
(
NodeTemplateMap
node
:
nodes
)
{
NODE_STATES
currentState
=
helper
.
getNodeCurrentState
(
node
);
NODE_STATES
desiredState
=
helper
.
getNodeDesiredState
(
node
);
node
=
helper
.
setNodeDesiredState
(
node
,
nodeState
);
toscaTemplate
=
helper
.
setNodeInToscaTemplate
(
toscaTemplate
,
node
);
}
return
toscaTemplate
;
}
...
...
@@ -154,7 +140,7 @@ public class DRIPService {
public
String
deploy
(
String
id
)
throws
JsonProcessingException
,
NotFoundException
,
IOException
,
ApiException
,
Exception
{
ToscaTemplate
toscaTemplate
=
initExecution
(
id
);
return
execute
(
toscaTemplate
,
deployerQueueName
);
return
execute
(
toscaTemplate
,
deployerQueueName
);
}
protected
ToscaTemplate
initExecution
(
String
id
)
throws
JsonProcessingException
,
NotFoundException
,
IOException
,
ApiException
{
...
...
@@ -166,19 +152,19 @@ public class DRIPService {
}
public
String
delete
(
String
id
,
List
<
String
>
nodeNames
)
throws
NotFoundException
,
IOException
,
JsonProcessingException
,
ApiException
,
TypeExeption
,
TimeoutException
,
InterruptedException
{
ToscaTemplate
toscaTemplate
=
initExecution
(
id
);
if
(
nodeNames
==
null
||
nodeNames
.
isEmpty
())
{
List
<
NodeTemplateMap
>
vmTopologies
=
helper
.
getVMTopologyTemplates
();
if
(
vmTopologies
!=
null
)
{
for
(
NodeTemplateMap
vmTopology
:
vmTopologies
)
{
CloudsStormSubTopology
.
StatusEnum
status
=
helper
.
getVMTopologyTemplateStatus
(
vmTopology
);
if
(!
status
.
equals
(
CloudsStormSubTopology
.
StatusEnum
.
DELETED
))
{
toscaTemplate
=
setProvisionerOperation
(
toscaTemplate
,
PROVISIONER_OPERATION
.
DELETE
);
}
}
return
execute
(
toscaTemplate
,
provisionerQueueName
);
}
}
//
ToscaTemplate toscaTemplate = initExecution(id);
//
if (nodeNames == null || nodeNames.isEmpty()) {
//
List<NodeTemplateMap> vmTopologies = helper.getVMTopologyTemplates();
//
if (vmTopologies != null) {
//
for (NodeTemplateMap vmTopology : vmTopologies) {
//
CloudsStormSubTopology.StatusEnum status = helper.getVMTopologyTemplateStatus(vmTopology);
//
if (!status.equals(CloudsStormSubTopology.StatusEnum.DELETED)) {
// toscaTemplate = setDesieredSate(toscaTemplate, vmTopologies, NODE_STATES
.DELETE);
//
}
//
}
// return execute(toscaTemplate,
provisionerQueueName);
//
}
//
}
return
null
;
}
...
...
manager/src/test/java/nl/uva/sne/drip/service/ServiceTests.java
View file @
9b8e422c
...
...
@@ -416,7 +416,6 @@ public class ServiceTests {
ToscaTemplate
toscaTemplate
=
dripService
.
initExecution
(
id
);
toscaTemplate
=
dripService
.
addCredentials
(
toscaTemplate
);
toscaTemplate
=
dripService
.
setProvisionerOperation
(
toscaTemplate
,
DRIPService
.
PROVISIONER_OPERATION
.
PROVISION
);
}
}
}
provisioner/src/main/java/nl/uva/sne/drip/provisioner/CloudStormService.java
View file @
9b8e422c
...
...
@@ -293,19 +293,26 @@ class CloudStormService {
int
i
=
0
;
List
<
InfrasCode
>
infrasCodes
=
new
ArrayList
<>();
for
(
NodeTemplateMap
vmTopologyMap
:
vmTopologiesMaps
)
{
Map
<
String
,
Object
>
provisionInterface
=
helper
.
getProvisionerInterfaceFromVMTopology
(
vmTopologyMap
);
String
operation
=
provisionInterface
.
keySet
().
iterator
().
next
();
Map
<
String
,
Object
>
inputs
=
(
Map
<
String
,
Object
>)
provisionInterface
.
get
(
operation
);
inputs
.
put
(
"object_type"
,
cloudStormSubtopologies
.
get
(
i
).
getTopology
());
OpCode
opCode
=
new
OpCode
();
opCode
.
setLog
(
Boolean
.
FALSE
);
opCode
.
setObjectType
(
OpCode
.
ObjectTypeEnum
.
SUBTOPOLOGY
);
opCode
.
setObjects
(
cloudStormSubtopologies
.
get
(
i
).
getTopology
());
opCode
.
setOperation
(
OpCode
.
OperationEnum
.
fromValue
(
operation
));
InfrasCode
infrasCode
=
new
InfrasCode
();
infrasCode
.
setCodeType
(
InfrasCode
.
CodeTypeEnum
.
SEQ
);
infrasCode
.
setOpCode
(
opCode
);
infrasCodes
.
add
(
infrasCode
);
ToscaHelper
.
NODE_STATES
nodeCurrentState
=
helper
.
getNodeCurrentState
(
vmTopologyMap
);
ToscaHelper
.
NODE_STATES
nodeDesiredState
=
helper
.
getNodeDesiredState
(
vmTopologyMap
);
if
(
nodeCurrentState
!=
null
&&
nodeCurrentState
.
equals
(
ToscaHelper
.
NODE_STATES
.
PROVISION
))
{
//Already there
}
if
(
nodeCurrentState
==
null
||
nodeCurrentState
.
equals
(
ToscaHelper
.
NODE_STATES
.
DELETE
))
{
Map
<
String
,
Object
>
provisionInterface
=
helper
.
getProvisionerInterfaceFromVMTopology
(
vmTopologyMap
);
String
operation
=
nodeDesiredState
.
toString
().
toLowerCase
();
Map
<
String
,
Object
>
inputs
=
(
Map
<
String
,
Object
>)
provisionInterface
.
get
(
operation
);
inputs
.
put
(
"object_type"
,
cloudStormSubtopologies
.
get
(
i
).
getTopology
());
OpCode
opCode
=
new
OpCode
();
opCode
.
setLog
(
Boolean
.
FALSE
);
opCode
.
setObjectType
(
OpCode
.
ObjectTypeEnum
.
SUBTOPOLOGY
);
opCode
.
setObjects
(
cloudStormSubtopologies
.
get
(
i
).
getTopology
());
opCode
.
setOperation
(
OpCode
.
OperationEnum
.
fromValue
(
operation
));
InfrasCode
infrasCode
=
new
InfrasCode
();
infrasCode
.
setCodeType
(
InfrasCode
.
CodeTypeEnum
.
SEQ
);
infrasCode
.
setOpCode
(
opCode
);
infrasCodes
.
add
(
infrasCode
);
}
}
CloudsStormInfrasCode
cloudsStormInfrasCode
=
new
CloudsStormInfrasCode
();
cloudsStormInfrasCode
.
setMode
(
CloudsStormInfrasCode
.
ModeEnum
.
LOCAL
);
...
...
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