From ddf9aaefc753b492fb72144d597a27df8080a4ab Mon Sep 17 00:00:00 2001 From: "andre.schmid" Date: Fri, 28 May 2021 19:10:30 +0100 Subject: Init ONAP model imports using the model API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../src/main/resources/scripts/sdcBePy/tosca/upgrade/run.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'catalog-be/src/main/resources/scripts/sdcBePy/tosca/upgrade/run.py') diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/upgrade/run.py b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/upgrade/run.py index cef7dd74db..44a25a0136 100644 --- a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/upgrade/run.py +++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/upgrade/run.py @@ -1,11 +1,14 @@ #!/usr/bin/env python3 import os +from pathlib import Path from sdcBePy.common import logger from sdcBePy.common.logger import print_and_exit 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.model_client import ModelClient +from sdcBePy.tosca.models.model_import_manager import ModelImportManager from sdcBePy.tosca.models.normativeElementsList import get_normative_element_candidate_list, \ get_normative_element_with_metadata_list from sdcBePy.tosca.models.normativeToUpdateList import TypesToUpdate, get_heat_and_normative_to_update_list, \ @@ -21,6 +24,14 @@ def main(sdc_be_proxy): # base_file_location = os.getcwd() + "/../../../../import/tosca/" base_file_location = os.getcwd() + "/" logger.debug("working directory =" + base_file_location) + + model_import_manager = ModelImportManager(Path(base_file_location) / 'models', ModelClient(sdc_be_proxy)) + try: + model_import_manager.update_models() + except Exception as ex: + logger.log("An error has occurred while uploading the models: ", str(ex)) + raise ex + process_element_list(get_normative_element_candidate_list(base_file_location), sdc_be_proxy) all_types = get_all_types() -- cgit 1.2.3-korg