Commit 08010adf authored by Spiros Koulouzis's avatar Spiros Koulouzis

tests

parent fcddcef3
tosca_definitions_version: tosca_simple_yaml_1_0
description: TOSCA template
topology_template:
node_templates:
compute:
properties:
disk_size: "120 GB"
mem_size: "7 GB"
num_cores: 4
os: Ubuntu 18.04
user_name: vm_user
interfaces:
Standard:
create: dumy.yaml
type: tosca.nodes.QC.VM.Compute
compute_1:
properties:
disk_size: "120 GB"
mem_size: "7 GB"
num_cores: 4
os: Ubuntu 18.04
user_name: vm_user
interfaces:
Standard:
create: dumy.yaml
type: tosca.nodes.QC.VM.Compute
topology:
properties:
domain: Ireland
provider: EC2
requirements:
- vm:
capability: tosca.capabilities.QC.VM
node: compute
relationship: tosca.relationships.DependsOn
- vm:
capability: tosca.capabilities.QC.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.QC.VM.topology
artifacts:
provisioned_files:
required: false
type: "string"
imports:
- nodes: https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/nodes.yaml
- data: https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/data.yml
- capabilities: https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/capabilities.yaml
- policies: https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/policies.yaml
- interfaces: https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/interfaces.yml
tosca_definitions_version: tosca_simple_yaml_1_0
description: TOSCA template
topology_template:
node_templates:
compute:
properties:
disk_size: "40 GB"
mem_size: "17500 MB"
num_cores: 2
os: Ubuntu 18.04
user_name: vm_user
interfaces:
Standard:
create: dumy.yaml
type: tosca.nodes.QC.VM.Compute
compute_1:
properties:
disk_size: "40 GB"
mem_size: "17500 MB"
num_cores: 2
os: Ubuntu 18.04
user_name: vm_user
interfaces:
Standard:
create: dumy.yaml
type: tosca.nodes.QC.VM.Compute
topology:
properties:
domain: Ireland
provider: EC2
requirements:
- vm:
capability: tosca.capabilities.QC.VM
node: compute
relationship: tosca.relationships.DependsOn
- vm:
capability: tosca.capabilities.QC.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.QC.VM.topology
artifacts:
provisioned_files:
required: false
type: "string"
imports:
- nodes: https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/nodes.yaml
- data: https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/data.yml
- capabilities: https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/capabilities.yaml
- policies: https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/policies.yaml
- interfaces: https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/interfaces.yml
tosca_definitions_version: "tosca_simple_yaml_1_0"
topology_template:
node_templates:
compute:
properties:
disk_size: "120 GB"
mem_size: "7 GB"
num_cores: 4
os: "Ubuntu 18.04"
user_name: "vm_user"
interfaces:
Standard:
create: dumy.yaml
type: tosca.nodes.QC.VM.Compute
#compute_1:
#properties:
#disk_size: "40000 MB"
#mem_size: "1000 MB"
#num_cores: 1
#os: "Ubuntu 18.04"
#user_name: "vm_user"
#interfaces:
#Standard:
#create: "dumy.yaml"
#type: "tosca.nodes.QC.VM.Compute"
topology:
properties:
domain: "Ireland"
provider: "EC2"
requirements:
#- vm:
#capability: "tosca.capabilities.QC.VM"
#node: "compute"
#relationship: "tosca.relationships.DependsOn"
- vm:
capability: "tosca.capabilities.QC.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.QC.VM.topology"
artifacts:
provisioned_files:
required: false
type: "string"
description: "TOSCA example"
imports:
- nodes: "https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/nodes.yaml"
- data: "https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/data.yml"
- capabilities: "https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/capabilities.yaml"
- policies: "https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/policies.yaml"
- interfaces: "https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/interfaces.yml"
tosca_definitions_version: tosca_simple_yaml_1_0
topology_template:
node_templates:
compute:
properties:
num_cores: 2
disk_size: 20 GB
mem_size: 4098 MB
os: Ubuntu 18.04
user_name: vm_user
interfaces:
Standard:
create: dumy.yaml
type: tosca.nodes.QC.VM.Compute
topology:
properties:
domain: Iraland
provider: EC2
requirements:
- vm:
capability: tosca.capabilities.QC.VM
node: compute
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.QC.VM.topology
description: TOSCA template
imports:
- nodes: https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/nodes.yaml
- data: https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/data.yml
- capabilities: https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/capabilities.yaml
- policies: https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/policies.yaml
- interfaces: https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/interfaces.yml
#!/bin/bash
TOSCA_ID="5f8eb46c8ff9431bd55e931a"
BASE_URL="https://fry.lab.uvalight.net:30001/manager/"
USERNAME=deploy_tester
PASSWORD=edvbafeabvafdb
#
# # curl -s -D - -k -u $USERNAME:$PASSWORD -X GET "$BASE_URL/tosca_template/$TOSCA_ID" &> tosca_output
# RESPONSE=`cat tosca_output | head -n 1 | cut '-d ' '-f2'`
#
# if [ $RESPONSE != "200" ];
# then
# cat tosca_output
# exit -1
# fi
# TOSCA_CONTENTS=`cat tosca_output | tail -n +11`
# echo $TOSCA_CONTENTS
#
#
# # curl -s -D - -k -u $USERNAME:$PASSWORD -X GET "$BASE_URL/provisioner/provision/$TOSCA_ID" &> provision_output
# RESPONSE=`cat provision_output | head -n 1 | cut '-d ' '-f2'`
#
# if [ $RESPONSE != "200" ];
# then
# cat provision_output
# exit -1
# fi
# PROVISION_ID=`cat provision_output | tail -n +11`
# PROVISION_ID=5f8ec0a68ff9431bd55e931e
# echo $PROVISION_ID
#
#
# curl -s -D - -k -u $USERNAME:$PASSWORD -X GET "$BASE_URL/deployer/deploy/$PROVISION_ID" &> deploy_output
# RESPONSE=`cat deploy_output | head -n 1 | cut '-d ' '-f2'`
#
# if [ $RESPONSE != "200" ];
# then
# cat deploy_output
# exit -1
# fi
# DEPLOY_ID=`cat deploy_output | tail -n +11`
# echo $DEPLOY_ID
#
# #
#
# # curl -u $USERNAME:$PASSWORD -X GET "$BASE_URL/tosca_template/$DEPLOY_ID"
# #
# # curl -u $USERNAME:$PASSWORD -X DELETE "$BASE_URL/tosca_template/$DEPLOY_ID"
#
#
......@@ -40,7 +40,7 @@ services:
#ipv4_address: 172.20.0.4
semaphore:
image: qcdis/docker_ansible_semaphore:2.4.1-2.9.9
image: ss
environment:
SEMAPHORE_DB_USER: semaphore
SEMAPHORE_DB_PASS: semaphore
......
......@@ -14,15 +14,15 @@ services:
rabbit:
image: rabbitmq:3.8-management
ports:
ports:
- "5671-5672:5671-5672"
- "15672:15672"
- "4369:4369"
- "15671:15671"
- "15671:15671"
mysql:
image: mysql:5.7
volumes:
volumes:
- ./mysql.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf
environment:
MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
......@@ -31,7 +31,7 @@ services:
MYSQL_PASSWORD: semaphore
#ports:
#- "3306:3306"
semaphore:
image: qcdis/docker_ansible_semaphore
environment:
......@@ -50,12 +50,12 @@ services:
- "3000:3000"
depends_on:
- mysql
mongo:
image: mongo:4
ports:
- "27017:27017"
- "27017:27017"
mongo-express:
image: mongo-express
environment:
......@@ -68,9 +68,9 @@ services:
depends_on:
- mongo
ports:
- "8082:8082"
- "8082:8082"
#mongoclient:
#image: mongoclient/mongoclient
#environment:
......@@ -79,57 +79,57 @@ services:
#depends_on:
#- mongo
#ports:
#- "3001:3000"
manager:
#- "3001:3000"
sdia-orchestrator:
depends_on:
- rabbit
- mongo
- sure-tosca
image: qcdis/manager
image: qcdis/sdia-orchestrator
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"
- "8080:8080"
sure-tosca:
image: qcdis/sure-tosca
ports:
ports:
- "8081:8081"
planner:
depends_on:
- rabbit
- sure-tosca
image: qcdis/planner
image: qcdis/planner
environment:
RABBITMQ_HOST: rabbit
provisioner:
depends_on:
- rabbit
- sure-tosca
image: qcdis/provisioner
image: qcdis/provisioner
environment:
RABBITMQ_HOST: rabbit
RABBITMQ_HOST: rabbit
SURE_TOSCA_BASE_PATH: http://sure-tosca:8081/tosca-sure/1.0.0
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: gcr.io/google-containers/cadvisor:latest
#ports:
......
......@@ -198,19 +198,19 @@
"description": "TOSCA example",
"imports": [
{
"nodes": "https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/types/nodes.yaml"
"nodes": "https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/nodes.yaml"
},
{
"data": "https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/types/data.yml"
"data": "https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/data.yml"
},
{
"capabilities": "https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/types/capabilities.yaml"
"capabilities": "https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/capabilities.yaml"
},
{
"policies": "https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/types/policies.yaml"
"policies": "https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/policies.yaml"
},
{
"interfaces": "https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/types/interfaces.yml"
"interfaces": "https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/interfaces.yml"
}
],
"dsl_definitions": null,
......
......@@ -362,11 +362,11 @@
" repository: \"docker_hub\"\n",
"description: \"TOSCA example\\n\"\n",
"imports:\n",
"- nodes: \"https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/types/nodes.yaml\"\n",
"- data: \"https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/types/data.yml\"\n",
"- capabilities: \"https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/types/capabilities.yaml\"\n",
"- policies: \"https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/types/policies.yaml\"\n",
"- interfaces: \"https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/types/interfaces.yml\"\n",
"- nodes: \"https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/nodes.yaml\"\n",
"- data: \"https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/data.yml\"\n",
"- capabilities: \"https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/capabilities.yaml\"\n",
"- policies: \"https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/policies.yaml\"\n",
"- interfaces: \"https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/types/interfaces.yml\"\n",
"repositories:\n",
" docker_hub: \"https://hub.docker.com/\"\n",
"\n"
......
......@@ -130,7 +130,7 @@ if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
if sys.argv[1] == "test_local":
tosca_path = "../TOSCA/"
input_tosca_file_path = tosca_path + '/application_example_updated.yaml'
input_tosca_file_path = tosca_path + '/generated_tosca_description_a8a061322c3b4b5593c289df841727af.yaml'
conf = {'url': "http://host"}
spec_service = SpecService(conf)
test_planner = Planner(input_tosca_file_path, spec_service)
......
This diff is collapsed.
import copy
from toscaparser.nodetemplate import NodeTemplate
from toscaparser.properties import Property
import networkx as nx
import logging
from service.specification_analyzer import SpecificationAnalyzer
from util import tosca_helper
def get_default_value(node_property):
if node_property and node_property.required and isinstance(node_property.value, dict) and 'required' in \
node_property.value and 'type' in node_property.value:
if node_property.default:
return {node_property.name: node_property.default}
if node_property.constraints:
for constraint in node_property.constraints:
print(constraint)
if node_property and node_property.required and node_property.value:
return {node_property.name: node_property.value}
return None
class SimpleAnalyzer(SpecificationAnalyzer):
def __init__(self, tosca_template):
super(SimpleAnalyzer, self).__init__(tosca_template)
def set_relationship_occurrences(self):
return_nodes = []
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)
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 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.QC.VM.Compute',
self.tosca_template.nodetemplates, self.all_node_types,
self.all_custom_def)
if vm_nodes:
for i in range(len(vm_nodes), min_masters_num):
old_vm_name = vm_nodes[0].name
new_vm = copy.deepcopy(vm_nodes[0])
new_vm_name = new_vm.name + '_' + str(i)
new_vm.name = new_vm_name
templates = new_vm.templates.pop(old_vm_name)
new_vm.templates[new_vm_name] = templates
return_nodes.append(new_vm)
for requirement in topology_nodes[0].requirements:
requirement_key = next(iter(requirement))
requirement_value = requirement[requirement_key]
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)
return_nodes.append(topology_nodes[0])
break
for i in range(len(vm_nodes), workers_num + 1):
old_vm_name = vm_nodes[0].name
new_vm = copy.deepcopy(vm_nodes[0])
new_vm_name = new_vm.name + '_' + str(i)
new_vm.name = new_vm_name
templates = new_vm.templates.pop(old_vm_name)
new_vm.templates[new_vm_name] = templates
return_nodes.append(new_vm)
for requirement in topology_nodes[0].requirements:
requirement_key = next(iter(requirement))
requirement_value = requirement[requirement_key]
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)
return_nodes.append(topology_nodes[0])
break
return return_nodes
def set_node_specifications(self):
nodes = []
for node_template in self.tosca_template.nodetemplates:
nodes.append(self.set_default_node_properties(node_template))
return nodes
# def set_default_node_properties(self, node):
# logging.info('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 = {}
# for ancestors_property in ancestors_properties:
# default_property = get_default_value(ancestors_property)
# if default_property:
# default_properties[next(iter(default_property))] = default_property[next(iter(default_property))]
#
# if default_properties:
# for default_property in default_properties:
# node.get_properties_objects().append(default_property)
# node_name = next(iter(node.templates))
# if 'properties' in node.templates[node_name]:
# for prop_name in node.templates[node_name]['properties']:
# if isinstance(node.templates[node_name]['properties'][prop_name], dict) or \
# isinstance(node.templates[node_name]['properties'][prop_name], str):
# if 'required' in node.templates[node_name]['properties'][prop_name] and \
# node.templates[node_name]['properties'][prop_name]['required'] and \
# 'default' in node.templates[node_name]['properties'][prop_name] and \
# prop_name not in default_properties:
# default_properties[prop_name] = node.templates[node_name]['properties'][prop_name][
# 'default']
#
# logging.info(
# 'Adding to : ' + str(node.templates[node_name]) + ' properties: ' + str(default_properties))
# node.templates[node_name]['properties'] = default_properties
# return node
class SpecService:
def __init__(self, conf):
self.configuration = conf
def get_property(self, prop_key):
return None
from abc import abstractmethod, ABCMeta
from toscaparser.tosca_template import ToscaTemplate
import networkx as nx
# import matplotlib.pyplot as plt
class SpecificationAnalyzer(metaclass=ABCMeta):
def __init__(self, tosca_template):
self.tosca_template = tosca_template
self.tosca_node_types = self.tosca_template.nodetemplates[0].type_definition.TOSCA_DEF
self.all_custom_def = self.tosca_template.nodetemplates[0].custom_def
self.all_node_types = {}
self.all_node_types.update(self.tosca_node_types.items())
self.all_node_types.update(self.all_custom_def.items())
self.required_nodes = []
self.g = self.build_graph(self.tosca_template.nodetemplates)
self.root_nodes = []
self.leaf_nodes = []
for node_name, degree in self.g.in_degree():
if degree == 0:
self.root_nodes.append(node_name)
for node_name, degree in self.g.out_degree():
if degree == 0:
self.leaf_nodes.append(node_name)
def build_graph(self, node_templates):
graph = nx.DiGraph()
for node in node_templates:
graph.add_node(node.name, attr_dict=node.entity_tpl)
for req in node.requirements:
req_name = next(iter(req))
req_node_name = req[req_name]['node']
if 'relationship' in req[req_name] and 'type' in req[req_name]['relationship']:
relationship_type = req[req_name]['relationship']['type']
else:
if 'relationship' not in req[req_name]:
relationship_type = 'tosca.relationships.DependsOn'
else:
relationship_type = req[req_name]['relationship']
graph.add_edge(node.name, req_node_name, relationship=relationship_type)
# nx.draw(graph, with_labels=True)
# plt.savefig("/tmp/graph.png")
# plt.show()
return graph
@abstractmethod
def set_node_specifications(self):
raise NotImplementedError('Must implement upload in subclasses')
@abstractmethod
def set_relationship_occurrences(self):
raise NotImplementedError('Must implement upload in subclasses')
import copy
import json
import logging
import os
import os.path
import tempfile
import time
import unittest
import requests
import yaml
from toscaparser.tosca_template import ToscaTemplate
from planner.planner import Planner
from service.spec_service import SpecService
from util import tosca_helper
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
class MyTestCase(unittest.TestCase):
# def test_tic_gluster_fs(self):
# url = 'https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/examples/glusterFS.yaml'
# input_tosca_file_path = self.get_remote_tosca_file(url)
# self.run_test(input_tosca_file_path)
def test_tic(self):
url = 'https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/examples/TIC.yaml'
input_tosca_file_path = self.get_remote_tosca_file(url)
self.run_test(input_tosca_file_path)
def test_docker(self):
url = 'https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/examples/application_example_updated.yaml'
input_tosca_file_path = self.get_remote_tosca_file(url)
self.run_test(input_tosca_file_path)
url = 'https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/examples/lifeWatch_vre1.yaml'
input_tosca_file_path = self.get_remote_tosca_file(url)
self.run_test(input_tosca_file_path)
def test_kubernetes(self):
url = 'https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/examples/kubernetes.yaml'
input_tosca_file_path = self.get_remote_tosca_file(url)
self.run_test(input_tosca_file_path)
def test_topology(self):
url = 'https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/examples/topology.yaml'
input_tosca_file_path = self.get_remote_tosca_file(url)
self.run_test(input_tosca_file_path)
def test_compute(self):
url = 'https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/examples/compute.yaml'
input_tosca_file_path = self.get_remote_tosca_file(url)
self.run_test(input_tosca_file_path)
def test_lifeWatch(self):
url = 'https://raw.githubusercontent.com/qcdis-sdia/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/"
input_tosca_file_path = tosca_path + file_name
if not os.path.exists(input_tosca_file_path):
tosca_path = "../TOSCA/"
input_tosca_file_path = tosca_path + file_name
self.assertEqual(True, os.path.exists(input_tosca_file_path),
"Input TOSCA file: " + input_tosca_file_path + " not found")
return input_tosca_file_path
def run_test(self, input_tosca_file_path):
conf = {'url': "http://host"}
spec_service = SpecService(conf)
test_planner = Planner(input_tosca_file_path, spec_service)
test_tosca_template = test_planner.resolve_requirements()
template_dict = tosca_helper.get_tosca_template_2_topology_template_dictionary(test_tosca_template)
test_tosca_template = test_planner.set_node_templates_properties()
template_dict = tosca_helper.get_tosca_template_2_topology_template_dictionary(test_tosca_template)
logger.info("template ----: \n" + yaml.dump(template_dict))
print(yaml.dump(template_dict))
ToscaTemplate(yaml_dict_tpl=copy.deepcopy(template_dict))
test_response = {'toscaTemplate': template_dict}
response = {'toscaTemplate': template_dict}
output_current_milli_time = int(round(time.time() * 1000))
response["creationDate"] = output_current_milli_time
response["parameters"] = []
# print("Output message:" + json.dumps(response))
self.assertEqual(True, True)
def get_remote_tosca_file(self, url):
tosca = requests.get(url)
input_tosca_file_path = os.path.join(tempfile.gettempdir(),'test_tosca_file.yaml')
open( input_tosca_file_path, 'wb').write(tosca.content)
return input_tosca_file_path
This diff is collapsed.
Metadata-Version: 1.0
Name: drip-planner2
Version: 0.1
Summary: UNKNOWN
Home-page: UNKNOWN
Author: S. Koulouzis
Author-email: UNKNOWN
License: UNKNOWN
Description: Long description of the package
Platform: UNKNOWN
setup.py
drip_planner2.egg-info/PKG-INFO
drip_planner2.egg-info/SOURCES.txt
drip_planner2.egg-info/dependency_links.txt
drip_planner2.egg-info/requires.txt
drip_planner2.egg-info/top_level.txt
planner/__init__.py
planner/planner.py
service/__init__.py
service/simple_spec_alayzer.py
service/spec_service.py
service/specification_analyzer.py
test/__init__.py
test/test_planner.py
util/__init__.py
util/tosca_helper.py
\ No newline at end of file
matplotlib==3.1.1
matplotlib==3.1.1
names==0.3.0
networkx==2.4
pika==1.1.0
tosca-parser==1.6.0
......@@ -3,5 +3,5 @@ pika==1.1.0
names==0.3.0
networkx==2.4
pyyaml==5.3.1
tosca-parser==2.0.0
tosca-parser==2.1.1
matplotlib==3.2.1
\ No newline at end of file
......@@ -20,46 +20,51 @@ logger.setLevel(logging.DEBUG)
class MyTestCase(unittest.TestCase):
def test_open_stack(self):
url = 'https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/examples/openstack.yaml'
input_tosca_file_path = self.get_remote_tosca_file(url)
self.run_test(input_tosca_file_path)
def test_tic_gluster_fs(self):
url = 'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/glusterFS.yaml'
url = 'https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/examples/glusterFS.yaml'
input_tosca_file_path = self.get_remote_tosca_file(url)
self.run_test(input_tosca_file_path)
def test_tic(self):
url = 'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/TIC.yaml'
url = 'https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/examples/TIC.yaml'
input_tosca_file_path = self.get_remote_tosca_file(url)
self.run_test(input_tosca_file_path)
def test_docker(self):
url = 'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/application_example_updated.yaml'
url = 'https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/examples/application_example_updated.yaml'
input_tosca_file_path = self.get_remote_tosca_file(url)
self.run_test(input_tosca_file_path)
url = 'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/lifeWatch_vre1.yaml'
url = 'https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/examples/lifeWatch_vre1.yaml'
input_tosca_file_path = self.get_remote_tosca_file(url)
self.run_test(input_tosca_file_path)
def test_kubernetes(self):
url = 'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/kubernetes.yaml'
url = 'https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/examples/kubernetes.yaml'
input_tosca_file_path = self.get_remote_tosca_file(url)
self.run_test(input_tosca_file_path)
def test_topology(self):
url = 'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/topology.yaml'
url = 'https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/examples/topology.yaml'
input_tosca_file_path = self.get_remote_tosca_file(url)
self.run_test(input_tosca_file_path)
def test_compute(self):
url = 'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/compute.yaml'
url = 'https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/examples/compute.yaml'
input_tosca_file_path = self.get_remote_tosca_file(url)
self.run_test(input_tosca_file_path)
def test_lifeWatch(self):
url = 'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/lifeWatch_vre1.yaml'
url = 'https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/examples/lifeWatch_vre1.yaml'
tic_tosca = requests.get(url)
input_tosca_file_path = os.path.join(tempfile.gettempdir(),'TIC.yaml')
input_tosca_file_path = os.path.join(tempfile.gettempdir(),'lifeWatch_vre1.yaml')
open( input_tosca_file_path, 'wb').write(tic_tosca.content)
self.run_test(input_tosca_file_path)
......
This diff is collapsed.
......@@ -2,7 +2,12 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="3f84153d-6ed1-4691-94d6-53105266f15e" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/../k8s/CONF/manager-deployment.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../k8s/CONF/manager-deployment.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../k8s/CONF/nginx-configmap.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../k8s/CONF/nginx-configmap.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../k8s/CONF/provisioner-deployment.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../k8s/CONF/provisioner-deployment.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/.idea/sure_tosca-flask-server.iml" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/.idea/sure_tosca-flask-server.iml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
......@@ -20,9 +25,14 @@
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/../../playbooks/install_nfs.yaml" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/../../sdia-tosca" />
<property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/../../sdia-tosca/examples" />
</key>
</component>
<component name="RunManager">
<configuration name="Unittests in test_default_api.py" type="tests" factoryName="Unittests" temporary="true" nameIsGenerated="true">
<module name="sure_tosca-client_python_stubs" />
......@@ -58,49 +68,60 @@
<servers />
</component>
<component name="WindowStateProjectService">
<state x="723" y="257" width="770" height="700" key="FileChooserDialogImpl" timestamp="1587904825236">
<state x="723" y="257" width="770" height="700" key="FileChooserDialogImpl" timestamp="1594637033414">
<screen x="67" y="34" width="1853" height="1046" />
</state>
<state x="723" y="257" width="770" height="700" key="FileChooserDialogImpl/67.34.1853.1046@67.34.1853.1046" timestamp="1587904825236" />
<state width="1825" height="255" key="GridCell.Tab.0.bottom" timestamp="1587047773485">
<state x="723" y="257" width="770" height="700" key="FileChooserDialogImpl/67.34.1853.1046@67.34.1853.1046" timestamp="1594637033414" />
<state width="1825" height="255" key="GridCell.Tab.0.bottom" timestamp="1592388772726">
<screen x="67" y="34" width="1853" height="1046" />
</state>
<state width="1825" height="255" key="GridCell.Tab.0.bottom/67.34.1853.1046@67.34.1853.1046" timestamp="1587047773485" />
<state width="1825" height="255" key="GridCell.Tab.0.center" timestamp="1587047773484">
<state width="1825" height="255" key="GridCell.Tab.0.bottom/67.34.1853.1046@67.34.1853.1046" timestamp="1592388772726" />
<state width="1825" height="255" key="GridCell.Tab.0.center" timestamp="1592388772725">
<screen x="67" y="34" width="1853" height="1046" />
</state>
<state width="1825" height="255" key="GridCell.Tab.0.center/67.34.1853.1046@67.34.1853.1046" timestamp="1587047773484" />
<state width="1825" height="255" key="GridCell.Tab.0.left" timestamp="1587047773484">
<state width="1825" height="255" key="GridCell.Tab.0.center/67.34.1853.1046@67.34.1853.1046" timestamp="1592388772725" />
<state width="1825" height="255" key="GridCell.Tab.0.left" timestamp="1592388772725">
<screen x="67" y="34" width="1853" height="1046" />
</state>
<state width="1825" height="255" key="GridCell.Tab.0.left/67.34.1853.1046@67.34.1853.1046" timestamp="1587047773484" />
<state width="1825" height="255" key="GridCell.Tab.0.right" timestamp="1587047773485">
<state width="1825" height="255" key="GridCell.Tab.0.left/67.34.1853.1046@67.34.1853.1046" timestamp="1592388772725" />
<state width="1825" height="255" key="GridCell.Tab.0.right" timestamp="1592388772725">
<screen x="67" y="34" width="1853" height="1046" />
</state>
<state width="1825" height="255" key="GridCell.Tab.0.right/67.34.1853.1046@67.34.1853.1046" timestamp="1587047773485" />
<state width="1825" height="383" key="GridCell.Tab.1.bottom" timestamp="1585306552969">
<state width="1825" height="255" key="GridCell.Tab.0.right/67.34.1853.1046@67.34.1853.1046" timestamp="1592388772725" />
<state width="1825" height="264" key="GridCell.Tab.1.bottom" timestamp="1592388772719">
<screen x="67" y="34" width="1853" height="1046" />
</state>
<state width="1825" height="383" key="GridCell.Tab.1.bottom/67.34.1853.1046@67.34.1853.1046" timestamp="1585306552969" />
<state width="1825" height="383" key="GridCell.Tab.1.center" timestamp="1585306552966">
<state width="1825" height="264" key="GridCell.Tab.1.bottom/67.34.1853.1046@67.34.1853.1046" timestamp="1592388772719" />
<state width="1825" height="264" key="GridCell.Tab.1.center" timestamp="1592388772719">
<screen x="67" y="34" width="1853" height="1046" />
</state>
<state width="1825" height="383" key="GridCell.Tab.1.center/67.34.1853.1046@67.34.1853.1046" timestamp="1585306552966" />
<state width="1825" height="383" key="GridCell.Tab.1.left" timestamp="1585306552965">
<state width="1825" height="264" key="GridCell.Tab.1.center/67.34.1853.1046@67.34.1853.1046" timestamp="1592388772719" />
<state width="1825" height="264" key="GridCell.Tab.1.left" timestamp="1592388772719">
<screen x="67" y="34" width="1853" height="1046" />
</state>
<state width="1825" height="383" key="GridCell.Tab.1.left/67.34.1853.1046@67.34.1853.1046" timestamp="1585306552965" />
<state width="1825" height="383" key="GridCell.Tab.1.right" timestamp="1585306552968">
<state width="1825" height="264" key="GridCell.Tab.1.left/67.34.1853.1046@67.34.1853.1046" timestamp="1592388772719" />
<state width="1825" height="264" key="GridCell.Tab.1.right" timestamp="1592388772719">
<screen x="67" y="34" width="1853" height="1046" />
</state>
<state width="1825" height="383" key="GridCell.Tab.1.right/67.34.1853.1046@67.34.1853.1046" timestamp="1585306552968" />
<state width="1825" height="264" key="GridCell.Tab.1.right/67.34.1853.1046@67.34.1853.1046" timestamp="1592388772719" />
<state x="359" y="103" key="SettingsEditor" timestamp="1587036749389">
<screen x="67" y="34" width="1853" height="1046" />
</state>
<state x="359" y="103" key="SettingsEditor/67.34.1853.1046@67.34.1853.1046" timestamp="1587036749389" />
<state x="563" y="235" width="1053" height="732" key="find.popup" timestamp="1584900160970">
<state x="563" y="235" width="1053" height="732" key="find.popup" timestamp="1590670239704">
<screen x="67" y="34" width="1853" height="1046" />
</state>
<state x="563" y="235" width="1053" height="732" key="find.popup/67.34.1853.1046@67.34.1853.1046" timestamp="1584900160970" />
<state x="563" y="235" width="1053" height="732" key="find.popup/67.34.1853.1046@67.34.1853.1046" timestamp="1590670239704" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/test/test_default_api.py</url>
<line>33</line>
<option name="timeStamp" value="7" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (sure_tosca-flask-server)" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6 (sure_tosca-flask-server)" project-jdk-type="Python SDK" />
<component name="PyCharmProfessionalAdvertiser">
<option name="shown" value="true" />
</component>
......
......@@ -5,7 +5,7 @@
<excludeFolder url="file://$MODULE_DIR$/venv" />
<excludeFolder url="file://$MODULE_DIR$/venv3-7" />
</content>
<orderEntry type="jdk" jdkName="Python 3.7 (sure_tosca-flask-server)" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="Python 3.6 (sure_tosca-flask-server)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
......@@ -18,7 +18,7 @@ formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(messag
h.setFormatter(formatter)
logger.addHandler(h)
logger.handler_set = True
base_url = 'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/'
base_url = 'https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/examples/'
class Test(TestCase):
def test_upload(self):
......
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