diff options
Diffstat (limited to 'catalog-be/src/main/resources/scripts/sdcBePy/common/normative')
-rw-r--r-- | catalog-be/src/main/resources/scripts/sdcBePy/common/normative/main.py | 6 | ||||
-rw-r--r-- | catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaElements.py | 16 |
2 files changed, 14 insertions, 8 deletions
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/main.py b/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/main.py index ad8338cee4..805f0b0167 100644 --- a/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/main.py +++ b/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/main.py @@ -11,14 +11,16 @@ from sdcBePy import properties colors = BColors() -def process_element_list(normative_elements_list, sdc_be_proxy): +def process_element_list(normative_elements_list, sdc_be_proxy, model=None): attempt = 0 for normative_element in normative_elements_list: + if normative_element is None: + continue while True: attempt += 1 try: process_and_create_normative_element(normative_element, - sdc_be_proxy=sdc_be_proxy) + sdc_be_proxy=sdc_be_proxy, model=model) break except ResourceCreationError as e: _check_and_retry(attempt, e.error_code, e.message) diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaElements.py b/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaElements.py index 654a755863..8506207ff9 100644 --- a/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaElements.py +++ b/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaElements.py @@ -10,7 +10,7 @@ from sdcBePy.common.errors import ResourceCreationError def process_and_create_normative_element(normative_element, scheme=None, be_host=None, be_port=None, header=None, admin_user=None, sdc_be_proxy=None, - debug=False, + model=None, debug=False, exit_on_success=False): if sdc_be_proxy is None: sdc_be_proxy = SdcBeProxy(be_host, be_port, header, scheme, admin_user, debug=debug) @@ -21,31 +21,33 @@ def process_and_create_normative_element(normative_element, url_suffix, element_name, element_from_name, + model, with_metadata, exit_on_success) def _create_normative_element(sdc_be_proxy, file_dir, - url_suffix, element_name, element_form_name, with_metadata=False, + url_suffix, element_name, element_form_name, model, with_metadata=False, exit_on_success=False): result = _send_request(sdc_be_proxy, file_dir, url_suffix, element_name, element_form_name, + model, with_metadata) print_and_check_result(result, exit_on_success) def _send_request(sdc_be_proxy, file_dir, url_suffix, element_name, - element_form_name, + element_form_name, model, with_metadata=False): try: log("create normative element ", element_name) type_file_name = file_dir + element_name multi_part_form_data = _create_multipart_form_data(element_form_name, type_file_name, with_metadata, - element_name) + element_name, model) debug("http request url =", url_suffix) http_res = sdc_be_proxy.post_file(url_suffix, multi_part_form_data) @@ -62,12 +64,15 @@ def _send_request(sdc_be_proxy, file_dir, url_suffix, element_name, return element_name, None, None -def _create_multipart_form_data(element_form_name, type_file_name, with_metadata, element_name): +def _create_multipart_form_data(element_form_name, type_file_name, with_metadata, element_name, model): 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) multi_part_form_data.append(metadata_type_part) + if model is not None: + model_data = ("model", model) + multi_part_form_data.append(model_data) debug(multi_part_form_data) return multi_part_form_data @@ -76,7 +81,6 @@ def _create_metadata_multipart(type_file_name): metadata = _create_json_metadata_str(type_file_name) return "toscaTypeMetadata", metadata - 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') |