Commit e0127d00 authored by Spiros Koulouzis's avatar Spiros Koulouzis

create NodeTemplate from types

parent 37e7927d
...@@ -48,6 +48,13 @@ topology_template: ...@@ -48,6 +48,13 @@ topology_template:
file: mysql:5.7 file: mysql:5.7
repository: docker_hub repository: docker_hub
#guillermo_kubernetes:
#type: tosca.nodes.ARTICONF.Orchestrator.Kubernetes
#cluster:
#type: tosca.nodes.Compute
......
...@@ -47,18 +47,11 @@ node_types: ...@@ -47,18 +47,11 @@ node_types:
host: host:
type: tosca.capabilities.ARTICONF.Orchestrator type: tosca.capabilities.ARTICONF.Orchestrator
occurrences: [1, 1] occurrences: [1, 1]
cap:
type: tosca.capabilities.ROOT
occurrences: [1, 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
capabilities:
cap_1:
type: tosca.capabilities.ROOT
occurrences: [1, 100]
requirements: requirements:
- host: - host:
capability: tosca.capabilities.Scalable capability: tosca.capabilities.Scalable
...@@ -66,7 +59,6 @@ node_types: ...@@ -66,7 +59,6 @@ node_types:
relationship: tosca.relationships.HostedOn relationship: tosca.relationships.HostedOn
interfaces: interfaces:
Standard: Standard:
configure: create: https://raw.githubusercontent.com/indigo-dc/tosca-types/master/artifacts/mysql/mysql_install.yml
implementation: playbooks/kubernetes_install.yaml
...@@ -2,9 +2,7 @@ ...@@ -2,9 +2,7 @@
<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 beforePath="$PROJECT_DIR$/../Dockerfiles/planner/Dockerfile" beforeDir="false" afterPath="$PROJECT_DIR$/../Dockerfiles/planner/Dockerfile" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../TOSCA/application_example.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../TOSCA/application_example.yaml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../TOSCA/application_example.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../TOSCA/application_example.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$/src/planner/basic_planner.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/planner/basic_planner.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/planner/basic_planner.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/planner/basic_planner.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>
...@@ -18,18 +16,14 @@ ...@@ -18,18 +16,14 @@
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300"> <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="true"> <file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/rpc_server.py"> <entry file="file://$PROJECT_DIR$/src/rpc_server.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor" />
<state relative-caret-position="152">
<caret line="113" selection-start-line="113" selection-end-line="118" selection-end-column="92" />
</state>
</provider>
</entry> </entry>
</file> </file>
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/planner/basic_planner.py"> <entry file="file://$PROJECT_DIR$/src/planner/basic_planner.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="81"> <state relative-caret-position="171">
<caret line="19" selection-start-line="19" selection-end-line="19" /> <caret line="29" selection-start-line="29" selection-end-line="29" />
<folding> <folding>
<element signature="e#0#11#0" expanded="true" /> <element signature="e#0#11#0" expanded="true" />
</folding> </folding>
...@@ -87,6 +81,13 @@ ...@@ -87,6 +81,13 @@
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component> </component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/src/rpc_server.py" />
</list>
</option>
</component>
<component name="ProjectConfigurationFiles"> <component name="ProjectConfigurationFiles">
<option name="files"> <option name="files">
<list> <list>
...@@ -94,7 +95,7 @@ ...@@ -94,7 +95,7 @@
</list> </list>
</option> </option>
</component> </component>
<component name="ProjectFrameBounds"> <component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="33" /> <option name="x" value="33" />
<option name="y" value="13" /> <option name="y" value="13" />
<option name="width" value="922" /> <option name="width" value="922" />
...@@ -132,6 +133,7 @@ ...@@ -132,6 +133,7 @@
</panes> </panes>
</component> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="full.screen.before.presentation.mode" value="false" /> <property name="full.screen.before.presentation.mode" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" /> <property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="settings.editor.selected.configurable" value="preferences.lookFeel" /> <property name="settings.editor.selected.configurable" value="preferences.lookFeel" />
...@@ -212,7 +214,7 @@ ...@@ -212,7 +214,7 @@
<servers /> <servers />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="33" y="13" width="922" height="526" extended-state="0" /> <frame x="33" y="12" width="926" height="527" extended-state="6" />
<layout> <layout>
<window_info content_ui="combo" id="Project" order="0" weight="0.14317425" /> <window_info content_ui="combo" id="Project" order="0" weight="0.14317425" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" /> <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
...@@ -265,16 +267,12 @@ ...@@ -265,16 +267,12 @@
</component> </component>
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/src/rpc_server.py"> <entry file="file://$PROJECT_DIR$/src/rpc_server.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor" />
<state relative-caret-position="152">
<caret line="113" selection-start-line="113" selection-end-line="118" selection-end-column="92" />
</state>
</provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/planner/basic_planner.py"> <entry file="file://$PROJECT_DIR$/src/planner/basic_planner.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="81"> <state relative-caret-position="171">
<caret line="19" selection-start-line="19" selection-end-line="19" /> <caret line="29" selection-start-line="29" selection-end-line="29" />
<folding> <folding>
<element signature="e#0#11#0" expanded="true" /> <element signature="e#0#11#0" expanded="true" />
</folding> </folding>
......
...@@ -12,6 +12,8 @@ import urllib.parse ...@@ -12,6 +12,8 @@ import urllib.parse
import sys import sys
import pdb import pdb
import names import names
import yaml
from pdb import set_trace as bp
...@@ -30,10 +32,11 @@ class BasicPlanner: ...@@ -30,10 +32,11 @@ class BasicPlanner:
node_templates = [] node_templates = []
for node in self.template.nodetemplates: for node in self.template.nodetemplates:
missing_requirements = self.get_missing_requirements(node) missing_requirements = self.get_missing_requirements(node)
for req in missing_requirements: for req in missing_requirements:
for key in req: for key in req:
capable_nodes = self.get_node_types_by_capability(req[key]['capability']) capable_nodes = self.get_node_types_by_capability(req[key]['capability'])
# remove nodes required once. e.g. kubernetes is hosting all dockers
for node_type in capable_nodes: for node_type in capable_nodes:
capable_node = capable_nodes[node_type] capable_node = capable_nodes[node_type]
for cap in capable_node['capabilities']: for cap in capable_node['capabilities']:
...@@ -47,24 +50,31 @@ class BasicPlanner: ...@@ -47,24 +50,31 @@ class BasicPlanner:
node.requirements.append(req) node.requirements.append(req)
node_templates.append(node) node_templates.append(node)
for node_type in capable_nodes:
capable_node = capable_nodes[node_type] for node_type in capable_node_types:
nodetemplate = {} nodetemplate_dict = {}
nodetemplate[names.get_first_name().lower()] = node_type type_name = next(iter(node_type))
print(nodetemplate) node_type_array = type_name.split(".")
name = names.get_first_name().lower() + "_" + node_type_array[len(node_type_array)-1].lower()
nodetemplate_dict[name] = node_type[next(iter(node_type))].copy()
nodetemplate_dict[name]['type'] = type_name
if 'capabilities' in nodetemplate_dict[name]:
nodetemplate_dict[name].pop('capabilities')
if 'requirements' in nodetemplate_dict[name]:
nodetemplate_dict[name].pop('requirements')
if 'capabilities' in nodetemplate_dict[name]:
nodetemplate_dict[name].pop('capabilities')
if 'derived_from' in nodetemplate_dict[name]:
nodetemplate_dict[name].pop('derived_from')
if 'type' in node_type[next(iter(node_type))]:
node_type[next(iter(node_type))].pop('type')
nodetemplate = NodeTemplate(name, nodetemplate_dict,node_type)
node_templates.append(nodetemplate)
self.template.nodetemplates = node_templates self.template.nodetemplates = node_templates
tpl_snippet = '''
server:
type: tosca.my.nodes.Compute
properties:
cpu_frequency: 0.05 GHz
disk_size: 500 MB
mem_size: 1 MB
'''
nodetemplates = yamlparser.simple_parse(tpl_snippet)
# print(type(nodetemplates))
# nodetemplate = NodeTemplate('server', nodetemplates)
print('------------------') print('------------------')
# print(node.get_capabilities().keys) # print(node.get_capabilities().keys)
...@@ -72,7 +82,7 @@ class BasicPlanner: ...@@ -72,7 +82,7 @@ class BasicPlanner:
def get_missing_requirements(self, node): def get_missing_requirements(self, node):
def_type = self.template._get_all_custom_defs()[node.type] def_type = self.all_nodes[node.type]
def_requirements = def_type['requirements'] def_requirements = def_type['requirements']
missing_requirements = [] missing_requirements = []
if not node.requirements: if not node.requirements:
......
...@@ -51,7 +51,7 @@ def on_request(ch, method, props, body): ...@@ -51,7 +51,7 @@ def on_request(ch, method, props, body):
ch.basic_publish(exchange='', ch.basic_publish(exchange='',
routing_key=props.reply_to, routing_key=props.reply_to,
properties=pika.BasicProperties(correlation_id=\ properties=pika.BasicProperties(correlation_id=
props.correlation_id), props.correlation_id),
body=str(response)) body=str(response))
ch.basic_ack(delivery_tag=method.delivery_tag) ch.basic_ack(delivery_tag=method.delivery_tag)
......
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