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

renamed types and added glusterfs test

parent c2921364
......@@ -257,8 +257,11 @@ class Planner:
number_of_matching_requirement = {}
# Loop requirements to find nodes per requirement
for req in all_requirements:
if 'capability' in req[next(iter(req))]:
capability = req[next(iter(req))]['capability']
key = next(iter(req))
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
logger.info(' Looking for nodes in node types with capability: ' + capability)
capable_nodes = self.get_node_types_by_capability(capability)
......
......@@ -30,26 +30,33 @@ class SimpleAnalyzer(SpecificationAnalyzer):
def set_relationship_occurrences(self):
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.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
if orchestrator_nodes:
if 'properties' in orchestrator_nodes[0].entity_tpl:
if 'min_masters_num' in orchestrator_nodes[0].entity_tpl['properties']:
min_masters_num = orchestrator_nodes[0].entity_tpl['properties']['min_masters_num']
if 'min_workers_num' in orchestrator_nodes[0].entity_tpl['properties']:
workers_num = orchestrator_nodes[0].entity_tpl['properties']['min_workers_num']
else:
min_masters_num = orchestrator_nodes[0].get_property_value('min_masters_num')
workers_num = orchestrator_nodes[0].get_property_value('min_workers_num')
topology_nodes = tosca_helper.get_nodes_by_type('tosca.nodes.ARTICONF.VM.topology',
if nodes_with_min_vms:
for node_with_min_vms in nodes_with_min_vms:
if 'properties' in node_with_min_vms.entity_tpl:
if 'min_masters_num' in node_with_min_vms.entity_tpl['properties']:
min_masters_num = min_masters_num + node_with_min_vms.entity_tpl['properties'][
'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:
min_masters_num = min_masters_num + node_with_min_vms.get_property_value('min_masters_num')
workers_num = workers_num + node_with_min_vms.get_property_value('min_workers_num')
if min_masters_num < 0:
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.all_custom_def)
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.all_custom_def)
if vm_nodes:
......@@ -65,7 +72,7 @@ class SimpleAnalyzer(SpecificationAnalyzer):
for requirement in topology_nodes[0].requirements:
requirement_key = next(iter(requirement))
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[requirement_key]['node'] = new_vm.name
topology_nodes[0].requirements.append(new_requirement)
......@@ -84,7 +91,7 @@ class SimpleAnalyzer(SpecificationAnalyzer):
for requirement in topology_nodes[0].requirements:
requirement_key = next(iter(requirement))
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[requirement_key]['node'] = new_vm.name
topology_nodes[0].requirements.append(new_requirement)
......
......@@ -6,7 +6,7 @@ import os.path
import tempfile
import time
import unittest
import requests
import yaml
from toscaparser.tosca_template import ToscaTemplate
......@@ -20,36 +20,45 @@ logger.setLevel(logging.DEBUG)
class MyTestCase(unittest.TestCase):
def test_docker(self):
file_name = 'application_example_updated.yaml'
input_tosca_file_path = self.get_input_tosca_file_path(file_name)
self.run_test(input_tosca_file_path)
file_name = 'lifeWatch_vre1.yaml'
input_tosca_file_path = self.get_input_tosca_file_path(file_name)
def test_tic_gluster_fs(self):
url = 'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/TIC.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 test_kubernetes(self):
file_name = 'kubernetes.yaml'
input_tosca_file_path = self.get_input_tosca_file_path(file_name)
self.run_test(input_tosca_file_path)
def test_topology(self):
file_name = 'topology.yaml'
input_tosca_file_path = self.get_input_tosca_file_path(file_name)
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):
file_name = 'lifeWatch_vre1.yaml'
input_tosca_file_path = self.get_input_tosca_file_path(file_name)
self.run_test(input_tosca_file_path)
# def test_docker(self):
# file_name = 'application_example_updated.yaml'
# input_tosca_file_path = self.get_input_tosca_file_path(file_name)
# self.run_test(input_tosca_file_path)
#
# file_name = 'lifeWatch_vre1.yaml'
# input_tosca_file_path = self.get_input_tosca_file_path(file_name)
# self.run_test(input_tosca_file_path)
#
#
# def test_kubernetes(self):
# file_name = 'kubernetes.yaml'
# input_tosca_file_path = self.get_input_tosca_file_path(file_name)
# self.run_test(input_tosca_file_path)
#
# def test_topology(self):
# file_name = 'topology.yaml'
# input_tosca_file_path = self.get_input_tosca_file_path(file_name)
# 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):
tosca_path = "../../TOSCA/"
......
......@@ -121,8 +121,8 @@ def node_type_2_node_template(node_type, all_custom_def):
node_type[next(iter(node_type))].pop('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
# manually. We get 'toscaparser.common.exception.InvalidTypeError: Type "tosca.nodes.ARTICONF.docker.Orchestrator"
# 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.capabilities.QC.docker.Orchestrator"
# is not a valid type.'
if len(node_template.custom_def) < len(all_custom_def):
for def_key in all_custom_def:
......@@ -273,7 +273,7 @@ def get_node_template_dict(node_template):
def get_node_type_interfaces(node):
node_type_interfaces = node.type_definition.interfaces
node_type_interfaces = node.type_definition.interfaces
return node_type_interfaces
......@@ -282,6 +282,6 @@ def get_node_template_interfaces(node):
return node_template_interfaces
def add_interfaces(node,node_type_interfaces):
def add_interfaces(node, node_type_interfaces):
# node.interfaces = node_type_interfaces
return node
\ No newline at end of file
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