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
b40b08cf
Commit
b40b08cf
authored
Sep 21, 2020
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change message to dbg and always close the rabbit connection if exception
parent
cddca1c6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
72 deletions
+79
-72
docker-compose.yml
docker-compose/docker-compose.yml
+46
-48
DRIPService.java
...er/src/main/java/nl/uva/sne/drip/service/DRIPService.java
+22
-13
__main__.py
planner/__main__.py
+1
-1
planner.py
planner/planner/planner.py
+10
-10
No files found.
docker-compose/docker-compose.yml
View file @
b40b08cf
...
@@ -71,43 +71,43 @@ services:
...
@@ -71,43 +71,43 @@ services:
-
"
8082:8082"
-
"
8082:8082"
mongoclient
:
#mongoclient:
image
:
mongoclient
#image: mongoclient/mongoclient
environment
:
-
MONGO_URL=mongodb://mongo:27017
-
ROOT_URL=/mongoclient
depends_on
:
-
mongo
ports
:
-
"
3001:3000"
#manager:
#depends_on:
#- rabbit
#- mongo
#- sure-tosca
#image: qcdis/manager
#environment:
#environment:
#RABBITMQ_HOST: rabbit
#- MONGO_URL=mongodb://mongo:27017
#MONGO_HOST: mongo
#- ROOT_URL=http://mongoclient/mongoclient
#SURE_TOSCA_BASE_PATH: http://sure-tosca:8081/tosca-sure/1.0.0
#depends_on:
#CREDENTIAL_SECRET: top_secret
#- mongo
#ports:
#ports:
#- "8080:8080"
#- "3001:3000"
manager
:
depends_on
:
-
rabbit
-
mongo
-
sure-tosca
image
:
qcdis/manager
environment
:
RABBITMQ_HOST
:
rabbit
MONGO_HOST
:
mongo
SURE_TOSCA_BASE_PATH
:
http://sure-tosca:8081/tosca-sure/1.0.0
CREDENTIAL_SECRET
:
top_secret
ports
:
-
"
8080:8080"
sure-tosca
:
sure-tosca
:
image
:
qcdis/sure-tosca
image
:
qcdis/sure-tosca
ports
:
ports
:
-
"
8081:8081"
-
"
8081:8081"
planner
:
#
planner:
depends_on
:
#
depends_on:
-
rabbit
#
- rabbit
-
sure-tosca
#
- sure-tosca
image
:
qcdis/planner
#
image: qcdis/planner
environment
:
#
environment:
RABBITMQ_HOST
:
rabbit
#
RABBITMQ_HOST: rabbit
provisioner
:
provisioner
:
depends_on
:
depends_on
:
...
@@ -120,26 +120,24 @@ services:
...
@@ -120,26 +120,24 @@ services:
CLOUD_STORM_SECRET
:
456
CLOUD_STORM_SECRET
:
456
CREDENTIAL_SECRET
:
top_secret
CREDENTIAL_SECRET
:
top_secret
#deployer:
deployer
:
#depends_on:
depends_on
:
#- rabbit
-
rabbit
#- sure-tosca
-
sure-tosca
#image: qcdis/deployer
image
:
qcdis/deployer
#environment:
environment
:
#RABBITMQ_HOST: rabbit
RABBITMQ_HOST
:
rabbit
#SURE_TOSCA_BASE_PATH: http://sure-tosca:8081/tosca-sure/1.0.0
SURE_TOSCA_BASE_PATH
:
http://sure-tosca:8081/tosca-sure/1.0.0
#SEMAPHORE_BASE_PATH: http://semaphore:3000/api
SEMAPHORE_BASE_PATH
:
http://semaphore:3000/api
cadvisor
:
cadvisor
:
image
:
g
oogle/cadvisor
image
:
g
cr.io/google-containers/cadvisor:latest
ports
:
ports
:
-
"
8083:8081"
-
8083:8080
volumes
:
volumes
:
-
'
/:/rootfs:ro'
-
/:/rootfs:ro
-
'
/var/run:/var/run:rw'
-
/var/run:/var/run:rw
-
'
/sys:/sys:ro'
-
/sys:/sys:ro
-
'
/var/lib/docker/:/var/lib/docker:ro'
-
/var/lib/docker/:/var/lib/docker:ro
manager/src/main/java/nl/uva/sne/drip/service/DRIPService.java
View file @
b40b08cf
...
@@ -58,19 +58,28 @@ public class DRIPService {
...
@@ -58,19 +58,28 @@ public class DRIPService {
@Value
(
"${message.broker.queue.deployer}"
)
@Value
(
"${message.broker.queue.deployer}"
)
private
String
deployerQueueName
;
private
String
deployerQueueName
;
private
String
execute
(
ToscaTemplate
toscaTemplate
,
String
requestQeueName
)
throws
JsonProcessingException
,
ApiException
,
IOException
,
TimeoutException
,
InterruptedException
{
private
String
execute
(
ToscaTemplate
toscaTemplate
,
String
requestQeueName
)
throws
IOException
,
TimeoutException
,
InterruptedException
{
caller
.
init
();
try
{
Logger
.
getLogger
(
DRIPService
.
class
.
getName
()).
log
(
Level
.
INFO
,
"toscaTemplate:\n{0}"
,
toscaTemplate
);
caller
.
init
();
Message
message
=
new
Message
();
Logger
.
getLogger
(
DRIPService
.
class
.
getName
()).
log
(
Level
.
INFO
,
"toscaTemplate:\n{0}"
,
toscaTemplate
);
message
.
setOwner
(
"user"
);
Message
message
=
new
Message
();
message
.
setCreationDate
(
System
.
currentTimeMillis
());
message
.
setOwner
(
"user"
);
message
.
setToscaTemplate
(
toscaTemplate
);
message
.
setCreationDate
(
System
.
currentTimeMillis
());
message
.
setToscaTemplate
(
toscaTemplate
);
caller
.
setRequestQeueName
(
requestQeueName
);
Message
response
=
caller
.
call
(
message
);
caller
.
setRequestQeueName
(
requestQeueName
);
ToscaTemplate
updatedToscaTemplate
=
response
.
getToscaTemplate
();
Message
response
=
caller
.
call
(
message
);
caller
.
close
();
ToscaTemplate
updatedToscaTemplate
=
response
.
getToscaTemplate
();
return
toscaTemplateService
.
save
(
updatedToscaTemplate
);
return
toscaTemplateService
.
save
(
updatedToscaTemplate
);
}
catch
(
IOException
|
TimeoutException
|
InterruptedException
ex
)
{
throw
ex
;
}
finally
{
try
{
caller
.
close
();
}
catch
(
IOException
|
TimeoutException
ex
)
{
Logger
.
getLogger
(
DRIPService
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
}
}
...
...
planner/__main__.py
View file @
b40b08cf
...
@@ -108,7 +108,7 @@ def handle_delivery(message, sys=None):
...
@@ -108,7 +108,7 @@ def handle_delivery(message, sys=None):
template_dict
=
tosca_helper
.
get_tosca_template_2_topology_template_dictionary
(
tosca_template
)
template_dict
=
tosca_helper
.
get_tosca_template_2_topology_template_dictionary
(
tosca_template
)
Planner
(
yaml_dict_tpl
=
template_dict
,
spec_service
=
spec_service
)
Planner
(
yaml_dict_tpl
=
template_dict
,
spec_service
=
spec_service
)
logger
.
info
(
"template ----:
\n
"
+
yaml
.
dump
(
template_dict
))
logger
.
debug
(
"template ----:
\n
"
+
yaml
.
dump
(
template_dict
))
response
=
{
'toscaTemplate'
:
template_dict
}
response
=
{
'toscaTemplate'
:
template_dict
}
output_current_milli_time
=
int
(
round
(
time
.
time
()
*
1000
))
output_current_milli_time
=
int
(
round
(
time
.
time
()
*
1000
))
...
...
planner/planner/planner.py
View file @
b40b08cf
...
@@ -62,7 +62,7 @@ class Planner:
...
@@ -62,7 +62,7 @@ class Planner:
self
.
tosca_template
=
ToscaTemplate
(
tosca_path
)
self
.
tosca_template
=
ToscaTemplate
(
tosca_path
)
elif
yaml_dict_tpl
:
elif
yaml_dict_tpl
:
self
.
yaml_dict_tpl
=
yaml_dict_tpl
self
.
yaml_dict_tpl
=
yaml_dict_tpl
logger
.
info
(
'yaml_dict_tpl:
\n
'
+
str
(
yaml
.
dump
(
yaml_dict_tpl
)))
logger
.
debug
(
'yaml_dict_tpl:
\n
'
+
str
(
yaml
.
dump
(
yaml_dict_tpl
)))
self
.
tosca_template
=
ToscaTemplate
(
yaml_dict_tpl
=
yaml_dict_tpl
)
self
.
tosca_template
=
ToscaTemplate
(
yaml_dict_tpl
=
yaml_dict_tpl
)
self
.
tosca_node_types
=
self
.
tosca_template
.
nodetemplates
[
0
]
.
type_definition
.
TOSCA_DEF
self
.
tosca_node_types
=
self
.
tosca_template
.
nodetemplates
[
0
]
.
type_definition
.
TOSCA_DEF
...
@@ -81,7 +81,7 @@ class Planner:
...
@@ -81,7 +81,7 @@ class Planner:
return
self
.
tosca_template
return
self
.
tosca_template
def
set_default_node_properties
(
self
,
node
):
def
set_default_node_properties
(
self
,
node
):
logger
.
info
(
'Setting properties for: '
+
str
(
node
.
type
))
logger
.
debug
(
'Setting properties for: '
+
str
(
node
.
type
))
ancestors_properties
=
tosca_helper
.
get_all_ancestors_properties
(
node
,
self
.
all_node_types
,
ancestors_properties
=
tosca_helper
.
get_all_ancestors_properties
(
node
,
self
.
all_node_types
,
self
.
all_custom_def
)
self
.
all_custom_def
)
default_properties
=
{}
default_properties
=
{}
...
@@ -113,7 +113,7 @@ class Planner:
...
@@ -113,7 +113,7 @@ class Planner:
default_properties
[
prop_name
]
=
node
.
templates
[
node_name
][
'properties'
][
prop_name
][
default_properties
[
prop_name
]
=
node
.
templates
[
node_name
][
'properties'
][
prop_name
][
'default'
]
'default'
]
logger
.
info
(
logger
.
debug
(
'Adding to : '
+
str
(
node
.
templates
[
node_name
])
+
' properties: '
+
str
(
default_properties
))
'Adding to : '
+
str
(
node
.
templates
[
node_name
])
+
' properties: '
+
str
(
default_properties
))
node
.
templates
[
node_name
][
'properties'
]
=
default_properties
node
.
templates
[
node_name
][
'properties'
]
=
default_properties
return
node
return
node
...
@@ -165,9 +165,9 @@ class Planner:
...
@@ -165,9 +165,9 @@ class Planner:
def
add_required_nodes
(
self
,
node
):
def
add_required_nodes
(
self
,
node
):
"""Adds the required nodes in self.required_nodes for an input node."""
"""Adds the required nodes in self.required_nodes for an input node."""
if
isinstance
(
node
,
NodeTemplate
):
if
isinstance
(
node
,
NodeTemplate
):
logger
.
info
(
'Resolving requirements for: '
+
node
.
name
)
logger
.
debug
(
'Resolving requirements for: '
+
node
.
name
)
elif
isinstance
(
node
,
dict
):
elif
isinstance
(
node
,
dict
):
logger
.
info
(
'Resolving requirements for: '
+
str
(
next
(
iter
(
node
))))
logger
.
debug
(
'Resolving requirements for: '
+
str
(
next
(
iter
(
node
))))
# Get all requirements for node.
# Get all requirements for node.
all_requirements
=
self
.
get_all_requirements
(
node
)
all_requirements
=
self
.
get_all_requirements
(
node
)
if
not
all_requirements
:
if
not
all_requirements
:
...
@@ -188,7 +188,7 @@ class Planner:
...
@@ -188,7 +188,7 @@ class Planner:
break
break
if
not
tosca_helper
.
contains_node_type
(
self
.
required_nodes
,
matching_node_type_name
)
and
\
if
not
tosca_helper
.
contains_node_type
(
self
.
required_nodes
,
matching_node_type_name
)
and
\
not
tosca_helper
.
contains_node_type
(
self
.
tosca_template
.
nodetemplates
,
matching_node_type_name
):
not
tosca_helper
.
contains_node_type
(
self
.
tosca_template
.
nodetemplates
,
matching_node_type_name
):
logger
.
info
(
' Adding: '
+
str
(
matching_node_template
.
name
))
logger
.
debug
(
' Adding: '
+
str
(
matching_node_template
.
name
))
self
.
required_nodes
.
append
(
matching_node
)
self
.
required_nodes
.
append
(
matching_node
)
# Find matching nodes for the new node's requirements
# Find matching nodes for the new node's requirements
self
.
add_required_nodes
(
matching_node
)
self
.
add_required_nodes
(
matching_node
)
...
@@ -197,13 +197,13 @@ class Planner:
...
@@ -197,13 +197,13 @@ class Planner:
"""Returns all requirements for an input node including all parents requirements"""
"""Returns all requirements for an input node including all parents requirements"""
node_type_name
=
tosca_helper
.
get_node_type_name
(
node
)
node_type_name
=
tosca_helper
.
get_node_type_name
(
node
)
logger
.
info
(
' Looking for requirements for node: '
+
node_type_name
)
logger
.
debug
(
' Looking for requirements for node: '
+
node_type_name
)
# Get the requirements for this node from its definition e.g. docker: hostedOn k8s
# Get the requirements for this node from its definition e.g. docker: hostedOn k8s
def_type
=
self
.
all_node_types
[
node_type_name
]
def_type
=
self
.
all_node_types
[
node_type_name
]
all_requirements
=
[]
all_requirements
=
[]
if
'requirements'
in
def_type
.
keys
():
if
'requirements'
in
def_type
.
keys
():
all_requirements
=
def_type
[
'requirements'
]
all_requirements
=
def_type
[
'requirements'
]
logger
.
info
(
' Found requirements: '
+
str
(
all_requirements
)
+
' for node: '
+
node_type_name
)
logger
.
debug
(
' Found requirements: '
+
str
(
all_requirements
)
+
' for node: '
+
node_type_name
)
# Get the requirements for this node from the template. e.g. wordpress: connectsTo mysql
# Get the requirements for this node from the template. e.g. wordpress: connectsTo mysql
# node_requirements = tosca_helper.get_node_requirements(node)
# node_requirements = tosca_helper.get_node_requirements(node)
...
@@ -214,7 +214,7 @@ class Planner:
...
@@ -214,7 +214,7 @@ class Planner:
parent_requirements
=
tosca_helper
.
get_ancestors_requirements
(
node
,
self
.
all_node_types
,
self
.
all_custom_def
)
parent_requirements
=
tosca_helper
.
get_ancestors_requirements
(
node
,
self
.
all_node_types
,
self
.
all_custom_def
)
parent_type
=
tosca_helper
.
get_node_type_name
(
node
)
parent_type
=
tosca_helper
.
get_node_type_name
(
node
)
if
parent_type
and
parent_requirements
:
if
parent_type
and
parent_requirements
:
logger
.
info
(
logger
.
debug
(
' Adding to : '
+
str
(
node_type_name
)
+
' parent requirements from: '
+
str
(
parent_type
))
' Adding to : '
+
str
(
node_type_name
)
+
' parent requirements from: '
+
str
(
parent_type
))
if
not
all_requirements
:
if
not
all_requirements
:
all_requirements
+=
parent_requirements
all_requirements
+=
parent_requirements
...
@@ -270,7 +270,7 @@ class Planner:
...
@@ -270,7 +270,7 @@ class Planner:
if
'capability'
in
req
[
key
]:
if
'capability'
in
req
[
key
]:
capability
=
req
[
key
][
'capability'
]
capability
=
req
[
key
][
'capability'
]
# Find all nodes in the definitions that have the capability: capability
# Find all nodes in the definitions that have the capability: capability
logger
.
info
(
' Looking for nodes in node types with capability: '
+
capability
)
logger
.
debug
(
' Looking for nodes in node types with capability: '
+
capability
)
capable_nodes
=
self
.
get_node_types_by_capability
(
capability
)
capable_nodes
=
self
.
get_node_types_by_capability
(
capability
)
if
not
capable_nodes
:
if
not
capable_nodes
:
logger
.
error
(
'Did not find any node with required capability: '
+
str
(
capability
))
logger
.
error
(
'Did not find any node with required capability: '
+
str
(
capability
))
...
...
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