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.normativeElementsList import get_normative_element_candidate_list, \
13 get_normative_element_with_metadata_list
14 from sdcBePy.tosca.models.normativeToUpdateList import TypesToUpdate, get_heat_and_normative_to_update_list, \
15 get_onap_sol_to_update_list, get_nfv_to_update_list
18 def main(sdc_be_proxy):
20 update_onap_version = False
21 update_nfv_version = True
23 # use to run script form this dir (not like the command)
24 # base_file_location = os.getcwd() + "/../../../../import/tosca/"
25 base_file_location = os.getcwd() + "/"
26 logger.debug("working directory =" + base_file_location)
28 model_import_manager = ModelImportManager(Path(base_file_location) / 'models', ModelClient(sdc_be_proxy))
30 model_import_manager.deploy_models()
31 except Exception as ex:
32 logger.log("An error has occurred while uploading the models: ", str(ex))
35 process_element_list(get_normative_element_candidate_list(base_file_location), sdc_be_proxy)
37 all_types = get_all_types()
39 heat_and_normative_list = get_heat_and_normative_to_update_list(all_types, base_file_location)
40 process_type_list(heat_and_normative_list, sdc_be_proxy, update_version)
42 onap_sol_list = get_onap_sol_to_update_list(all_types, base_file_location)
43 process_type_list(onap_sol_list, sdc_be_proxy, update_onap_version)
45 nfv_list = get_nfv_to_update_list(all_types, base_file_location)
46 process_type_list(nfv_list, sdc_be_proxy, update_nfv_version)
48 process_element_list(get_normative_element_with_metadata_list(base_file_location), sdc_be_proxy)
50 logger.log("Updating end ->", "All normatives updated successfully!")
51 print_and_exit(0, None)
55 path = os.path.dirname(__file__)
56 return TypesToUpdate([path + "/../data/typesToUpgrade.json",
57 path + "/../data/onapTypesToUpgrade.json"])
61 sdc_be_proxy, _ = parse_and_create_proxy()
65 if __name__ == "__main__":