summaryrefslogtreecommitdiffstats
path: root/app/toscalib/utils/tosca_export.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_export.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_export.py')
-rw-r--r--app/toscalib/utils/tosca_export.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/app/toscalib/utils/tosca_export.py b/app/toscalib/utils/tosca_export.py
new file mode 100644
index 0000000..c4399ef
--- /dev/null
+++ b/app/toscalib/utils/tosca_export.py
@@ -0,0 +1,40 @@
+#Author: Shu Shi
+#emaiL: shushi@research.att.com
+
+
+import yaml
+import re
+from toscalib.templates.constant import *
+
+def _yaml_export(filename, content):
+ out_str = yaml.safe_dump(content, default_flow_style=False, width=float("inf"))
+ out_str = re.sub(YMO_PREFIX, '', out_str)
+ if filename == 'WEB':
+ return out_str
+ with open(filename, 'w') as outfile:
+ outfile.write(out_str)
+ return out_str
+
+def _heat_export(filename, content):
+ heat_ver = YMO_PREFIX + 'heat_template_version'
+ heat_content = content[YMO_TOPOLOGY]
+ if heat_content is None:
+ heat_content = {}
+ heat_content[heat_ver] = '2013-05-23'
+# if heat_content.has_key(YMO_TOPO_OUTPUTS):
+ if YMO_TOPO_OUTPUTS in heat_content:
+ heat_content.pop(YMO_TOPO_OUTPUTS)
+
+ out_str = yaml.dump(heat_content, default_flow_style=False)
+ out_str = re.sub(YMO_TOPO_INPUTS, YMO_PREFIX+'parameters', out_str)
+ out_str = re.sub(YMO_TOPO_NODE_TEMPLATES, YMO_PREFIX+'resources', out_str)
+
+ out_str = re.sub('get_input', 'get_param', out_str)
+ out_str = re.sub('get_attribute', 'get_attr', out_str)
+ out_str = re.sub('get_id', 'get_resource', out_str)
+ out_str = re.sub('get_property', 'get_attr', out_str)
+ out_str = re.sub('type: integer', 'type: number', out_str)
+
+ out_str = re.sub(YMO_PREFIX, '', out_str)
+ with open(filename, 'w') as outfile:
+ outfile.write(out_str)