Commit 0d49ba8c authored by Spiros Koulouzis's avatar Spiros Koulouzis

renamed types and added glusterfs test

parent c2921364
...@@ -257,8 +257,11 @@ class Planner: ...@@ -257,8 +257,11 @@ class Planner:
number_of_matching_requirement = {} number_of_matching_requirement = {}
# Loop requirements to find nodes per requirement # Loop requirements to find nodes per requirement
for req in all_requirements: for req in all_requirements:
if 'capability' in req[next(iter(req))]: key = next(iter(req))
capability = req[next(iter(req))]['capability'] if not req[key]:
raise Exception('Requirement: '+str(req)+ ' is not properly defined')
if 'capability' in req[key]:
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.info(' 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)
......
...@@ -30,26 +30,33 @@ class SimpleAnalyzer(SpecificationAnalyzer): ...@@ -30,26 +30,33 @@ class SimpleAnalyzer(SpecificationAnalyzer):
def set_relationship_occurrences(self): def set_relationship_occurrences(self):
return_nodes = [] return_nodes = []
orchestrator_nodes = tosca_helper.get_nodes_by_type('tosca.nodes.ARTICONF.docker.Orchestrator', nodes_with_min_vms = tosca_helper.get_nodes_by_type('tosca.nodes.QC.docker.Orchestrator',
self.tosca_template.nodetemplates, self.all_node_types, self.tosca_template.nodetemplates, self.all_node_types,
self.all_custom_def) self.all_custom_def)
min_masters_num = 1 nodes_with_min_vms = nodes_with_min_vms + tosca_helper.get_nodes_by_type('tosca.nodes.QC.Application.GlusterFS',
self.tosca_template.nodetemplates,
self.all_node_types,
self.all_custom_def)
min_masters_num = 0
workers_num = 0 workers_num = 0
if orchestrator_nodes: if nodes_with_min_vms:
if 'properties' in orchestrator_nodes[0].entity_tpl: for node_with_min_vms in nodes_with_min_vms:
if 'min_masters_num' in orchestrator_nodes[0].entity_tpl['properties']: if 'properties' in node_with_min_vms.entity_tpl:
min_masters_num = orchestrator_nodes[0].entity_tpl['properties']['min_masters_num'] if 'min_masters_num' in node_with_min_vms.entity_tpl['properties']:
if 'min_workers_num' in orchestrator_nodes[0].entity_tpl['properties']: min_masters_num = min_masters_num + node_with_min_vms.entity_tpl['properties'][
workers_num = orchestrator_nodes[0].entity_tpl['properties']['min_workers_num'] 'min_masters_num']
if 'min_workers_num' in node_with_min_vms.entity_tpl['properties']:
workers_num = workers_num + node_with_min_vms.entity_tpl['properties']['min_workers_num']
else: else:
min_masters_num = orchestrator_nodes[0].get_property_value('min_masters_num') min_masters_num = min_masters_num + node_with_min_vms.get_property_value('min_masters_num')
workers_num = orchestrator_nodes[0].get_property_value('min_workers_num') workers_num = workers_num + node_with_min_vms.get_property_value('min_workers_num')
if min_masters_num < 0:
topology_nodes = tosca_helper.get_nodes_by_type('tosca.nodes.ARTICONF.VM.topology', min_masters_num = 1
topology_nodes = tosca_helper.get_nodes_by_type('tosca.nodes.QC.VM.topology',
self.tosca_template.nodetemplates, self.all_node_types, self.tosca_template.nodetemplates, self.all_node_types,
self.all_custom_def) self.all_custom_def)
if topology_nodes: if topology_nodes:
vm_nodes = tosca_helper.get_nodes_by_type('tosca.nodes.ARTICONF.VM.Compute', vm_nodes = tosca_helper.get_nodes_by_type('tosca.nodes.QC.VM.Compute',
self.tosca_template.nodetemplates, self.all_node_types, self.tosca_template.nodetemplates, self.all_node_types,
self.all_custom_def) self.all_custom_def)
if vm_nodes: if vm_nodes:
...@@ -65,7 +72,7 @@ class SimpleAnalyzer(SpecificationAnalyzer): ...@@ -65,7 +72,7 @@ class SimpleAnalyzer(SpecificationAnalyzer):
for requirement in topology_nodes[0].requirements: for requirement in topology_nodes[0].requirements:
requirement_key = next(iter(requirement)) requirement_key = next(iter(requirement))
requirement_value = requirement[requirement_key] requirement_value = requirement[requirement_key]
if requirement_value['capability'] == 'tosca.capabilities.ARTICONF.VM': if requirement_value['capability'] == 'tosca.capabilities.QC.VM':
new_requirement = copy.deepcopy(requirement) new_requirement = copy.deepcopy(requirement)
new_requirement[requirement_key]['node'] = new_vm.name new_requirement[requirement_key]['node'] = new_vm.name
topology_nodes[0].requirements.append(new_requirement) topology_nodes[0].requirements.append(new_requirement)
...@@ -84,7 +91,7 @@ class SimpleAnalyzer(SpecificationAnalyzer): ...@@ -84,7 +91,7 @@ class SimpleAnalyzer(SpecificationAnalyzer):
for requirement in topology_nodes[0].requirements: for requirement in topology_nodes[0].requirements:
requirement_key = next(iter(requirement)) requirement_key = next(iter(requirement))
requirement_value = requirement[requirement_key] requirement_value = requirement[requirement_key]
if requirement_value['capability'] == 'tosca.capabilities.ARTICONF.VM': if requirement_value['capability'] == 'tosca.capabilities.QC.VM':
new_requirement = copy.deepcopy(requirement) new_requirement = copy.deepcopy(requirement)
new_requirement[requirement_key]['node'] = new_vm.name new_requirement[requirement_key]['node'] = new_vm.name
topology_nodes[0].requirements.append(new_requirement) topology_nodes[0].requirements.append(new_requirement)
......
...@@ -6,7 +6,7 @@ import os.path ...@@ -6,7 +6,7 @@ import os.path
import tempfile import tempfile
import time import time
import unittest import unittest
import requests
import yaml import yaml
from toscaparser.tosca_template import ToscaTemplate from toscaparser.tosca_template import ToscaTemplate
...@@ -20,36 +20,45 @@ logger.setLevel(logging.DEBUG) ...@@ -20,36 +20,45 @@ logger.setLevel(logging.DEBUG)
class MyTestCase(unittest.TestCase): class MyTestCase(unittest.TestCase):
def test_docker(self): def test_tic_gluster_fs(self):
file_name = 'application_example_updated.yaml' url = 'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/TIC.yaml'
input_tosca_file_path = self.get_input_tosca_file_path(file_name) tic_tosca = requests.get(url)
self.run_test(input_tosca_file_path) input_tosca_file_path = os.path.join(tempfile.gettempdir(),'TIC.yaml')
open( input_tosca_file_path, 'wb').write(tic_tosca.content)
file_name = 'lifeWatch_vre1.yaml'
input_tosca_file_path = self.get_input_tosca_file_path(file_name)
self.run_test(input_tosca_file_path) self.run_test(input_tosca_file_path)
def test_kubernetes(self): # def test_docker(self):
file_name = 'kubernetes.yaml' # file_name = 'application_example_updated.yaml'
input_tosca_file_path = self.get_input_tosca_file_path(file_name) # input_tosca_file_path = self.get_input_tosca_file_path(file_name)
self.run_test(input_tosca_file_path) # self.run_test(input_tosca_file_path)
#
def test_topology(self): # file_name = 'lifeWatch_vre1.yaml'
file_name = 'topology.yaml' # input_tosca_file_path = self.get_input_tosca_file_path(file_name)
input_tosca_file_path = self.get_input_tosca_file_path(file_name) # self.run_test(input_tosca_file_path)
self.run_test(input_tosca_file_path) #
#
def test_compute(self): # def test_kubernetes(self):
file_name = 'compute.yaml' # file_name = 'kubernetes.yaml'
input_tosca_file_path = self.get_input_tosca_file_path(file_name) # input_tosca_file_path = self.get_input_tosca_file_path(file_name)
self.run_test(input_tosca_file_path) # self.run_test(input_tosca_file_path)
#
def test_lifeWatch(self): # def test_topology(self):
file_name = 'lifeWatch_vre1.yaml' # file_name = 'topology.yaml'
input_tosca_file_path = self.get_input_tosca_file_path(file_name) # input_tosca_file_path = self.get_input_tosca_file_path(file_name)
self.run_test(input_tosca_file_path) # self.run_test(input_tosca_file_path)
#
# def test_compute(self):
# file_name = 'compute.yaml'
# input_tosca_file_path = self.get_input_tosca_file_path(file_name)
# self.run_test(input_tosca_file_path)
#
# def test_lifeWatch(self):
# url = 'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/lifeWatch_vre1.yaml'
# tic_tosca = requests.get(url)
# input_tosca_file_path = os.path.join(tempfile.gettempdir(),'TIC.yaml')
# open( input_tosca_file_path, 'wb').write(tic_tosca.content)
# self.run_test(input_tosca_file_path)
def get_input_tosca_file_path(self, file_name): def get_input_tosca_file_path(self, file_name):
tosca_path = "../../TOSCA/" tosca_path = "../../TOSCA/"
......
...@@ -121,8 +121,8 @@ def node_type_2_node_template(node_type, all_custom_def): ...@@ -121,8 +121,8 @@ def node_type_2_node_template(node_type, all_custom_def):
node_type[next(iter(node_type))].pop('type') node_type[next(iter(node_type))].pop('type')
node_template = NodeTemplate(name, node_template_dict, node_type) node_template = NodeTemplate(name, node_template_dict, node_type)
# For some reason the tosca.nodes.ARTICONF.docker.Orchestrator doesn't have all definitions so we need to add them # For some reason the tosca.capabilities.QC.docker.Orchestrator doesn't have all definitions so we need to add them
# manually. We get 'toscaparser.common.exception.InvalidTypeError: Type "tosca.nodes.ARTICONF.docker.Orchestrator" # manually. We get 'toscaparser.common.exception.InvalidTypeError: Type "tosca.capabilities.QC.docker.Orchestrator"
# is not a valid type.' # is not a valid type.'
if len(node_template.custom_def) < len(all_custom_def): if len(node_template.custom_def) < len(all_custom_def):
for def_key in all_custom_def: for def_key in all_custom_def:
...@@ -282,6 +282,6 @@ def get_node_template_interfaces(node): ...@@ -282,6 +282,6 @@ def get_node_template_interfaces(node):
return node_template_interfaces return node_template_interfaces
def add_interfaces(node,node_type_interfaces): def add_interfaces(node, node_type_interfaces):
# node.interfaces = node_type_interfaces # node.interfaces = node_type_interfaces
return node return node
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