Commit 15d47673 authored by Spiros Koulouzis's avatar Spiros Koulouzis

update default properties for types

parent 61e56960
tosca_definitions_version: tosca_simple_yaml_1_0 description: TOSCA example
repositories:
docker_hub: https://hub.docker.com/
imports: imports:
- nodes: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/nodes.yaml - nodes: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/nodes.yaml
- capabilities: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/capabilities.yaml - capabilities: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/capabilities.yaml
- policies: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/policies.yaml - policies: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/policies.yaml
topology_template: topology_template:
node_templates: node_templates:
wordpress: compute:
type: tosca.nodes.ARTICONF.Container.Application.Docker interfaces:
requirements: Standard:
- service: create: dumy.yaml
node: mysql
relationship:
#type: tosca.relationships.ConnectsTo
type: tosca.relationships.DependsOn
artifacts:
image:
file: wordpress:latest
type: tosca.artifacts.Deployment.Image.Container.Docker
repository: docker_hub
properties: properties:
ports: cpu_frequency: 0.5 GHz
- "8000:80" disk_size: 15000 MB
environment: host_name: vm
WORDPRESS_DB_HOST: mysql:3306 mem_size: 500 MB
WORDPRESS_DB_USER: wordpress num_cpus: 1
WORDPRESS_DB_PASSWORD: wordpress os: ubuntu 15
WORDPRESS_DB_NAME: wordpress user_name: vm_user
requirements: type: tosca.nodes.ARTICONF.VM.Compute
- host: compute_1:
capability: tosca.capabilities.ARTICONF.Orchestrator interfaces:
node: heidi_kubernetes Standard:
relationship: tosca.relationships.HostedOn create: dumy.yaml
properties:
cpu_frequency: 0.5 GHz
disk_size: 15000 MB
host_name: vm
mem_size: 500 MB
num_cpus: 1
os: ubuntu 15
role: worker
user_name: vm_user
type: tosca.nodes.ARTICONF.VM.Compute
mysql: mysql:
artifacts: artifacts:
image: image:
...@@ -48,53 +44,90 @@ topology_template: ...@@ -48,53 +44,90 @@ topology_template:
MYSQL_PASSWORD: wordpress MYSQL_PASSWORD: wordpress
MYSQL_ROOT_PASSWORD: somewordpress MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_USER: wordpress MYSQL_USER: wordpress
ports:
- 3306:3306
volumes: volumes:
- db_data:/var/lib/mysql - db_data:/var/lib/mysql
requirements: requirements:
- host: - host:
capability: tosca.capabilities.ARTICONF.Orchestrator capability: tosca.capabilities.ARTICONF.Orchestrator
node: heidi_kubernetes node: swarm
relationship: tosca.relationships.HostedOn relationship: tosca.relationships.HostedOn
type: tosca.nodes.ARTICONF.Container.Application.Docker - useless:
capability: tosca.capabilities.ARTICONF.Useless
heidi_kubernetes: node: swarm
relationship: tosca.relationships.HostedOn
type: tosca.nodes.ARTICONF.Container.Application.Docker
swarm:
interfaces: interfaces:
Standard: Standard:
create: interfaces/playbooks/kubernetes_install.yaml create: interfaces/playbooks/docker_swarm_install.yaml
properties:
masters_num: 1
workers_num: 1
requirements: requirements:
- host: - host:
capability: tosca.capabilities.Scalable capability: tosca.capabilities.Scalable
node: beverly_topology node: topology
relationship: tosca.relationships.HostedOn
- host:
capability: tosca.capabilities.Compute
node: beverly_topology
relationship: tosca.relationships.HostedOn relationship: tosca.relationships.HostedOn
type: tosca.nodes.ARTICONF.Orchestrator.Kubernetes type: tosca.nodes.ARTICONF.Orchestrator.Swarm
topology:
beverly_topology:
interfaces: interfaces:
Standard: Standard:
create: dumy.yaml create: dumy.yaml
properties: properties:
domain: UvA (Amsterdam, The Netherlands) XO Rack domain: {}
name: name name: {}
provider: ExoGeni provider: {}
requirements: requirements:
- vm: - vm:
capability: tosca.capabilities.ARTICONF.VM capability: tosca.capabilities.ARTICONF.VM
node: nancy_compute node: compute
occurrences:
- 1
- UNBOUNDED
relationship: tosca.relationships.DependsOn
- vm:
capability: tosca.capabilities.ARTICONF.VM
node: compute_1
occurrences:
- 1
- UNBOUNDED
relationship: tosca.relationships.DependsOn relationship: tosca.relationships.DependsOn
type: tosca.nodes.ARTICONF.VM.topology type: tosca.nodes.ARTICONF.VM.topology
wordpress:
nancy_compute: artifacts:
interfaces: image:
Standard: file: wordpress:latest
create: dumy.yaml repository: docker_hub
type: tosca.artifacts.Deployment.Image.Container.Docker
properties: properties:
cpu_frequency: 2.9 GHz environment:
disk_size: 25000 MB WORDPRESS_DB_HOST: mysql:3306
host_name: vm WORDPRESS_DB_NAME: wordpress
mem_size: 3000 MB WORDPRESS_DB_PASSWORD: wordpress
num_cpus: 1 WORDPRESS_DB_USER: wordpress
type: tosca.nodes.ARTICONF.VM.Compute ports:
- 8000:80
requirements:
- service:
node: mysql
relationship:
type: tosca.relationships.DependsOn
- host:
capability: tosca.capabilities.ARTICONF.Orchestrator
node: swarm
relationship: tosca.relationships.HostedOn
- useless:
capability: tosca.capabilities.ARTICONF.Useless
node: swarm
relationship: tosca.relationships.HostedOn
type: tosca.nodes.ARTICONF.Container.Application.Docker
policies:
- scalability:
properties:
fault_tolerance_level: 0
targets:
- mysql
type: tosca.policies.ARTICONF.FaultTolerance
tosca_definitions_version: tosca_simple_yaml_1_0
...@@ -73,7 +73,7 @@ topology_template: ...@@ -73,7 +73,7 @@ topology_template:
policies: policies:
- scalability: - scalability:
type: tosca.policies.ARTICONF.Performance type: tosca.policies.ARTICONF.Performance.CPU
targets: [ wordpress ] targets: [ wordpress ]
properties: properties:
constraint_name: cpu_load constraint_name: cpu_load
......
...@@ -2,12 +2,12 @@ tosca_definitions_version: tosca_simple_yaml_1_0 ...@@ -2,12 +2,12 @@ tosca_definitions_version: tosca_simple_yaml_1_0
node_types: node_types:
tosca.nodes.ARTICONF.Root:
description: root ARTICONF node
tosca.nodes.ARTICONF.Container.Application.Docker: tosca.nodes.ARTICONF.Container.Application.Docker:
#derived_from: tosca.nodes.Container.Application.Docker derived_from: tosca.nodes.ARTICONF.Root
description: description of container description: description of container
capabilities:
service:
type: tosca.capabilities.Container.Docker
properties: properties:
ports: ports:
description: ports to be forwarded description: ports to be forwarded
...@@ -33,73 +33,84 @@ node_types: ...@@ -33,73 +33,84 @@ node_types:
- host: - host:
capability: tosca.capabilities.ARTICONF.Orchestrator capability: tosca.capabilities.ARTICONF.Orchestrator
node: tosca.nodes.ARTICONF.Orchestrator node: tosca.nodes.ARTICONF.Orchestrator
relationship: tosca.relationships.HostedOn relationship: tosca.relationships.HostedOn
- useless:
capability: tosca.capabilities.ARTICONF.Useless
node: tosca.nodes.ARTICONF.Orchestrator
relationship: tosca.relationships.HostedOn
tosca.nodes.ARTICONF.Orchestrator: tosca.nodes.ARTICONF.Orchestrator:
#derived_from: tosca.nodes.SoftwareComponent derived_from: tosca.nodes.ARTICONF.Root
description: a container orchestrator description: a container orchestrator
requirements: requirements:
- host: - host:
capability: tosca.capabilities.Compute capability: tosca.capabilities.ARTICONF.VM.topology
node: tosca.nodes.Compute node: tosca.nodes.ARTICONF.VM.topology
relationship: tosca.relationships.HostedOn relationship: tosca.relationships.HostedOn
capabilities: capabilities:
host: orchestrator:
type: tosca.capabilities.ARTICONF.Orchestrator type: tosca.capabilities.ARTICONF.Orchestrator
occurrences: [1, 1] host:
type: tosca.capabilities.Container.Docker
container:
type: tosca.capabilities.Container
properties: properties:
masters_num: masters_num:
type: integer type: integer
required: true required: true
default: 1
constraints: constraints:
- greater_or_equal: 1 - greater_or_equal: 1
workers_num: workers_num:
type: integer type: integer
required: true required: true
default: 1
constraints: constraints:
- greater_or_equal: 1 - greater_or_equal: 1
tosca.nodes.ARTICONF.Orchestrator.Kubernetes: tosca.nodes.ARTICONF.Orchestrator.Kubernetes:
derived_from: tosca.nodes.ARTICONF.Orchestrator derived_from: tosca.nodes.ARTICONF.Orchestrator
description: Kubernetes orchestrator description: Kubernetes orchestrator
requirements:
- host:
capability: tosca.capabilities.Scalable
node: tosca.nodes.ARTICONF.Infrastructure
relationship: tosca.relationships.HostedOn
interfaces: interfaces:
Standard: Standard:
create: interfaces/playbooks/kubernetes_install.yaml create: interfaces/playbooks/kubernetes_install.yaml
tosca.nodes.ARTICONF.Orchestrator.Swarm: #tosca.nodes.ARTICONF.Orchestrator.Swarm:
derived_from: tosca.nodes.ARTICONF.Orchestrator #derived_from: tosca.nodes.ARTICONF.Orchestrator
description: swarm orchestrator #description: swarm orchestrator
#interfaces:
#Standard:
#create: interfaces/playbooks/docker_swarm_install.yaml
tosca.nodes.ARTICONF.VM.topology:
derived_from: tosca.nodes.ARTICONF.Infrastructure
description: topology of VMs
requirements: requirements:
- host: - vm:
capability: tosca.capabilities.Scalable capability: tosca.capabilities.ARTICONF.VM
node: tosca.nodes.ARTICONF.Infrastructure node: tosca.nodes.ARTICONF.Infrastructure
relationship: tosca.relationships.HostedOn relationship: tosca.relationships.DependsOn
capabilities: capabilities:
useless: scalable:
type: tosca.capabilities.ARTICONF.Useless type: tosca.capabilities.Scalable
topology:
type: tosca.capabilities.ARTICONF.VM.topology
properties:
provider:
type: string
required: true
default: "ExoGeni"
name:
type: string
required: false
domain:
type: string
required: true
default: "UvA (Amsterdam, The Netherlands) XO Rack"
credential:
type: tosca.datatypes.Credential
required: false
interfaces: interfaces:
Standard: Standard:
create: interfaces/playbooks/docker_swarm_install.yaml create: dumy.yaml
tosca.nodes.ARTICONF.Infrastructure:
description: Base infrastructure node
capabilities:
compute:
type: tosca.capabilities.Compute
node:
type: tosca.capabilities.Node
tosca.nodes.ARTICONF.VM.Compute: tosca.nodes.ARTICONF.VM.Compute:
derived_from: tosca.nodes.ARTICONF.Infrastructure derived_from: tosca.nodes.ARTICONF.Infrastructure
...@@ -116,64 +127,51 @@ node_types: ...@@ -116,64 +127,51 @@ node_types:
type: string type: string
required: true required: true
default: "vm" default: "vm"
num_cpus: num_cores:
type: integer type: integer
required: true required: true
default: 2
constraints: constraints:
- greater_or_equal: 1 - greater_or_equal: 1
cpu_frequency: cpu_frequency:
type: scalar-unit.frequency type: scalar-unit.frequency
required: true required: false
constraints: constraints:
- greater_or_equal: 0.5 GHz - greater_or_equal: 0.5 GHz
disk_size: disk_size:
type: scalar-unit.size type: scalar-unit.size
required: true required: true
default: 50000 MB
constraints: constraints:
- greater_or_equal: 15000 MB - greater_or_equal: 15000 MB
mem_size: mem_size:
type: scalar-unit.size type: scalar-unit.size
required: true required: true
default: 6000 MB
constraints: constraints:
- greater_or_equal: 500 MB - greater_or_equal: 500 MB
os: os:
type: string type: string
required: true required: true
default: "ubuntu 15" default: "ubuntu 16"
interfaces: role:
Standard:
create: dumy.yaml
tosca.nodes.ARTICONF.VM.topology:
derived_from: tosca.nodes.ARTICONF.Infrastructure
description: topology of VMs
requirements:
- vm:
capability: tosca.capabilities.ARTICONF.VM
node: tosca.nodes.ARTICONF.Infrastructure
relationship: tosca.relationships.DependsOn
occurrences: [1, UNBOUNDED]
capabilities:
scalable:
type: tosca.capabilities.Scalable
topology:
type: tosca.capabilities.ARTICONF.VM.topology
occurrences: [1, 1]
properties:
provider:
type: string
required: true
name:
type: string
required: true
domain:
type: string type: string
required: true required: true
credential: description: the role of the VM in the topology
type: tosca.datatypes.Credential default: "master"
required: false constraints:
- valid_values: [ "master","worker" ]
interfaces: interfaces:
Standard: Standard:
create: dumy.yaml create: dumy.yaml
tosca.nodes.ARTICONF.Infrastructure:
derived_from: tosca.nodes.ARTICONF.Root
description: Base infrastructure node
capabilities:
compute:
type: tosca.capabilities.Compute
node:
type: tosca.capabilities.Node
...@@ -6,19 +6,13 @@ ...@@ -6,19 +6,13 @@
package nl.uva.sne.drip.service; package nl.uva.sne.drip.service;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import nl.uva.sne.drip.model.Message; import nl.uva.sne.drip.model.Message;
import nl.uva.sne.drip.model.MessageParameter;
import nl.uva.sne.drip.model.ToscaTemplate; import nl.uva.sne.drip.model.ToscaTemplate;
import nl.uva.sne.drip.rpc.DRIPCaller;
import nl.uva.sne.drip.rpc.PlannerCaller; import nl.uva.sne.drip.rpc.PlannerCaller;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
......
...@@ -2,12 +2,11 @@ ...@@ -2,12 +2,11 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="462ede19-adfe-472b-975e-fefefa973fe0" name="Default Changelist" comment=""> <list default="true" id="462ede19-adfe-472b-975e-fefefa973fe0" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/src/test_planner.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../TOSCA/application_example_output.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../TOSCA/application_example_output.yaml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../TOSCA/application_example_output.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../TOSCA/application_example_output.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../TOSCA/application_example_updated.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../TOSCA/application_example_updated.yaml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../TOSCA/application_example_updated.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../TOSCA/application_example_updated.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../TOSCA/types/nodes.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../TOSCA/types/nodes.yaml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../TOSCA/types/nodes.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../TOSCA/types/nodes.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/planner/planner.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/planner/planner.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/planner/simple_spec_alayzer.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/planner/simple_spec_alayzer.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/rpc_server.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/rpc_server.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/rpc_server.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/rpc_server.py" afterDir="false" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
...@@ -255,7 +254,14 @@ ...@@ -255,7 +254,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1571756795577</updated> <updated>1571756795577</updated>
</task> </task>
<option name="localTasksCounter" value="17" /> <task id="LOCAL-00017" summary="added test">
<created>1571757387680</created>
<option name="number" value="00017" />
<option name="presentableId" value="LOCAL-00017" />
<option name="project" value="LOCAL" />
<updated>1571757387680</updated>
</task>
<option name="localTasksCounter" value="18" />
<servers /> <servers />
</component> </component>
<component name="Vcs.Log.Tabs.Properties"> <component name="Vcs.Log.Tabs.Properties">
...@@ -287,7 +293,8 @@ ...@@ -287,7 +293,8 @@
<MESSAGE value="set default properties" /> <MESSAGE value="set default properties" />
<MESSAGE value="set min number of VMs based on the swarm default workers and masters" /> <MESSAGE value="set min number of VMs based on the swarm default workers and masters" />
<MESSAGE value="fixed policies error" /> <MESSAGE value="fixed policies error" />
<option name="LAST_COMMIT_MESSAGE" value="fixed policies error" /> <MESSAGE value="added test" />
<option name="LAST_COMMIT_MESSAGE" value="added test" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>
...@@ -304,9 +311,19 @@ ...@@ -304,9 +311,19 @@
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line"> <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/src/rpc_server.py</url> <url>file://$PROJECT_DIR$/src/rpc_server.py</url>
<line>134</line> <line>136</line>
<option name="timeStamp" value="295" /> <option name="timeStamp" value="295" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/src/rpc_server.py</url>
<line>106</line>
<option name="timeStamp" value="302" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/src/rpc_server.py</url>
<line>99</line>
<option name="timeStamp" value="303" />
</line-breakpoint>
</breakpoints> </breakpoints>
<default-breakpoints> <default-breakpoints>
<breakpoint type="python-exception"> <breakpoint type="python-exception">
......
{
"test_planner.py": true,
"test_planner.py::MyTestCase::test_something": true
}
\ No newline at end of file
...@@ -22,8 +22,9 @@ class SimpleAnalyzer(SpecificationAnalyzer): ...@@ -22,8 +22,9 @@ class SimpleAnalyzer(SpecificationAnalyzer):
self.tosca_template.nodetemplates, self.all_node_types, self.tosca_template.nodetemplates, self.all_node_types,
self.all_custom_def) self.all_custom_def)
masters_num = orchestrator_nodes[0].get_property_value('masters_num') masters_num = orchestrator_nodes[0].entity_tpl['properties']['masters_num']
workers_num = orchestrator_nodes[0].get_property_value('workers_num') workers_num = orchestrator_nodes[0].entity_tpl['properties']['workers_num']
# workers_num = orchestrator_nodes[0].get_property_value('workers_num')
min_num_of_vm = masters_num + workers_num min_num_of_vm = masters_num + workers_num
topology_nodes = tosca_util.get_nodes_by_type('tosca.nodes.ARTICONF.VM.topology', topology_nodes = tosca_util.get_nodes_by_type('tosca.nodes.ARTICONF.VM.topology',
self.tosca_template.nodetemplates, self.all_node_types, self.tosca_template.nodetemplates, self.all_node_types,
...@@ -124,12 +125,13 @@ class SimpleAnalyzer(SpecificationAnalyzer): ...@@ -124,12 +125,13 @@ class SimpleAnalyzer(SpecificationAnalyzer):
for default_property in default_properties: for default_property in default_properties:
affected_node.get_properties_objects().append(default_property) affected_node.get_properties_objects().append(default_property)
for prop_name in affected_node.templates[next(iter(affected_node.templates))]['properties']: if 'properties' in affected_node.templates[next(iter(affected_node.templates))]:
if 'required' not in affected_node.templates[next(iter(affected_node.templates))]['properties'][ for prop_name in affected_node.templates[next(iter(affected_node.templates))]['properties']:
prop_name] and 'type' not in \ if 'required' not in affected_node.templates[next(iter(affected_node.templates))]['properties'][
affected_node.templates[next(iter(affected_node.templates))]['properties'][prop_name]: prop_name] and 'type' not in \
default_properties[prop_name] = \ affected_node.templates[next(iter(affected_node.templates))]['properties'][prop_name]:
affected_node.templates[next(iter(affected_node.templates))]['properties'][(prop_name)] default_properties[prop_name] = \
affected_node.templates[next(iter(affected_node.templates))]['properties'][prop_name]
affected_node.templates[next(iter(affected_node.templates))]['properties'] = default_properties affected_node.templates[next(iter(affected_node.templates))]['properties'] = default_properties
...@@ -152,7 +154,6 @@ class SimpleAnalyzer(SpecificationAnalyzer): ...@@ -152,7 +154,6 @@ class SimpleAnalyzer(SpecificationAnalyzer):
def get_defult_value(self, node_property): def get_defult_value(self, node_property):
if isinstance(node_property.value, if isinstance(node_property.value,
dict) and 'required' in node_property.value and 'type' in node_property.value: dict) and 'required' in node_property.value and 'type' in node_property.value:
logging.info('node property: ' + str(node_property.value))
if node_property.value['required']: if node_property.value['required']:
default_prop = {} default_prop = {}
if 'default' in node_property.value: if 'default' in node_property.value:
......
# To change this license header, choose License Headers in Project Properties. # To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates # To change this template file, choose Tools | Templates
# and open the template in the editor. # and open the template in the editor.
import json
import os import os
import os.path import os.path
import tempfile import tempfile
import time import time
import pika import pika
import yaml
from planner.basic_planner import * from planner.basic_planner import *
from planner.planner import * from planner.planner import *
...@@ -88,13 +89,14 @@ def handle_delivery(message): ...@@ -88,13 +89,14 @@ def handle_delivery(message):
with open(input_tosca_file_path, 'w') as outfile: with open(input_tosca_file_path, 'w') as outfile:
outfile.write(yaml.dump(tosca_template_json)) outfile.write(yaml.dump(tosca_template_json))
planner = Planner(input_tosca_file_path) conf = {'url': "http://host"}
required_nodes = planner.resolve_requirements() spec_service = SpecService(conf)
required_nodes = planner.set_infrastructure_specifications(required_nodes) test_planner = Planner(input_tosca_file_path, spec_service)
planner.add_required_nodes_to_template(required_nodes) tosca_template = test_planner.resolve_requirements()
planned_template = tosca_util.get_tosca_template_as_yml(planner.template) tosca_template = test_planner.set_infrastructure_specifications()
logger.info("template ----: \n" + planned_template) template_dict = tosca_util.get_tosca_template_2_topology_template_dictionary(tosca_template)
template_dict = yaml.load(planned_template) logger.info("template ----: \n" + yaml.dump(template_dict))
response = {'toscaTemplate': template_dict} response = {'toscaTemplate': template_dict}
output_current_milli_time = lambda: int(round(time.time() * 1000)) output_current_milli_time = lambda: int(round(time.time() * 1000))
response["creationDate"] = output_current_milli_time response["creationDate"] = output_current_milli_time
...@@ -110,13 +112,13 @@ if __name__ == "__main__": ...@@ -110,13 +112,13 @@ if __name__ == "__main__":
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
if sys.argv[1] == "test_local": if sys.argv[1] == "test_local":
tosca_path = "../../TOSCA/" tosca_path = "../../TOSCA/"
tosca_file_path = tosca_path+'/application_example_updated.yaml' input_tosca_file_path = tosca_path + '/application_example.yaml'
conf = {'url': "http://host"} conf = {'url': "http://host"}
spec_service = SpecService(conf) spec_service = SpecService(conf)
test_planner = Planner(tosca_file_path, spec_service) test_planner = Planner(input_tosca_file_path, spec_service)
tosca_template = test_planner.resolve_requirements() test_tosca_template = test_planner.resolve_requirements()
tosca_template = test_planner.set_infrastructure_specifications() test_tosca_template = test_planner.set_infrastructure_specifications()
template = tosca_util.get_tosca_template_2_topology_template_dictionary(tosca_template) template = tosca_util.get_tosca_template_2_topology_template_dictionary(test_tosca_template)
logger.info("template ----: \n" + yaml.dump(template)) logger.info("template ----: \n" + yaml.dump(template))
try: try:
...@@ -127,7 +129,7 @@ if __name__ == "__main__": ...@@ -127,7 +129,7 @@ if __name__ == "__main__":
tosca_folder_path = os.path.dirname(os.path.abspath(sys.argv[0])) + os.path.join(tempfile.gettempdir(), tosca_folder_path = os.path.dirname(os.path.abspath(sys.argv[0])) + os.path.join(tempfile.gettempdir(),
tosca_path) tosca_path)
tosca_file_name = 'tosca_template' tosca_file_name = 'tosca_template'
input_tosca_file_path = tosca_path+'/application_example_output.yaml' input_tosca_file_path = tosca_path + '/application_example_output.yaml'
with open(input_tosca_file_path, 'w') as outfile: with open(input_tosca_file_path, 'w') as outfile:
outfile.write(yaml.dump(template)) outfile.write(yaml.dump(template))
......
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