Commit b40b08cf authored by Spiros Koulouzis's avatar Spiros Koulouzis

change message to dbg and always close the rabbit connection if exception

parent cddca1c6
......@@ -71,43 +71,43 @@ services:
- "8082:8082"
mongoclient:
image: 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
#mongoclient:
#image: mongoclient/mongoclient
#environment:
#RABBITMQ_HOST: rabbit
#MONGO_HOST: mongo
#SURE_TOSCA_BASE_PATH: http://sure-tosca:8081/tosca-sure/1.0.0
#CREDENTIAL_SECRET: top_secret
#- MONGO_URL=mongodb://mongo:27017
#- ROOT_URL=http://mongoclient/mongoclient
#depends_on:
#- mongo
#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:
image: qcdis/sure-tosca
ports:
- "8081:8081"
planner:
depends_on:
- rabbit
- sure-tosca
image: qcdis/planner
environment:
RABBITMQ_HOST: rabbit
#planner:
#depends_on:
#- rabbit
#- sure-tosca
#image: qcdis/planner
#environment:
#RABBITMQ_HOST: rabbit
provisioner:
depends_on:
......@@ -120,26 +120,24 @@ services:
CLOUD_STORM_SECRET: 456
CREDENTIAL_SECRET: top_secret
#deployer:
#depends_on:
#- rabbit
#- sure-tosca
#image: qcdis/deployer
#environment:
#RABBITMQ_HOST: rabbit
#SURE_TOSCA_BASE_PATH: http://sure-tosca:8081/tosca-sure/1.0.0
#SEMAPHORE_BASE_PATH: http://semaphore:3000/api
deployer:
depends_on:
- rabbit
- sure-tosca
image: qcdis/deployer
environment:
RABBITMQ_HOST: rabbit
SURE_TOSCA_BASE_PATH: http://sure-tosca:8081/tosca-sure/1.0.0
SEMAPHORE_BASE_PATH: http://semaphore:3000/api
cadvisor:
image: google/cadvisor
ports:
- "8083:8081"
image: gcr.io/google-containers/cadvisor:latest
ports:
- 8083:8080
volumes:
- '/:/rootfs:ro'
- '/var/run:/var/run:rw'
- '/sys:/sys:ro'
- '/var/lib/docker/:/var/lib/docker:ro'
- /:/rootfs:ro
- /var/run:/var/run:rw
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
......@@ -58,19 +58,28 @@ public class DRIPService {
@Value("${message.broker.queue.deployer}")
private String deployerQueueName;
private String execute(ToscaTemplate toscaTemplate, String requestQeueName) throws JsonProcessingException, ApiException, IOException, TimeoutException, InterruptedException {
caller.init();
Logger.getLogger(DRIPService.class.getName()).log(Level.INFO, "toscaTemplate:\n{0}", toscaTemplate);
Message message = new Message();
message.setOwner("user");
message.setCreationDate(System.currentTimeMillis());
message.setToscaTemplate(toscaTemplate);
caller.setRequestQeueName(requestQeueName);
Message response = caller.call(message);
ToscaTemplate updatedToscaTemplate = response.getToscaTemplate();
caller.close();
return toscaTemplateService.save(updatedToscaTemplate);
private String execute(ToscaTemplate toscaTemplate, String requestQeueName) throws IOException, TimeoutException, InterruptedException{
try {
caller.init();
Logger.getLogger(DRIPService.class.getName()).log(Level.INFO, "toscaTemplate:\n{0}", toscaTemplate);
Message message = new Message();
message.setOwner("user");
message.setCreationDate(System.currentTimeMillis());
message.setToscaTemplate(toscaTemplate);
caller.setRequestQeueName(requestQeueName);
Message response = caller.call(message);
ToscaTemplate updatedToscaTemplate = response.getToscaTemplate();
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);
}
}
}
......
......@@ -108,7 +108,7 @@ def handle_delivery(message, sys=None):
template_dict = tosca_helper.get_tosca_template_2_topology_template_dictionary(tosca_template)
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}
output_current_milli_time = int(round(time.time() * 1000))
......
......@@ -62,7 +62,7 @@ class Planner:
self.tosca_template = ToscaTemplate(tosca_path)
elif 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_node_types = self.tosca_template.nodetemplates[0].type_definition.TOSCA_DEF
......@@ -81,7 +81,7 @@ class Planner:
return self.tosca_template
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,
self.all_custom_def)
default_properties = {}
......@@ -113,7 +113,7 @@ class Planner:
default_properties[prop_name] = node.templates[node_name]['properties'][prop_name][
'default']
logger.info(
logger.debug(
'Adding to : ' + str(node.templates[node_name]) + ' properties: ' + str(default_properties))
node.templates[node_name]['properties'] = default_properties
return node
......@@ -165,9 +165,9 @@ class Planner:
def add_required_nodes(self, node):
"""Adds the required nodes in self.required_nodes for an input node."""
if isinstance(node, NodeTemplate):
logger.info('Resolving requirements for: ' + node.name)
logger.debug('Resolving requirements for: ' + node.name)
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.
all_requirements = self.get_all_requirements(node)
if not all_requirements:
......@@ -188,7 +188,7 @@ class Planner:
break
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):
logger.info(' Adding: ' + str(matching_node_template.name))
logger.debug(' Adding: ' + str(matching_node_template.name))
self.required_nodes.append(matching_node)
# Find matching nodes for the new node's requirements
self.add_required_nodes(matching_node)
......@@ -197,13 +197,13 @@ class Planner:
"""Returns all requirements for an input node including all parents requirements"""
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
def_type = self.all_node_types[node_type_name]
all_requirements = []
if 'requirements' in def_type.keys():
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
# node_requirements = tosca_helper.get_node_requirements(node)
......@@ -214,7 +214,7 @@ class Planner:
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)
if parent_type and parent_requirements:
logger.info(
logger.debug(
' Adding to : ' + str(node_type_name) + ' parent requirements from: ' + str(parent_type))
if not all_requirements:
all_requirements += parent_requirements
......@@ -270,7 +270,7 @@ class Planner:
if 'capability' in req[key]:
capability = req[key]['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)
if not capable_nodes:
logger.error('Did not find any node with required capability: ' + str(capability))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment