Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
f1e1e884
Commit
f1e1e884
authored
Jul 08, 2019
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added parser to dump yaml
parent
d66a4806
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
1 deletion
+72
-1
basic_planner.py
drip_planner2/src/planner/basic_planner.py
+7
-1
TOSCA_parser.py
drip_planner2/src/utils/TOSCA_parser.py
+65
-0
__init__.py
drip_planner2/src/utils/__init__.py
+0
-0
TOSCA_parser.cpython-36.pyc
...lanner2/src/utils/__pycache__/TOSCA_parser.cpython-36.pyc
+0
-0
__init__.cpython-36.pyc
drip_planner2/src/utils/__pycache__/__init__.cpython-36.pyc
+0
-0
No files found.
drip_planner2/src/planner/basic_planner.py
View file @
f1e1e884
...
...
@@ -13,6 +13,7 @@ import sys
import
pdb
import
names
import
yaml
from
utils.TOSCA_parser
import
*
...
...
@@ -54,6 +55,11 @@ class BasicPlanner:
self
.
template
.
nodetemplates
=
node_templates
# print(yaml.dump(self.template.tpl))
tp
=
TOSCAParser
()
tp
.
tosca_template2_yaml
(
self
.
template
)
print
(
'------------------'
)
# print(node.get_capabilities().keys)
...
...
@@ -62,7 +68,7 @@ class BasicPlanner:
def
get_missing_requirements
(
self
,
node
):
def_type
=
self
.
all_nodes
[
node
.
type
]
def_requirements
=
def_type
[
'requirements'
]
def_requirements
=
def_type
[
'requirements'
]
missing_requirements
=
[]
if
not
node
.
requirements
:
missing_requirements
=
def_requirements
...
...
drip_planner2/src/utils/TOSCA_parser.py
0 → 100644
View file @
f1e1e884
import
json
import
operator
import
pdb
import
re
from
toscaparser.tosca_template
import
ToscaTemplate
from
toscaparser.tosca_template
import
TopologyTemplate
from
toscaparser.elements.nodetype
import
NodeType
from
toscaparser.nodetemplate
import
NodeTemplate
from
toscaparser.utils
import
yamlparser
import
urllib
import
urllib.parse
import
sys
import
pdb
import
names
import
yaml
# TOSCA template key names
SECTIONS
=
(
DEFINITION_VERSION
,
DEFAULT_NAMESPACE
,
TEMPLATE_NAME
,
TOPOLOGY_TEMPLATE
,
TEMPLATE_AUTHOR
,
TEMPLATE_VERSION
,
DESCRIPTION
,
IMPORTS
,
DSL_DEFINITIONS
,
NODE_TYPES
,
RELATIONSHIP_TYPES
,
RELATIONSHIP_TEMPLATES
,
CAPABILITY_TYPES
,
ARTIFACT_TYPES
,
DATA_TYPES
,
INTERFACE_TYPES
,
POLICY_TYPES
,
GROUP_TYPES
,
REPOSITORIES
,
INPUTS
,
NODE_TEMPLATES
,
OUTPUTS
,
GROUPS
,
SUBSTITUION_MAPPINGS
,
POLICIES
,
TYPE
,
REQUIREMENTS
)
=
\
(
'tosca_definitions_version'
,
'tosca_default_namespace'
,
'template_name'
,
'tosca_template'
,
'template_author'
,
'template_version'
,
'description'
,
'imports'
,
'dsl_definitions'
,
'node_types'
,
'relationship_types'
,
'relationship_templates'
,
'capability_types'
,
'artifact_types'
,
'data_types'
,
'interface_types'
,
'policy_types'
,
'group_types'
,
'repositories'
,
'inputs'
,
'node_templates'
,
'outputs'
,
'groups'
,
'substitution_mappings'
,
'policies'
,
'type'
,
'requirements'
)
class
TOSCAParser
:
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
[
DEFINITION_VERSION
]
=
tosca_template
.
version
topology_dict
[
IMPORTS
]
=
tosca_template
.
_tpl_imports
()
topology_dict
[
DESCRIPTION
]
=
tosca_template
.
description
topology_dict
[
TOPOLOGY_TEMPLATE
]
=
{}
topology_dict
[
TOPOLOGY_TEMPLATE
][
NODE_TEMPLATES
]
=
{}
node_templates
=
tosca_template
.
topology_template
.
nodetemplates
for
node_template
in
node_templates
:
node_template_dict
=
self
.
get_node_template_dict
(
node_template
)
topology_dict
[
TOPOLOGY_TEMPLATE
][
NODE_TEMPLATES
][
node_template
.
name
]
=
node_template_dict
yaml
.
Dumper
.
ignore_aliases
=
lambda
*
args
:
True
print
(
yaml
.
dump
(
topology_dict
,
default_flow_style
=
False
))
def
get_node_template_dict
(
self
,
node_template
):
node_template_dict
=
{}
node_template_dict
[
TYPE
]
=
node_template
.
type
node_template_dict
[
REQUIREMENTS
]
=
{}
# requirement_list = []
node_template_dict
[
REQUIREMENTS
]
=
node_template
.
requirements
return
node_template_dict
\ No newline at end of file
drip_planner2/src/utils/__init__.py
0 → 100644
View file @
f1e1e884
drip_planner2/src/utils/__pycache__/TOSCA_parser.cpython-36.pyc
0 → 100644
View file @
f1e1e884
File added
drip_planner2/src/utils/__pycache__/__init__.cpython-36.pyc
0 → 100644
View file @
f1e1e884
File added
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment