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/tosca/run.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/tosca/run.py')
-rw-r--r-- | catalog-be/src/main/resources/scripts/sdcBePy/tosca/run.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/run.py b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/run.py new file mode 100644 index 0000000000..955acff930 --- /dev/null +++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/run.py @@ -0,0 +1,29 @@ +import json + +from sdcBePy import properties +from sdcBePy.common.logger import print_and_exit + +from sdcBePy.tosca.imports.run import main as import_main +from sdcBePy.tosca.main import parse_and_create_proxy +from sdcBePy.tosca.upgrade.run import main as upgrade_main + + +def run(): + sdc_be_proxy, update_version = parse_and_create_proxy() + + response = sdc_be_proxy.get_normatives() + + resources = [] + if response == 200: + resources = json.loads(sdc_be_proxy.get_response_from_buffer())["resources"] + else: + print_and_exit(response, "Can't get normatives!") + + if len(resources) < properties.resource_len: + import_main(sdc_be_proxy, update_version) + else: + upgrade_main(sdc_be_proxy) + + +if __name__ == '__main__': + run() |