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
2bbc0d82
Commit
2bbc0d82
authored
Mar 19, 2020
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed status from topology. All nodes have state attribute
parent
369b1304
Changes
14
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
517 additions
and
157 deletions
+517
-157
application_example_provisioned.yaml
TOSCA/application_example_provisioned.yaml
+54
-78
nodes.yaml
TOSCA/types/nodes.yaml
+1
-6
pom.xml
commons/pom.xml
+7
-1
Converter.java
...rc/main/java/nl/uva/sne/drip/commons/utils/Converter.java
+3
-3
ToscaHelper.java
.../main/java/nl/uva/sne/drip/commons/utils/ToscaHelper.java
+41
-3
ToscaHelperTest.java
...t/java/nl/uva/sne/drip/commons/utils/ToscaHelperTest.java
+41
-0
test_deployer.py
deployer/test/test_deployer.py
+2
-2
message_example_provisioned.json
example_messages/message_example_provisioned.json
+0
-0
message_provision_request.json
example_messages/message_provision_request.json
+1
-0
DRIPService.java
...er/src/main/java/nl/uva/sne/drip/service/DRIPService.java
+2
-2
ServiceTests.java
...r/src/test/java/nl/uva/sne/drip/service/ServiceTests.java
+1
-1
CloudStormService.java
...n/java/nl/uva/sne/drip/provisioner/CloudStormService.java
+60
-36
RPCServer.java
.../src/main/java/nl/uva/sne/drip/provisioner/RPCServer.java
+42
-25
CloudStormServiceTest.java
...va/nl/uva/sne/drip/provisioner/CloudStormServiceTest.java
+262
-0
No files found.
TOSCA/application_example_provisioned.yaml
View file @
2bbc0d82
This diff is collapsed.
Click to expand it.
TOSCA/types/nodes.yaml
View file @
2bbc0d82
...
@@ -154,11 +154,6 @@ node_types:
...
@@ -154,11 +154,6 @@ node_types:
ssh_keys
:
ssh_keys
:
type
:
tosca.datatypes.ARTICONF.Credential
type
:
tosca.datatypes.ARTICONF.Credential
required
:
false
required
:
false
status
:
type
:
string
required
:
false
constraints
:
-
valid_values
:
[
"
fresh"
,
"
running"
,
"
deleted"
,
"
failed"
,
"
stopped"
]
interfaces
:
interfaces
:
CloudsStorm
:
CloudsStorm
:
type
:
tosca.interfaces.ARTICONF.CloudsStorm
type
:
tosca.interfaces.ARTICONF.CloudsStorm
...
...
commons/pom.xml
View file @
2bbc0d82
...
@@ -144,6 +144,12 @@
...
@@ -144,6 +144,12 @@
<version>
1.25
</version>
<version>
1.25
</version>
<type>
jar
</type>
<type>
jar
</type>
</dependency>
</dependency>
<dependency>
<groupId>
com.jcraft
</groupId>
<artifactId>
jsch
</artifactId>
<version>
0.1.54
</version>
<type>
jar
</type>
</dependency>
</dependencies>
</dependencies>
...
...
commons/src/main/java/nl/uva/sne/drip/commons/utils/Converter.java
View file @
2bbc0d82
...
@@ -60,7 +60,7 @@ public class Converter {
...
@@ -60,7 +60,7 @@ public class Converter {
}
}
public
static
String
encodeFileToBase64Binary
(
String
fileName
)
throws
IOException
{
public
static
String
encodeFileToBase64Binary
(
String
fileName
)
throws
IOException
{
return
encode2Bas64
(
Files
.
readAllBytes
(
Paths
.
get
(
fileName
)));
return
encode2Bas
e
64
(
Files
.
readAllBytes
(
Paths
.
get
(
fileName
)));
}
}
public
static
void
decodeBase64BToFile
(
String
base64
,
String
fileName
)
throws
IOException
{
public
static
void
decodeBase64BToFile
(
String
base64
,
String
fileName
)
throws
IOException
{
...
@@ -82,11 +82,11 @@ public class Converter {
...
@@ -82,11 +82,11 @@ public class Converter {
String
name
=
System
.
currentTimeMillis
()
+
"_"
+
originalFileName
;
String
name
=
System
.
currentTimeMillis
()
+
"_"
+
originalFileName
;
byte
[]
bytes
=
file
.
getBytes
();
byte
[]
bytes
=
file
.
getBytes
();
return
encode2Bas64
(
bytes
);
return
encode2Bas
e
64
(
bytes
);
}
}
private
static
String
encode2Bas64
(
byte
[]
bytes
)
{
private
static
String
encode2Bas
e
64
(
byte
[]
bytes
)
{
byte
[]
encodedBytes
=
Base64
.
getEncoder
().
encode
(
bytes
);
byte
[]
encodedBytes
=
Base64
.
getEncoder
().
encode
(
bytes
);
return
new
String
(
encodedBytes
,
StandardCharsets
.
UTF_8
);
return
new
String
(
encodedBytes
,
StandardCharsets
.
UTF_8
);
...
...
commons/src/main/java/nl/uva/sne/drip/commons/utils/ToscaHelper.java
View file @
2bbc0d82
...
@@ -21,11 +21,15 @@ import com.fasterxml.jackson.databind.ObjectMapper;
...
@@ -21,11 +21,15 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import
com.fasterxml.jackson.databind.SerializationFeature
;
import
com.fasterxml.jackson.databind.SerializationFeature
;
import
com.fasterxml.jackson.dataformat.yaml.YAMLFactory
;
import
com.fasterxml.jackson.dataformat.yaml.YAMLFactory
;
import
com.fasterxml.jackson.dataformat.yaml.YAMLGenerator
;
import
com.fasterxml.jackson.dataformat.yaml.YAMLGenerator
;
import
com.jcraft.jsch.JSch
;
import
com.jcraft.jsch.JSchException
;
import
com.jcraft.jsch.KeyPair
;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.net.HttpURLConnection
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Base64
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -43,6 +47,7 @@ import nl.uva.sne.drip.sure.tosca.client.ApiException;
...
@@ -43,6 +47,7 @@ import nl.uva.sne.drip.sure.tosca.client.ApiException;
import
nl.uva.sne.drip.sure.tosca.client.Configuration
;
import
nl.uva.sne.drip.sure.tosca.client.Configuration
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
static
nl
.
uva
.
sne
.
drip
.
commons
.
utils
.
Constatnts
.*;
import
static
nl
.
uva
.
sne
.
drip
.
commons
.
utils
.
Constatnts
.*;
import
nl.uva.sne.drip.model.cloud.storm.CloudsStormSubTopology.StatusEnum
;
/**
/**
*
*
...
@@ -57,7 +62,7 @@ public class ToscaHelper {
...
@@ -57,7 +62,7 @@ public class ToscaHelper {
private
Integer
id
;
private
Integer
id
;
public
static
enum
NODE_STATES
{
public
static
enum
NODE_STATES
{
PROVISION
,
DELETE
,
START
,
STOP
,
H_SCALE
,
V_SCALE
,
CONFIGURE
DELETED
,
STARTED
,
STOPPED
,
H_SCALED
,
V_SCALED
,
CONFIGURED
,
RUNNING
,
FAILED
}
}
@Autowired
@Autowired
...
@@ -251,7 +256,7 @@ public class ToscaHelper {
...
@@ -251,7 +256,7 @@ public class ToscaHelper {
return
toscaCredential
;
return
toscaCredential
;
}
else
{
}
else
{
throw
new
Exc
eption
(
"NodeTemplate is not of type: "
+
VM_TOPOLOGY
+
" it is of type: "
+
vmTopology
.
getType
());
throw
new
TypeEx
eption
(
"NodeTemplate is not of type: "
+
VM_TOPOLOGY
+
" it is of type: "
+
vmTopology
.
getType
());
}
}
}
}
...
@@ -296,7 +301,10 @@ public class ToscaHelper {
...
@@ -296,7 +301,10 @@ public class ToscaHelper {
public
NODE_STATES
getNodeCurrentState
(
NodeTemplateMap
node
)
{
public
NODE_STATES
getNodeCurrentState
(
NodeTemplateMap
node
)
{
return
getNodeState
(
node
,
"current_state"
);
return
getNodeState
(
node
,
"current_state"
);
}
public
NodeTemplateMap
setNodeCurrentState
(
NodeTemplateMap
node
,
NODE_STATES
nodeState
)
{
return
setNodeState
(
node
,
"current_state"
,
nodeState
);
}
}
public
NodeTemplateMap
setNodeDesiredState
(
NodeTemplateMap
node
,
NODE_STATES
nodeState
)
{
public
NodeTemplateMap
setNodeDesiredState
(
NodeTemplateMap
node
,
NODE_STATES
nodeState
)
{
...
@@ -325,4 +333,34 @@ public class ToscaHelper {
...
@@ -325,4 +333,34 @@ public class ToscaHelper {
return
node
;
return
node
;
}
}
public
static
NODE_STATES
cloudStormStatus2NodeState
(
StatusEnum
cloudStormStatus
)
{
if
(
cloudStormStatus
.
equals
(
StatusEnum
.
FRESH
)){
return
null
;
}
String
cloudStormStatusStr
=
cloudStormStatus
.
toString
().
toUpperCase
();
return
NODE_STATES
.
valueOf
(
cloudStormStatusStr
);
}
public
KeyPair
getKeyPairsFromVM
(
NodeTemplate
vmMap
)
throws
ApiException
,
TypeExeption
,
JSchException
{
if
(
vmMap
.
getType
().
equals
(
VM_TYPE
))
{
Map
<
String
,
Object
>
attributes
=
vmMap
.
getAttributes
();
if
(
attributes
!=
null
&&
attributes
.
containsKey
(
"user_key_pair"
))
{
Map
<
String
,
Object
>
userKeyPair
=
(
Map
<
String
,
Object
>)
attributes
.
get
(
"user_key_pair"
);
if
(
userKeyPair
.
containsKey
(
"protocol"
)
&&
userKeyPair
.
get
(
"protocol"
).
equals
(
"ssh"
))
{
Map
<
String
,
Object
>
keysMap
=
(
Map
<
String
,
Object
>)
userKeyPair
.
get
(
"keys"
);
JSch
jsch
=
new
JSch
();
byte
[]
privatekeyBytes
=
Base64
.
getDecoder
().
decode
(((
String
)
keysMap
.
get
(
"private_key"
)));
byte
[]
publicKeyBytes
=
Base64
.
getDecoder
().
decode
(((
String
)
keysMap
.
get
(
"public_key"
)));
KeyPair
keyPair
=
KeyPair
.
load
(
jsch
,
privatekeyBytes
,
publicKeyBytes
);
keyPair
.
dispose
();
return
keyPair
;
}
}
}
else
{
throw
new
TypeExeption
(
"NodeTemplate is not of type: "
+
VM_TYPE
+
" it is of type: "
+
vmMap
.
getType
());
}
return
null
;
}
}
}
commons/src/test/java/nl/uva/sne/drip/commons/utils/ToscaHelperTest.java
View file @
2bbc0d82
...
@@ -20,6 +20,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
...
@@ -20,6 +20,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.dataformat.yaml.YAMLFactory
;
import
com.fasterxml.jackson.dataformat.yaml.YAMLFactory
;
import
com.fasterxml.jackson.dataformat.yaml.YAMLGenerator
;
import
com.fasterxml.jackson.dataformat.yaml.YAMLGenerator
;
import
com.jcraft.jsch.KeyPair
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
...
@@ -439,4 +440,44 @@ public class ToscaHelperTest {
...
@@ -439,4 +440,44 @@ public class ToscaHelperTest {
}
}
/**
* Test of getKeyPairsFromVM method, of class ToscaHelper.
*/
@Test
public
void
testGetKeyPairsFromVM
()
throws
Exception
{
System
.
out
.
println
(
"getKeyPairsFromVM"
);
instance
.
uploadToscaTemplate
(
provisionedToscaTemplate
);
KeyPair
keyPair
;
List
<
NodeTemplateMap
>
vmTopologyTemplatesMap
=
instance
.
getVMTopologyTemplates
();
assertNotNull
(
vmTopologyTemplatesMap
);
for
(
NodeTemplateMap
nodeTemplateMap
:
vmTopologyTemplatesMap
)
{
assertNotNull
(
nodeTemplateMap
);
List
<
NodeTemplateMap
>
vmTemplatesMap
=
instance
.
getTemplateVMsForVMTopology
(
nodeTemplateMap
);
assertNotNull
(
vmTemplatesMap
);
for
(
NodeTemplateMap
vmMap
:
vmTemplatesMap
)
{
assertNotNull
(
vmMap
);
assertNotNull
(
vmMap
.
getNodeTemplate
());
keyPair
=
instance
.
getKeyPairsFromVM
(
vmMap
.
getNodeTemplate
());
assertNotNull
(
keyPair
);
}
}
}
/**
* Test of cloudStormStatus2NodeState method, of class ToscaHelper.
*/
@Test
public
void
testCloudStormStatus2NodeState
()
{
System
.
out
.
println
(
"cloudStormStatus2NodeState"
);
for
(
CloudsStormSubTopology
.
StatusEnum
value
:
CloudsStormSubTopology
.
StatusEnum
.
values
())
{
ToscaHelper
.
NODE_STATES
result
=
ToscaHelper
.
cloudStormStatus2NodeState
(
value
);
if
(
value
.
equals
(
CloudsStormSubTopology
.
StatusEnum
.
FRESH
))
{
assertNull
(
result
);
}
else
{
assertEquals
(
value
.
toString
().
toUpperCase
(),
result
.
toString
().
toUpperCase
());
}
}
}
}
}
deployer/test/test_deployer.py
View file @
2bbc0d82
...
@@ -28,10 +28,10 @@ class TestDeployer(unittest.TestCase):
...
@@ -28,10 +28,10 @@ class TestDeployer(unittest.TestCase):
def
test
(
self
):
def
test
(
self
):
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
tosca_path
=
"../../
TOSCA
/"
tosca_path
=
"../../
example_messages
/"
input_tosca_file_path
=
tosca_path
+
'/message_example_provisioned.json'
input_tosca_file_path
=
tosca_path
+
'/message_example_provisioned.json'
if
not
os
.
path
.
exists
(
input_tosca_file_path
):
if
not
os
.
path
.
exists
(
input_tosca_file_path
):
tosca_path
=
"../
TOSCA
/"
tosca_path
=
"../
example_messages
/"
input_tosca_file_path
=
tosca_path
+
'/message_example_provisioned.json'
input_tosca_file_path
=
tosca_path
+
'/message_example_provisioned.json'
with
open
(
input_tosca_file_path
,
'r'
)
as
stream
:
with
open
(
input_tosca_file_path
,
'r'
)
as
stream
:
...
...
TOSCA
/message_example_provisioned.json
→
example_messages
/message_example_provisioned.json
View file @
2bbc0d82
File moved
example_messages/message_provision_request.json
0 → 100644
View file @
2bbc0d82
{
"owner"
:
"user"
,
"creationDate"
:
1584616813246
,
"toscaTemplate"
:{
"tosca_definitions_version"
:
"tosca_simple_yaml_1_0"
,
"tosca_default_namespace"
:
null
,
"template_name"
:
null
,
"topology_template"
:{
"description"
:
null
,
"inputs"
:
null
,
"node_templates"
:{
"compute"
:{
"properties"
:{
"disk_size"
:
"10000 MB"
,
"mem_size"
:
"1000 MB"
,
"num_cores"
:
1
,
"os"
:
"Ubuntu 18.04"
,
"user_name"
:
"vm_user"
},
"interfaces"
:{
"Standard"
:{
"create"
:
"dumy.yaml"
}},
"type"
:
"tosca.nodes.ARTICONF.VM.Compute"
},
"compute_1"
:{
"properties"
:{
"disk_size"
:
"10000 MB"
,
"mem_size"
:
"1000 MB"
,
"num_cores"
:
1
,
"os"
:
"Ubuntu 18.04"
,
"user_name"
:
"vm_user"
},
"interfaces"
:{
"Standard"
:{
"create"
:
"dumy.yaml"
}},
"type"
:
"tosca.nodes.ARTICONF.VM.Compute"
},
"kubernetes"
:{
"requirements"
:[{
"host"
:{
"capability"
:
"tosca.capabilities.ARTICONF.VM.topology"
,
"node"
:
"topology"
,
"relationship"
:
"tosca.relationships.HostedOn"
}}],
"interfaces"
:{
"Kubernetes"
:{
"configure"
:{
"inputs"
:{
"playbook"
:
"https://raw.githubusercontent.com/skoulouzis/CONF/develop/ansible_playbooks/dashboard.yaml"
}},
"create"
:{
"inputs"
:{
"playbook"
:
"https://raw.githubusercontent.com/skoulouzis/CONF/develop/ansible_playbooks/create_k8s.yml"
}},
"install"
:{
"inputs"
:{
"playbook"
:
"https://raw.githubusercontent.com/skoulouzis/CONF/develop/ansible_playbooks/install_k8s.yml"
}}}},
"type"
:
"tosca.nodes.ARTICONF.docker.Orchestrator.Kubernetes"
},
"topology"
:{
"properties"
:{
"domain"
:
"Frankfurt"
,
"provider"
:
"EC2"
},
"requirements"
:[{
"vm"
:{
"capability"
:
"tosca.capabilities.ARTICONF.VM"
,
"node"
:
"compute"
,
"relationship"
:
"tosca.relationships.DependsOn"
}},{
"vm"
:{
"capability"
:
"tosca.capabilities.ARTICONF.VM"
,
"node"
:
"compute_1"
,
"relationship"
:
"tosca.relationships.DependsOn"
}}],
"interfaces"
:{
"CloudsStorm"
:{
"delete"
:{
"inputs"
:{
"code_type"
:
"SEQ"
,
"object_type"
:
"SubTopology"
}},
"hscale"
:{
"inputs"
:{
"code_type"
:
"SEQ"
,
"object_type"
:
"SubTopology"
}},
"provision"
:{
"inputs"
:{
"code_type"
:
"SEQ"
,
"object_type"
:
"SubTopology"
}},
"start"
:{
"inputs"
:{
"code_type"
:
"SEQ"
,
"object_type"
:
"SubTopology"
}},
"stop"
:{
"inputs"
:{
"code_type"
:
"SEQ"
,
"object_type"
:
"SubTopology"
}}}},
"type"
:
"tosca.nodes.ARTICONF.VM.topology"
,
"attributes"
:{
"credential"
:{
"cloud_provider_name"
:
"EC2"
,
"keys"
:{
"aws_access_key_id"
:
"XXXXXXXXXXXXXXXXXXX"
},
"token"
:
"XXXXXXXXXXXXXXX"
,
"token_type"
:
"access_key"
},
"desired_state"
:
"PROVISION"
}},
"ws-pema"
:{
"properties"
:{
"ports"
:[
"30001:8080"
]},
"requirements"
:[{
"host"
:{
"capability"
:
"tosca.capabilities.ARTICONF.docker.Orchestrator"
,
"node"
:
"kubernetes"
,
"relationship"
:
"tosca.relationships.HostedOn"
}}],
"type"
:
"tosca.nodes.ARTICONF.Container.Application.Docker"
,
"artifacts"
:{
"image"
:{
"file"
:
"alogo53/ws-pema-lifewatch"
,
"repository"
:
"docker_hub"
,
"type"
:
"tosca.artifacts.Deployment.Image.Container.Docker"
}}}},
"relationship_templates"
:
null
,
"outputs"
:
null
,
"groups"
:
null
,
"substitution_mappings"
:
null
,
"policies"
:
null
},
"template_author"
:
null
,
"template_version"
:
null
,
"description"
:
"TOSCA example"
,
"imports"
:[{
"nodes"
:
"https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/nodes.yaml"
},{
"data"
:
"https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/data.yml"
},{
"capabilities"
:
"https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/capabilities.yaml"
},{
"policies"
:
"https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/policies.yaml"
},{
"interfaces"
:
"https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/interfaces.yml"
}],
"dsl_definitions"
:
null
,
"node_types"
:
null
,
"relationship_types"
:
null
,
"relationship_templates"
:
null
,
"capability_types"
:
null
,
"artifact_types"
:
null
,
"data_types"
:
null
,
"interface_types"
:
null
,
"policy_types"
:
null
,
"group_types"
:
null
,
"repositories"
:
null
}}
manager/src/main/java/nl/uva/sne/drip/service/DRIPService.java
View file @
2bbc0d82
...
@@ -117,7 +117,7 @@ public class DRIPService {
...
@@ -117,7 +117,7 @@ public class DRIPService {
if
(
vmTopologies
==
null
||
vmTopologies
.
isEmpty
())
{
if
(
vmTopologies
==
null
||
vmTopologies
.
isEmpty
())
{
throw
new
MissingVMTopologyException
(
"ToscaTemplate: "
+
toscaTemplate
+
" has no VM Topologies"
);
throw
new
MissingVMTopologyException
(
"ToscaTemplate: "
+
toscaTemplate
+
" has no VM Topologies"
);
}
}
toscaTemplate
=
setDesieredSate
(
toscaTemplate
,
vmTopologies
,
NODE_STATES
.
PROVISION
);
toscaTemplate
=
setDesieredSate
(
toscaTemplate
,
vmTopologies
,
NODE_STATES
.
RUNNING
);
return
execute
(
toscaTemplate
,
provisionerQueueName
);
return
execute
(
toscaTemplate
,
provisionerQueueName
);
}
}
...
@@ -162,7 +162,7 @@ public class DRIPService {
...
@@ -162,7 +162,7 @@ public class DRIPService {
for
(
NodeTemplateMap
vmTopology
:
vmTopologies
)
{
for
(
NodeTemplateMap
vmTopology
:
vmTopologies
)
{
CloudsStormSubTopology
.
StatusEnum
status
=
helper
.
getVMTopologyTemplateStatus
(
vmTopology
);
CloudsStormSubTopology
.
StatusEnum
status
=
helper
.
getVMTopologyTemplateStatus
(
vmTopology
);
if
(!
status
.
equals
(
CloudsStormSubTopology
.
StatusEnum
.
DELETED
))
{
if
(!
status
.
equals
(
CloudsStormSubTopology
.
StatusEnum
.
DELETED
))
{
toscaTemplate
=
setDesieredSate
(
toscaTemplate
,
vmTopologies
,
NODE_STATES
.
DELETE
);
toscaTemplate
=
setDesieredSate
(
toscaTemplate
,
vmTopologies
,
NODE_STATES
.
DELETE
D
);
}
}
}
}
return
execute
(
toscaTemplate
,
provisionerQueueName
);
return
execute
(
toscaTemplate
,
provisionerQueueName
);
...
...
manager/src/test/java/nl/uva/sne/drip/service/ServiceTests.java
View file @
2bbc0d82
...
@@ -434,7 +434,7 @@ public class ServiceTests {
...
@@ -434,7 +434,7 @@ public class ServiceTests {
Assert
.
assertTrue
(
attributes
.
containsKey
(
"credential"
));
Assert
.
assertTrue
(
attributes
.
containsKey
(
"credential"
));
assertNotNull
(
attributes
.
get
(
"credential"
));
assertNotNull
(
attributes
.
get
(
"credential"
));
}
}
toscaTemplate
=
dripService
.
setDesieredSate
(
toscaTemplate
,
vmTopologies
,
ToscaHelper
.
NODE_STATES
.
PROVISION
);
toscaTemplate
=
dripService
.
setDesieredSate
(
toscaTemplate
,
vmTopologies
,
ToscaHelper
.
NODE_STATES
.
RUNNING
);
Map
<
String
,
NodeTemplate
>
nodes
=
toscaTemplate
.
getTopologyTemplate
().
getNodeTemplates
();
Map
<
String
,
NodeTemplate
>
nodes
=
toscaTemplate
.
getTopologyTemplate
().
getNodeTemplates
();
Set
<
String
>
names
=
nodes
.
keySet
();
Set
<
String
>
names
=
nodes
.
keySet
();
for
(
String
name
:
names
)
{
for
(
String
name
:
names
)
{
...
...
provisioner/src/main/java/nl/uva/sne/drip/provisioner/CloudStormService.java
View file @
2bbc0d82
This diff is collapsed.
Click to expand it.
provisioner/src/main/java/nl/uva/sne/drip/provisioner/RPCServer.java
View file @
2bbc0d82
...
@@ -35,45 +35,43 @@ import java.util.logging.Logger;
...
@@ -35,45 +35,43 @@ import java.util.logging.Logger;
*/
*/
public
class
RPCServer
{
public
class
RPCServer
{
private
static
Properties
prop
;
/**
* @return the prop
public
static
void
main
(
String
[]
argv
)
throws
MalformedURLException
{
*/
prop
=
new
Properties
();
public
static
Properties
getProp
()
{
if
(
argv
.
length
>=
1
)
{
return
prop
;
try
{
prop
.
load
(
new
FileInputStream
(
argv
[
0
]));
}
catch
(
IOException
ex
)
{
Logger
.
getLogger
(
RPCServer
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
else
{
String
resourceName
=
"application.properties"
;
ClassLoader
loader
=
Thread
.
currentThread
().
getContextClassLoader
();
try
(
InputStream
resourceStream
=
loader
.
getResourceAsStream
(
resourceName
))
{
prop
.
load
(
resourceStream
);
}
catch
(
IOException
ex
)
{
Logger
.
getLogger
(
RPCServer
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
/**
* @param aProp the prop to set
*/
public
static
void
setProp
(
Properties
aProp
)
{
prop
=
aProp
;
}
}
private
static
Properties
prop
;
public
static
void
main
(
String
[]
argv
)
throws
MalformedURLException
{
init
(
argv
);
start
();
start
();
}
}
private
static
void
start
()
{
private
static
void
start
()
{
ConnectionFactory
factory
=
new
ConnectionFactory
();
ConnectionFactory
factory
=
new
ConnectionFactory
();
factory
.
setHost
(
prop
.
getProperty
(
"message.broker.host"
));
factory
.
setHost
(
getProp
()
.
getProperty
(
"message.broker.host"
));
factory
.
setPassword
(
prop
.
getProperty
(
"message.broker.username"
));
factory
.
setPassword
(
getProp
()
.
getProperty
(
"message.broker.username"
));
factory
.
setUsername
(
prop
.
getProperty
(
"message.broker.password"
));
factory
.
setUsername
(
getProp
()
.
getProperty
(
"message.broker.password"
));
factory
.
setPort
(
AMQP
.
PROTOCOL
.
PORT
);
factory
.
setPort
(
AMQP
.
PROTOCOL
.
PORT
);
Logger
.
getLogger
(
RPCServer
.
class
.
getName
()).
log
(
Level
.
INFO
,
"Connected to: {0}"
,
prop
.
getProperty
(
"message.broker.host"
));
Logger
.
getLogger
(
RPCServer
.
class
.
getName
()).
log
(
Level
.
INFO
,
"Connected to: {0}"
,
getProp
()
.
getProperty
(
"message.broker.host"
));
try
(
Connection
connection
=
factory
.
newConnection
())
{
try
(
Connection
connection
=
factory
.
newConnection
())
{
Channel
channel
=
connection
.
createChannel
();
Channel
channel
=
connection
.
createChannel
();
//We define the queue name
//We define the queue name
channel
.
queueDeclare
(
prop
.
getProperty
(
"message.broker.queue.provisioner"
,
"provisioner"
),
false
,
false
,
false
,
null
);
channel
.
queueDeclare
(
getProp
()
.
getProperty
(
"message.broker.queue.provisioner"
,
"provisioner"
),
false
,
false
,
false
,
null
);
DefaultConsumer
c
;
DefaultConsumer
c
;
c
=
new
nl
.
uva
.
sne
.
drip
.
provisioner
.
Consumer
(
channel
,
prop
);
c
=
new
nl
.
uva
.
sne
.
drip
.
provisioner
.
Consumer
(
channel
,
getProp
()
);
//Start listening for messages
//Start listening for messages
channel
.
basicConsume
(
prop
.
getProperty
(
"message.broker.queue.provisioner"
,
"provisioner"
),
false
,
c
);
channel
.
basicConsume
(
getProp
()
.
getProperty
(
"message.broker.queue.provisioner"
,
"provisioner"
),
false
,
c
);
//Block so we don't close the channel
//Block so we don't close the channel
while
(
true
)
{
while
(
true
)
{
...
@@ -92,4 +90,23 @@ public class RPCServer {
...
@@ -92,4 +90,23 @@ public class RPCServer {
}
}
public
static
void
init
(
String
[]
argv
)
{
setProp
(
new
Properties
());
if
(
argv
.
length
>=
1
)
{
try
{
getProp
().
load
(
new
FileInputStream
(
argv
[
0
]));
}
catch
(
IOException
ex
)
{
Logger
.
getLogger
(
RPCServer
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
else
{
String
resourceName
=
"application.properties"
;
ClassLoader
loader
=
Thread
.
currentThread
().
getContextClassLoader
();
try
(
InputStream
resourceStream
=
loader
.
getResourceAsStream
(
resourceName
))
{
getProp
().
load
(
resourceStream
);
}
catch
(
IOException
ex
)
{
Logger
.
getLogger
(
RPCServer
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
}
}
}
provisioner/src/test/java/nl/uva/sne/drip/provisioner/CloudStormServiceTest.java
0 → 100644
View file @
2bbc0d82
This diff is collapsed.
Click to expand it.
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