diff options
author | Tal Gitelman <tg851x@intl.att.com> | 2018-08-16 16:27:12 +0300 |
---|---|---|
committer | Michael Lando <ml636r@att.com> | 2018-08-20 02:51:19 +0000 |
commit | 3e7c13579da7ff25b308cb577efdd04fd7ca9696 (patch) | |
tree | ec73d5cfecd514d2b31e09aa8ae3eff91ecfb5e1 /catalog-be/src/main/resources/scripts/import/tosca/importNormativeElements.py | |
parent | 61919ec216756da63bd43983c3f522b402de4cb6 (diff) |
Import normative improvement
Change-Id: I6db32d8107874b2454b75348d909b295030a556f
Issue-ID: SDC-557
Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
Diffstat (limited to 'catalog-be/src/main/resources/scripts/import/tosca/importNormativeElements.py')
-rw-r--r-- | catalog-be/src/main/resources/scripts/import/tosca/importNormativeElements.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/catalog-be/src/main/resources/scripts/import/tosca/importNormativeElements.py b/catalog-be/src/main/resources/scripts/import/tosca/importNormativeElements.py index 347898a815..453ee3aebc 100644 --- a/catalog-be/src/main/resources/scripts/import/tosca/importNormativeElements.py +++ b/catalog-be/src/main/resources/scripts/import/tosca/importNormativeElements.py @@ -1,4 +1,5 @@ import pycurl +import zipfile from StringIO import StringIO import json import copy @@ -47,7 +48,7 @@ def createNormativeElement(scheme, be_host, be_port, admin_user, file_dir, url_s type_file_name = file_dir + "/" + element_name - multi_part_form_data = create_multipart_form_data(element_form_name, type_file_name, with_metadata) + multi_part_form_data = create_multipart_form_data(element_form_name, type_file_name, with_metadata, element_name) c.setopt(pycurl.HTTPPOST, multi_part_form_data) c.setopt(c.WRITEFUNCTION, buffer.write) @@ -69,8 +70,8 @@ def createNormativeElement(scheme, be_host, be_port, admin_user, file_dir, url_s return (element_name, None, None) -def create_multipart_form_data(element_form_name, type_file_name, with_metadata): - tosca_type_zip_part = create_zip_file_multi_part(element_form_name, type_file_name) +def create_multipart_form_data(element_form_name, type_file_name, with_metadata, element_name): + tosca_type_zip_part = create_zip_file_multi_part(element_form_name, type_file_name, element_name) multi_part_form_data = [tosca_type_zip_part] if with_metadata: metadata_type_part = create_metadata_multipart(type_file_name) @@ -84,7 +85,11 @@ def create_metadata_multipart(type_file_name): return ("toscaTypeMetadata", metadata) -def create_zip_file_multi_part(element_form_name, type_file_name): +def create_zip_file_multi_part(element_form_name, type_file_name, element_name): + zf = zipfile.ZipFile(type_file_name + ".zip", "w") + zf.write(type_file_name + '.yml', element_name + '.yml') + zf.close() + tosca_type_zip_path = type_file_name + ".zip" tosca_type_zip_part = (element_form_name, (pycurl.FORM_FILE, tosca_type_zip_path)) return tosca_type_zip_part |