Commit e0127d00 authored by Spiros Koulouzis's avatar Spiros Koulouzis

create NodeTemplate from types

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