summaryrefslogtreecommitdiffstats
path: root/app/toscalib/utils/tosca_print.py
diff options
context:
space:
mode:
authorStone, Avi (as206k) <as206k@att.com>2018-04-12 16:41:45 +0300
committerStone, Avi (as206k) <as206k@att.com>2018-04-12 16:41:45 +0300
commit879e94b78193798e8b170fca9b924d2c3881f7ba (patch)
tree150de697138a7593869eaae455add025b06a6e04 /app/toscalib/utils/tosca_print.py
parent7e02c7aaab14828ef8baaef98865f26d98e3b795 (diff)
DCAE-D tosca-lab initial commit
DCAE-D tosca-lab initial commit Change-Id: Ia42934ce7c75abe05fa106585c9334c8b048ee36 Issue-ID: SDC-1218 Signed-off-by: Stone, Avi (as206k) <as206k@att.com>
Diffstat (limited to 'app/toscalib/utils/tosca_print.py')
-rw-r--r--app/toscalib/utils/tosca_print.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/app/toscalib/utils/tosca_print.py b/app/toscalib/utils/tosca_print.py
new file mode 100644
index 0000000..a7205e3
--- /dev/null
+++ b/app/toscalib/utils/tosca_print.py
@@ -0,0 +1,58 @@
+#Author: Shu Shi
+#emaiL: shushi@research.att.com
+
+
+LEVEL_NODE_NAME = 1
+LEVEL_NODE_DETAILS = 2
+LEVEL_NODE_EVERYTHING = 3
+
+def _print_template(template, level=LEVEL_NODE_DETAILS):
+ print_str = ''
+ if template is None:
+ return print_str
+ print_str += 'Nodes:'+ '\n'
+ for node in iter(template.node_dict.values()):
+ print_str += _print_node(node, level)
+ return print_str
+
+def _print_node(node, level):
+ print_str = ''
+ if node is None:
+ return
+ print_str += ' '+ node.name + '\n'
+ print_str += ' type: '+ node.type+ '\n'
+ if level == LEVEL_NODE_DETAILS:
+ if len(node.properties) > 0:
+ print_str += ' properties:' + '\n'
+ for prop in iter(node.properties.values()):
+ if prop.filled:
+ print_str += ' '+ prop.name+ ': '+ str(prop.value._get_value()[0])+ '\n'
+ else:
+ print_str += ' '+ prop.name+ ': null'+ '\n'
+ if len(node.requirements)> 0:
+ print_str += ' requirements:'+ '\n'
+ for req in node.requirements:
+ if req.filled:
+ print_str += ' '+ req.name+ ': '+ req.value.name+ '\n'
+ else:
+ print_str += ' '+ req.name+ ': null'+ '\n'
+ print_str += ''+ '\n'
+ return print_str
+
+
+def _print_node_types(db):
+ print_str = 'Available node types: '+ '\n'
+ for name in db.NODE_TYPES.keys():
+ print_str += name, '\n'
+ return print_str
+
+def _print_templates(db):
+ print_str = 'Available templates: '+ '\n'
+ for name in db.TEMPLATES.keys():
+ print_str += name, '\n'
+ return print_str
+
+def _print_node_type(node_type):
+ print_str = 'Node Type Definition: '+ node_type.name+ '\n'
+ print_str += node_type.raw_content+ '\n'
+ return print_str