diff options
author | k.kedron <k.kedron@partner.samsung.com> | 2020-06-05 14:51:01 +0200 |
---|---|---|
committer | Krystian Kedron <k.kedron@partner.samsung.com> | 2020-06-24 09:21:00 +0000 |
commit | 16fe29ac226610f79c8da1f691437ec7fe6e79c4 (patch) | |
tree | 5b73d8f1724c561609c05fd2802ad80b7acfb4c0 /catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaElements.py | |
parent | fca8a0b1af32083b8ea025135b120091aec9714f (diff) |
Improvement sdc-BE-init python scripts
- Implemented retries when request fail
- Moved configuration variables to the Properties file
- Extended sdcBeProxy
- Implemented script to run import/update (should fix deployment glitch)
- Updated the import_Normatives recipes to use new script
Issue-ID: SDC-2784
Signed-off-by: Krystian Kedron <k.kedron@partner.samsung.com>
Change-Id: I83fab898783ad8d3b3d532af43d75bc54d033c33
Diffstat (limited to 'catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaElements.py')
-rw-r--r-- | catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaElements.py | 15 |
1 files changed, 9 insertions, 6 deletions
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 1d4e734351..5cdca0a095 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 @@ -3,8 +3,9 @@ import zipfile import pycurl -from sdcBePy.common.logger import debug, log, print_name_and_return_code, error_and_exit +from sdcBePy.common.logger import debug, log, print_name_and_return_code, print_and_exit from sdcBePy.common.sdcBeProxy import SdcBeProxy +from sdcBePy.common.errors import ResourceCreationError def process_and_create_normative_element(normative_element, @@ -49,9 +50,11 @@ def _send_request(sdc_be_proxy, file_dir, url_suffix, element_name, http_res = sdc_be_proxy.post_file(url_suffix, multi_part_form_data) if http_res is not None: debug("http response =", http_res) - debug("response buffer", str(sdc_be_proxy.con.buffer.getvalue(), "UTF-8")) + + response = sdc_be_proxy.get_response_from_buffer() + debug("response buffer", response) # c.close() - return element_name, http_res, sdc_be_proxy.con.buffer.getvalue() + return element_name, http_res, response except Exception as inst: print("ERROR=" + str(inst)) @@ -99,9 +102,9 @@ def print_and_check_result(result, exit_on_success): if result is not None: print_name_and_return_code(result[0], result[1]) if result[1] is None or result[1] not in [200, 201, 409]: - error_and_exit(1, "Failed to create the normatives elements!!") + raise ResourceCreationError("Failed to create the normatives elements!!", 1) else: if exit_on_success is True: - error_and_exit(0, "All normatives elements created successfully!!") + print_and_exit(0, "All normatives elements created successfully!!") else: - error_and_exit(1, "Results is None!!") + raise ResourceCreationError("Results is None!", 1) |