summaryrefslogtreecommitdiffstats
path: root/simple_compose_stdin.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 /simple_compose_stdin.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 'simple_compose_stdin.py')
-rw-r--r--simple_compose_stdin.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/simple_compose_stdin.py b/simple_compose_stdin.py
new file mode 100644
index 0000000..532c57a
--- /dev/null
+++ b/simple_compose_stdin.py
@@ -0,0 +1,35 @@
+#Author: Shu Shi
+#emaiL: shushi@research.att.com
+
+import sys, json, base64, logging
+
+from toscalib.tosca_workbook import ToscaWorkBook
+
+input_data = sys.stdin.readline()
+try:
+ in_data = json.loads(input_data)
+except ValueError as e:
+ logging.error( 'error, cannot load input json data: ' + str(input_data))
+
+workbook = ToscaWorkBook()
+workbook._import_dir('./data/shared_model/')
+
+#if in_data.has_key('models'):
+if 'models' in in_data:
+ in_model = in_data['models']
+ if type(in_model) != list:
+ logging.warning( 'models in the input should be a list type')
+ for model_entry in in_model:
+ for key in ['schema', 'template', 'translate']:
+# if model_entry.has_key(key):
+ if key in model_entry:
+ workbook._import_yml_str(base64.b64decode(model_entry[key]))
+
+#if in_data.has_key('template'):
+if 'template' in in_data:
+ in_temp = in_data['template']
+ workbook._translate_template_yaml_str(base64.b64decode(in_temp))
+ workbook._add_shared_node([{'dcae.capabilities.cdapHost':'cdap_host'}, {'dcae.capabilities.dockerHost': 'docker_host'}, {'dcae.capabilities.composition.host': 'composition_virtual'}])
+
+ret = workbook._export_yaml_web('cloudify,main')
+print(ret)