diff options
author | andre.schmid <andre.schmid@est.tech> | 2021-05-28 19:10:30 +0100 |
---|---|---|
committer | Christophe Closset <christophe.closset@intl.att.com> | 2021-06-14 08:19:21 +0000 |
commit | ddf9aaefc753b492fb72144d597a27df8080a4ab (patch) | |
tree | 8d998a1287b903f6669df8568bdb6d2edda60eac /catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/run.py | |
parent | c82aebcde26e34c4151531b4d7a8f6e7689734ba (diff) |
Init ONAP model imports using the model API
Creates a client for the model endpoint in the catalog init scripts.
Introduces the directory structure to provide the models along its
imports, separated by init/upgrade phase.
Each model structure will be zipped and uploaded to the endpoint,
based on the model directory name.
Change-Id: I0392c1e6d3a29b30567b11016041a8e9cccbc745
Issue-ID: SDC-3615
Signed-off-by: André Schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/run.py')
-rw-r--r-- | catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/run.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/run.py b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/run.py index 9ac820071a..067f110efc 100644 --- a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/run.py +++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/run.py @@ -1,13 +1,15 @@ #!/usr/bin/env python3 import os +from pathlib import Path import sdcBePy.common.logger as logger from sdcBePy.common.normative.main import process_element_list, process_type_list from sdcBePy.tosca.main import parse_and_create_proxy -from sdcBePy.tosca.models.normativeElementsList import get_normative_element_candidate_list, \ - get_normative_element_with_metadata_list -from sdcBePy.tosca.models.normativeTypesList import get_normative_type_candidate_list +from sdcBePy.tosca.models import normativeElementsList +from sdcBePy.tosca.models import normativeTypesList +from sdcBePy.tosca.models.model_client import ModelClient +from sdcBePy.tosca.models.model_import_manager import ModelImportManager def main(sdc_be_proxy, update_version): @@ -16,9 +18,16 @@ def main(sdc_be_proxy, update_version): base_file_location = os.getcwd() + os.path.sep logger.debug("working directory =" + base_file_location) - process_element_list(get_normative_element_candidate_list(base_file_location), sdc_be_proxy) - process_type_list(get_normative_type_candidate_list(base_file_location), sdc_be_proxy, update_version) - process_element_list(get_normative_element_with_metadata_list(base_file_location), sdc_be_proxy) + model_import_manager = ModelImportManager(Path(base_file_location) / 'models', ModelClient(sdc_be_proxy)) + try: + model_import_manager.create_models() + except Exception as ex: + logger.log("An error has occurred while uploading the models: ", str(ex)) + raise ex + + process_element_list(normativeElementsList.get_normative_element_candidate_list(base_file_location), sdc_be_proxy) + process_type_list(normativeTypesList.get_normative_type_candidate_list(base_file_location), sdc_be_proxy, update_version) + process_element_list(normativeElementsList.get_normative_element_with_metadata_list(base_file_location), sdc_be_proxy) logger.log("Script end ->", "All normatives imported successfully!") logger.print_and_exit(0, None) |