Commit 69b3d53d authored by Spiros Koulouzis's avatar Spiros Koulouzis

dump yaml

parent f00d0c31
...@@ -59,6 +59,6 @@ node_types: ...@@ -59,6 +59,6 @@ node_types:
relationship: tosca.relationships.HostedOn relationship: tosca.relationships.HostedOn
interfaces: interfaces:
Standard: Standard:
create: https://raw.githubusercontent.com/indigo-dc/tosca-types/master/artifacts/mysql/mysql_install.yml create: interfaces/playbooks/kubernetes_install.yaml
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<python-data xmlns="http://nbpython.dev.java.net/ns/php-project/1">
<main.file>rpc_server.py</main.file>
<platform.active>Python_3.6.6</platform.active>
</python-data>
</project-shared-configuration>
...@@ -28,7 +28,7 @@ class BasicPlanner: ...@@ -28,7 +28,7 @@ class BasicPlanner:
self.all_nodes.update(self.tosca_node_types.items()) self.all_nodes.update(self.tosca_node_types.items())
self.all_nodes.update(self.all_custom_def.items()) self.all_nodes.update(self.all_custom_def.items())
capable_node_types = []
node_templates = [] node_templates = []
capable_node_name = '' capable_node_name = ''
for node in self.template.nodetemplates: for node in self.template.nodetemplates:
...@@ -46,18 +46,13 @@ class BasicPlanner: ...@@ -46,18 +46,13 @@ class BasicPlanner:
req[next(iter(req))]['node'] = capable_node_name req[next(iter(req))]['node'] = capable_node_name
node.requirements.append(req) node.requirements.append(req)
node_templates.append(node) node_templates.append(node)
for node_type in capable_node_types:
nodetemplate = self.node_type_2_node_template(node_type)
node_templates.append(nodetemplate)
self.template.nodetemplates = node_templates self.template.nodetemplates = node_templates
t = self.template
# print(yaml.dump(self.template.tpl))
tp = TOSCAParser() tp = TOSCAParser()
tp.tosca_template2_yaml(self.template) tp.tosca_template2_yaml(t)
print('------------------') print('------------------')
...@@ -161,7 +156,6 @@ class BasicPlanner: ...@@ -161,7 +156,6 @@ class BasicPlanner:
if 'type' in node_type[next(iter(node_type))]: if 'type' in node_type[next(iter(node_type))]:
node_type[next(iter(node_type))].pop('type') node_type[next(iter(node_type))].pop('type')
return NodeTemplate(name, nodetemplate_dict,node_type) return NodeTemplate(name, nodetemplate_dict,node_type)
......
...@@ -23,7 +23,7 @@ SECTIONS = (DEFINITION_VERSION, DEFAULT_NAMESPACE, TEMPLATE_NAME, ...@@ -23,7 +23,7 @@ SECTIONS = (DEFINITION_VERSION, DEFAULT_NAMESPACE, TEMPLATE_NAME,
CAPABILITY_TYPES, ARTIFACT_TYPES, DATA_TYPES, INTERFACE_TYPES, CAPABILITY_TYPES, ARTIFACT_TYPES, DATA_TYPES, INTERFACE_TYPES,
POLICY_TYPES, GROUP_TYPES, REPOSITORIES,INPUTS,NODE_TEMPLATES, POLICY_TYPES, GROUP_TYPES, REPOSITORIES,INPUTS,NODE_TEMPLATES,
OUTPUTS,GROUPS,SUBSTITUION_MAPPINGS,POLICIES,TYPE,REQUIREMENTS, OUTPUTS,GROUPS,SUBSTITUION_MAPPINGS,POLICIES,TYPE,REQUIREMENTS,
ARTIFACTS,PROPERTIES) = \ ARTIFACTS,PROPERTIES,INTERFACES) = \
('tosca_definitions_version', 'tosca_default_namespace', ('tosca_definitions_version', 'tosca_default_namespace',
'template_name', 'tosca_template', 'template_author', 'template_name', 'tosca_template', 'template_author',
'template_version', 'description', 'imports', 'dsl_definitions', 'template_version', 'description', 'imports', 'dsl_definitions',
...@@ -31,26 +31,21 @@ SECTIONS = (DEFINITION_VERSION, DEFAULT_NAMESPACE, TEMPLATE_NAME, ...@@ -31,26 +31,21 @@ SECTIONS = (DEFINITION_VERSION, DEFAULT_NAMESPACE, TEMPLATE_NAME,
'capability_types', 'artifact_types', 'data_types', 'capability_types', 'artifact_types', 'data_types',
'interface_types', 'policy_types', 'group_types', 'repositories', 'interface_types', 'policy_types', 'group_types', 'repositories',
'inputs','node_templates','outputs','groups','substitution_mappings', 'inputs','node_templates','outputs','groups','substitution_mappings',
'policies','type','requirements','artifacts','properties') 'policies','type','requirements','artifacts','properties','interfaces')
class TOSCAParser: class TOSCAParser:
def tosca_template2_yaml(self, tosca_template): def tosca_template2_yaml(self, tosca_template):
# print(type(tosca_template.tpl['topology_template']['node_templates']['mysql']))
# print((tosca_template.tpl['topology_template']['node_templates']))
topology_dict = {} topology_dict = {}
topology_dict[DEFINITION_VERSION] = tosca_template.version topology_dict[DEFINITION_VERSION] = tosca_template.version
topology_dict[IMPORTS] = tosca_template._tpl_imports() topology_dict[IMPORTS] = tosca_template._tpl_imports()
topology_dict[DESCRIPTION] = tosca_template.description topology_dict[DESCRIPTION] = tosca_template.description
topology_dict[TOPOLOGY_TEMPLATE] = {} topology_dict[TOPOLOGY_TEMPLATE] = {}
topology_dict[TOPOLOGY_TEMPLATE][NODE_TEMPLATES] = {} topology_dict[TOPOLOGY_TEMPLATE][NODE_TEMPLATES] = {}
node_templates = tosca_template.topology_template.nodetemplates node_templates = tosca_template.nodetemplates
for node_template in node_templates: for node_template in node_templates:
node_template_dict = self.get_node_template_dict(node_template) node_template_dict = self.get_node_template_dict(node_template)
topology_dict[TOPOLOGY_TEMPLATE][NODE_TEMPLATES][node_template.name] = node_template_dict topology_dict[TOPOLOGY_TEMPLATE][NODE_TEMPLATES][node_template.name] = node_template_dict
break
# If we don't add this then dump uses references for the same dictionary entries i.e. '&id001' # If we don't add this then dump uses references for the same dictionary entries i.e. '&id001'
yaml.Dumper.ignore_aliases = lambda *args : True yaml.Dumper.ignore_aliases = lambda *args : True
...@@ -61,10 +56,22 @@ class TOSCAParser: ...@@ -61,10 +56,22 @@ class TOSCAParser:
node_template_dict = {} node_template_dict = {}
node_template_dict[TYPE] = node_template.type node_template_dict[TYPE] = node_template.type
# node_template_dict[REQUIREMENTS] = {} # node_template_dict[REQUIREMENTS] = {}
node_template_dict[REQUIREMENTS] = node_template.requirements if node_template.requirements:
node_template_dict[ARTIFACTS] = node_template.templates[node_template.name][ARTIFACTS] node_template_dict[REQUIREMENTS] = node_template.requirements
node_template_dict[PROPERTIES] = node_template.templates[node_template.name][PROPERTIES] # if node_template.interfaces:
print(dir(node_template)) # interfaces = {}
# for interface in node_template.interfaces:
# interfaces[interface.type] = {}
# interfaces[interface.type][interface.name] = interface.implementation
# print( node_template.templates[node_template.name] )
if ARTIFACTS in node_template.templates[node_template.name].keys():
node_template_dict[ARTIFACTS] = node_template.templates[node_template.name][ARTIFACTS]
if PROPERTIES in node_template.templates[node_template.name].keys():
node_template_dict[PROPERTIES] = node_template.templates[node_template.name][PROPERTIES]
if INTERFACES in node_template.templates[node_template.name].keys():
node_template_dict[INTERFACES] = node_template.templates[node_template.name][INTERFACES]
# print(dir(node_template))
# print(node_template.templates) # print(node_template.templates)
......
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