Commit ab6a1a17 authored by Spiros Koulouzis's avatar Spiros Koulouzis

removed policies

parent ae0db377
......@@ -2,7 +2,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0
imports:
- nodes: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/nodes.yaml
- data: https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/TOSCA/types/data.yml
- data: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/data.yml
- capabilities: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/capabilities.yaml
- policies: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/policies.yaml
- interfaces: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/interfaces.yml
......
tosca_definitions_version: tosca_simple_yaml_1_0
description: TOSCA example
imports:
- nodes: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/nodes.yaml
- data: https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/TOSCA/types/data.yml
- capabilities: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/capabilities.yaml
- policies: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/policies.yaml
- interfaces: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/interfaces.yml
- nodes: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/nodes.yaml
- data: https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/TOSCA/types/data.yml
- capabilities: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/capabilities.yaml
- policies: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/policies.yaml
- interfaces: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/interfaces.yml
repositories:
docker_hub: https://hub.docker.com/
topology_template:
node_templates:
description: >
TOSCA example
topology_template:
#topology:
#interfaces:
#CloudsStorm:
#provision:
#inputs:
#code_type: SEQ
#object_type: SubTopology
#properties:
#domain: UvA (Amsterdam, The Netherlands) XO Rack
#provider: ExoGENI
#type: tosca.nodes.ARTICONF.VM.topology
node_templates:
ws-pema-lifewatch:
type: tosca.nodes.ARTICONF.Container.Application.Docker
properties:
......@@ -27,4 +35,15 @@ topology_template:
type: tosca.artifacts.Deployment.Image.Container.Docker
file: alogo53/ws-pema-lifewatch
repository: docker_hub
requirements:
- host:
capability: tosca.capabilities.ARTICONF.docker.Orchestrator
node: kubernetes
relationship: tosca.relationships.HostedOn
kubernetes:
type: tosca.nodes.ARTICONF.docker.Orchestrator.Kubernetes
properties:
min_masters_num: 1
min_workers_num: 1
......@@ -14,13 +14,13 @@ services:
- "4369:4369"
- "15671:15671"
planner:
depends_on:
- rabbit
- sure-tosca
image: alogo53/planner:3.0.0
environment:
RABBITMQ_HOST: rabbit
#planner:
#depends_on:
#- rabbit
#- sure-tosca
#image: alogo53/planner:3.0.0
#environment:
#RABBITMQ_HOST: rabbit
provisioner:
depends_on:
......@@ -52,17 +52,17 @@ services:
ports:
- "30000:8080"
sure-tosca:
image: alogo53/sure-tosca:3.0.0
ports:
- "8081:8081"
#logspout:
#sure-tosca:
#image: alogo53/sure-tosca:3.0.0
#ports:
#- "30002:80"
#volumes:
#- /etc/hostname:/etc/host_hostname:ro
#- /var/run/docker.sock:/var/run/docker.sock
#environment:
#publish: "127.0.0.1:30002:80"
#image: gliderlabs/logspout:latest
#- "8081:8081"
logspout:
ports:
- "30002:80"
volumes:
- /etc/hostname:/etc/host_hostname:ro
- /var/run/docker.sock:/var/run/docker.sock
environment:
publish: "127.0.0.1:30002:80"
image: gliderlabs/logspout:latest
......@@ -12,6 +12,33 @@ from service.simple_spec_alayzer import SimpleAnalyzer
from util import tosca_helper
def add_requirements(node, missing_requirements, capable_node_name):
"""Add the requirements to the node """
for req in missing_requirements:
req[next(iter(req))]['node'] = capable_node_name
if isinstance(node, NodeTemplate):
contains_requirement = False
for node_requirement in node.requirements:
if node_requirement == req:
contains_requirement = True
break
if not contains_requirement:
node.requirements.append(req)
elif isinstance(node, dict):
type_name = next(iter(node))
if 'requirements' not in node[type_name]:
node[type_name]['requirements'] = []
node_requirements = node[type_name]['requirements']
contains_requirement = False
for node_requirement in node_requirements:
if node_requirement == req:
contains_requirement = True
break
if not contains_requirement:
node[type_name]['requirements'].append(req)
return node
class Planner:
def __init__(self, tosca_path=None, yaml_dict_tpl=None, spec_service=None):
......@@ -105,7 +132,7 @@ class Planner:
matching_node_type_name = next(iter(matching_node))
matching_node_template = tosca_helper.node_type_2_node_template(matching_node, self.all_custom_def)
# Add the requirements to the node we analyzed. e.g. docker needed host now we added the type and name of host
node = self.add_requirements(node, all_requirements, matching_node_template.name)
node = add_requirements(node, all_requirements, matching_node_template.name)
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):
logging.info(' Adding: ' + str(matching_node_template.name))
......@@ -179,11 +206,15 @@ class Planner:
def find_best_node_for_requirements(self, all_requirements):
"""Returns the 'best' node for a set of requirements. Here we count the number of requiremets that the node
can cover and return the one which covers the most """
# Check if we have a preference from policies
matching_nodes = {}
number_of_matching_requirement = {}
for req in all_requirements:
if 'capability' in req[next(iter(req))]:
capability = req[next(iter(req))]['capability']
logging.info(' Looking for nodes with capability: ' + capability)
# Check if we already cover the requirements within the topology
capable_nodes = self.get_node_templates_by_capability(capability)
# Loop requirements to find nodes per requirement
for req in all_requirements:
if 'capability' in req[next(iter(req))]:
......@@ -226,28 +257,9 @@ class Planner:
child_nodes[tosca_node_type] = self.all_node_types[tosca_node_type]
return child_nodes
def add_requirements(self, node, missing_requirements, capable_node_name):
"""Add the requirements to the node """
for req in missing_requirements:
req[next(iter(req))]['node'] = capable_node_name
if isinstance(node, NodeTemplate):
contains_requirement = False
for node_requirement in node.requirements:
if node_requirement == req:
contains_requirement = True
break
if not contains_requirement:
node.requirements.append(req)
elif isinstance(node, dict):
type_name = next(iter(node))
if 'requirements' not in node[type_name]:
node[type_name]['requirements'] = []
node_requirements = node[type_name]['requirements']
contains_requirement = False
for node_requirement in node_requirements:
if node_requirement == req:
contains_requirement = True
break
if not contains_requirement:
node[type_name]['requirements'].append(req)
return node
def get_node_templates_by_capability(self, capability):
candidate_nodes = {}
for node in self.tosca_template.nodetemplates:
if node.type.startswith('tosca.nodes'):
tosca_helper.get_all_ancestors_types()
return capable_nodes
werkzeug==1.0.0
PyYAML
wheel==0.33.6
connexion == 2.4.0
python-dateutil == 2.8.0
typing == 3.7.4.1
swagger-ui-bundle == 0.0.5
tinydb == 3.15.1
tosca-parser ==1.6.1
wheel==0.34.2
connexion==2.6.0
python-dateutil==2.8.1
typing==3.7.4.1
swagger-ui-bundle==0.0.6
# tinydb==3.15.1
tosca-parser ==1.7.0
......@@ -4,7 +4,7 @@ import sys
from setuptools import setup, find_packages
NAME = "sure_tosca"
VERSION = "1.0.0"
VERSION = "1.2.0"
# To install the library, run the following
#
......
#!/usr/bin/env python
#!/usr/bin/env python3
import connexion
......
from sure_tosca.models.node_template import NodeTemplateModel # noqa: E501
from sure_tosca.models.node_template_map import NodeTemplateMapModel # noqa: E501
from sure_tosca.models.tosca_template import ToscaTemplateModel # noqa: E501
def add_type_definition(definition_map):
return None
def get_types(query):
return None
\ No newline at end of file
......@@ -4,4 +4,4 @@ coverage==5.0.3
nose>=1.3.7
pluggy>=0.13.1
randomize>=0.14
Werkzeug==0.16.1
\ No newline at end of file
werkzeug==1.0.0
\ No newline at end of file
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