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