4 from pathlib import Path
6 from sdcBePy.common import logger
7 from sdcBePy.common.logger import print_and_exit
8 from sdcBePy.common.normative.main import process_element_list, process_type_list
9 from sdcBePy.tosca.main import parse_and_create_proxy
10 from sdcBePy.tosca.models.model_client import ModelClient
11 from sdcBePy.tosca.models.model_import_manager import ModelImportManager
12 from sdcBePy.tosca.models.node_type_client import NodeTypeClient
13 from sdcBePy.tosca.models.normativeElementsList import get_normative_element_candidate_list, \
14 get_normative_element_with_metadata_list
15 from sdcBePy.tosca.models.normativeToUpdateList import TypesToUpdate, get_heat_and_normative_to_update_list, \
16 get_onap_sol_to_update_list, get_nfv_to_update_list
19 def main(sdc_be_proxy):
21 update_onap_version = False
22 update_nfv_version = True
24 # use to run script form this dir (not like the command)
25 # base_file_location = os.getcwd() + "/../../../../import/tosca/"
26 base_file_location = os.getcwd() + "/"
27 logger.debug("working directory =" + base_file_location)
29 model_import_manager = ModelImportManager(Path(base_file_location) / 'models', ModelClient(sdc_be_proxy),
30 NodeTypeClient(sdc_be_proxy))
32 model_import_manager.deploy_models()
33 except Exception as ex:
34 logger.log("An error has occurred while uploading the models: ", str(ex))
37 process_element_list(get_normative_element_candidate_list(base_file_location), sdc_be_proxy)
39 all_types = get_all_types()
41 heat_and_normative_list = get_heat_and_normative_to_update_list(all_types, base_file_location)
42 process_type_list(heat_and_normative_list, sdc_be_proxy, update_version)
44 onap_sol_list = get_onap_sol_to_update_list(all_types, base_file_location)
45 process_type_list(onap_sol_list, sdc_be_proxy, update_onap_version)
47 nfv_list = get_nfv_to_update_list(all_types, base_file_location)
48 process_type_list(nfv_list, sdc_be_proxy, update_nfv_version)
50 process_element_list(get_normative_element_with_metadata_list(base_file_location), sdc_be_proxy)
52 logger.log("Updating end ->", "All normatives updated successfully!")
53 print_and_exit(0, None)
57 path = os.path.dirname(__file__)
58 return TypesToUpdate([path + "/../data/typesToUpgrade.json",
59 path + "/../data/onapTypesToUpgrade.json"])
63 sdc_be_proxy, _ = parse_and_create_proxy()
67 if __name__ == "__main__":