Commit 03c9c83b authored by Spiros Koulouzis's avatar Spiros Koulouzis

change some attributes back to properties

parent 5b6644ae
tosca_definitions_version: tosca_simple_yaml_1_0
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
- interfaces: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/interfaces.yml
repositories:
docker_hub: https://hub.docker.com/
topology_template:
node_templates:
compute:
......@@ -19,22 +15,8 @@ topology_template:
mem_size: 6000 MB
num_cores: 2
os: ubuntu 16
attributes:
private_ip: 192.168.1.10
type: tosca.nodes.ARTICONF.VM.Compute
compute_1:
interfaces:
Standard:
create: dumy.yaml
properties:
disk_size: 50000 MB
mem_size: 6000 MB
num_cores: 2
os: ubuntu 16
attributes:
private_ip: 192.168.1.11
type: tosca.nodes.ARTICONF.VM.Compute
compute_2:
interfaces:
Standard:
create: dumy.yaml
......@@ -53,11 +35,27 @@ topology_template:
capability: tosca.capabilities.ARTICONF.VM.topology
node: topology
relationship: tosca.relationships.HostedOn
type: tosca.nodes.ARTICONF.Orchestrator.Kubernetes
logspout:
artifacts:
image:
file: gliderlabs/logspout:latest
repository: docker_hub
type: tosca.artifacts.Deployment.Image.Container.Docker
properties:
environment:
publish: 127.0.0.1:8000:80
ports:
- 8000:80
volumes:
- /etc/hostname:/etc/host_hostname:ro
- /var/run/docker.sock:/var/run/docker.sock
requirements:
- host:
capability: tosca.capabilities.ARTICONF.VM.topology
node: topology_1
capability: tosca.capabilities.ARTICONF.Orchestrator
node: kubernetes
relationship: tosca.relationships.HostedOn
type: tosca.nodes.ARTICONF.Orchestrator.Kubernetes
type: tosca.nodes.ARTICONF.Container.Application.Docker
mysql:
artifacts:
image:
......@@ -84,6 +82,9 @@ topology_template:
interfaces:
Standard:
create: dumy.yaml
properties:
domain: UvA (Amsterdam, The Netherlands) XO Rack
provider: ExoGeni
requirements:
- vm:
capability: tosca.capabilities.ARTICONF.VM
......@@ -94,16 +95,6 @@ topology_template:
node: compute_1
relationship: tosca.relationships.DependsOn
type: tosca.nodes.ARTICONF.VM.topology
topology_1:
interfaces:
Standard:
create: dumy.yaml
requirements:
- vm:
capability: tosca.capabilities.ARTICONF.VM
node: compute_2
relationship: tosca.relationships.DependsOn
type: tosca.nodes.ARTICONF.VM.topology
wordpress:
artifacts:
image:
......@@ -128,21 +119,18 @@ topology_template:
node: kubernetes
relationship: tosca.relationships.HostedOn
type: tosca.nodes.ARTICONF.Container.Application.Docker
policies:
- scalability:
properties:
fault_tolerance_level: 0
constraint_name: cpu_load
max_value: 90
targets:
- wordpress
type: tosca.policies.ARTICONF.Performance.CPU
- faultTolerance:
properties:
level: 1
targets:
- mysql
type: tosca.policies.ARTICONF.FaultTolerance
outputs:
private_ip:
description: The private IP address of the application’s first tier.
value: { get_attribute: [compute, private_ip] }
private_ip_1:
description: The private IP address of the application’s first tier.
value: { get_attribute: [compute_1, private_ip] }
tosca_definitions_version: tosca_simple_yaml_1_0
......@@ -2,13 +2,10 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="e478ccae-5352-4e8e-9efb-3f5cda44e877" name="Default Changelist" comment="added matplotlib">
<change beforePath="$PROJECT_DIR$/../build.sh" beforeDir="false" afterPath="$PROJECT_DIR$/../build.sh" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../TOSCA/application_example_2_topologies.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../TOSCA/application_example_2_topologies.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/requirements.txt" beforeDir="false" afterPath="$PROJECT_DIR$/requirements.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/__main__.py" beforeDir="false" afterPath="$PROJECT_DIR$/__main__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/service/simple_spec_alayzer.py" beforeDir="false" afterPath="$PROJECT_DIR$/service/simple_spec_alayzer.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../jenkins_pipeline" beforeDir="false" afterPath="$PROJECT_DIR$/../jenkins_pipeline" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/test-requirements.txt" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/test-requirements.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../test.sh" beforeDir="false" afterPath="$PROJECT_DIR$/../test.sh" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
......@@ -206,18 +203,38 @@
<breakpoints>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/service/simple_spec_alayzer.py</url>
<line>45</line>
<line>47</line>
<option name="timeStamp" value="1" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/planner/planner.py</url>
<line>36</line>
<option name="timeStamp" value="3" />
<line>66</line>
<option name="timeStamp" value="8" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/planner/planner.py</url>
<line>61</line>
<option name="timeStamp" value="9" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/__main__.py</url>
<line>124</line>
<option name="timeStamp" value="10" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/service/simple_spec_alayzer.py</url>
<line>25</line>
<option name="timeStamp" value="20" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/service/simple_spec_alayzer.py</url>
<line>127</line>
<option name="timeStamp" value="22" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/service/simple_spec_alayzer.py</url>
<line>26</line>
<option name="timeStamp" value="5" />
<line>160</line>
<option name="timeStamp" value="26" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
......
......@@ -115,7 +115,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_2_topologies.yaml'
input_tosca_file_path = tosca_path + '/application_example_updated.yaml'
conf = {'url': "http://host"}
spec_service = SpecService(conf)
test_planner = Planner(input_tosca_file_path, spec_service)
......@@ -129,18 +129,18 @@ if __name__ == "__main__":
except NameError:
import sys
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_2_topologies.yaml'
with open(input_tosca_file_path, 'w') as outfile:
outfile.write(yaml.dump(template_dict))
ToscaTemplate(input_tosca_file_path)
test_response = {'toscaTemplate': template_dict}
logger.info("Output message:" + json.dumps(test_response))
# 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_2_topologies.yaml'
#
# with open(input_tosca_file_path, 'w') as outfile:
# outfile.write(yaml.dump(template_dict))
#
# ToscaTemplate(input_tosca_file_path)
#
# test_response = {'toscaTemplate': template_dict}
# logger.info("Output message:" + json.dumps(test_response))
else:
logger.info("Input args: " + sys.argv[0] + ' ' + sys.argv[1] + ' ' + sys.argv[2])
channel = init_chanel(sys.argv)
......
......@@ -23,12 +23,14 @@ class SimpleAnalyzer(SpecificationAnalyzer):
self.tosca_template.nodetemplates, self.all_node_types,
self.all_custom_def)
orchestrator_nodes[0].type_definition
if 'attributes' in orchestrator_nodes[0].entity_tpl:
if 'masters_num' in orchestrator_nodes[0].entity_tpl['attributes']:
masters_num = orchestrator_nodes[0].entity_tpl['attributes']['masters_num']
if 'workers_num' in orchestrator_nodes[0].entity_tpl['attributes']:
workers_num = orchestrator_nodes[0].entity_tpl['attributes']['workers_num']
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',
self.tosca_template.nodetemplates, self.all_node_types,
......@@ -43,7 +45,7 @@ class SimpleAnalyzer(SpecificationAnalyzer):
self.tosca_template.nodetemplates, self.all_node_types,
self.all_custom_def)
if vm_nodes:
for i in range(len(vm_nodes), masters_num):
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)
......@@ -116,12 +118,12 @@ class SimpleAnalyzer(SpecificationAnalyzer):
ancestors_types = tosca_helper.get_all_ancestors_types(affected_node, self.all_node_types, self.all_custom_def)
# if 'tosca.nodes.ARTICONF.Orchestrator' in ancestors_types:
# logging.info('Do Something')
properties = tosca_helper.get_all_ancestors_properties(affected_node, self.all_node_types,
ancestors_properties = tosca_helper.get_all_ancestors_properties(affected_node, self.all_node_types,
self.all_custom_def)
default_properties = {}
for node_property in properties:
default_property = self.get_defult_value(node_property)
for ancestors_property in ancestors_properties:
default_property = self.get_defult_value(ancestors_property)
if default_property:
default_properties[next(iter(default_property))] = default_property[next(iter(default_property))]
......@@ -156,25 +158,36 @@ class SimpleAnalyzer(SpecificationAnalyzer):
return affected_node
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:
if node_property.value['required']:
default_prop = {}
if 'default' in node_property.value:
if node_property.value['type'] == 'integer':
default_prop = int(node_property.value['default'])
else:
default_prop = str(node_property.value['default'])
elif 'constraints' in node_property.value:
constraints = node_property.value['constraints']
for constraint in constraints:
for constraint_key in constraint:
if 'equal' in constraint_key:
if node_property.value['type'] == 'integer':
default_prop = int(constraint[constraint_key])
else:
default_prop = str(constraint[constraint_key])
name = node_property.name
node_property = {name: default_prop}
return 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 isinstance(node_property.value,
# dict) and 'required' in node_property.value and 'type' in node_property.value:
# if node_property.value['required']:
# default_prop = {}
# if 'default' in node_property.value:
# if node_property.value['type'] == 'integer':
# default_prop = int(node_property.value['default'])
# else:
# default_prop = str(node_property.value['default'])
# elif 'constraints' in node_property.value:
# constraints = node_property.value['constraints']
# for constraint in constraints:
# for constraint_key in constraint:
# if 'equal' in constraint_key:
# if node_property.value['type'] == 'integer':
# default_prop = int(constraint[constraint_key])
# else:
# default_prop = str(constraint[constraint_key])
# name = node_property.name
# node_property = {name: default_prop}
# return node_property
# if node_property.value:
# name = node_property.name
# node_property = {name: node_property.value}
# return node_property
return None
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