X-Git-Url: https://gerrit.onap.org/r/gitweb?p=demo.git;a=blobdiff_plain;f=heat%2FvFW_CNF_CDS%2Fautomation%2Finstantiate.py;h=7363c4794a21b89485cbd1749f68f9dc33421f48;hp=0316f113c178fd2b62925c10d17537803c276a0b;hb=1ff5827ffde7af1d8aed23890a571455300ade6d;hpb=6a7d598d08aa0e145a5aff71c4ed6deafb098e39 diff --git a/heat/vFW_CNF_CDS/automation/instantiate.py b/heat/vFW_CNF_CDS/automation/instantiate.py index 0316f113..7363c479 100755 --- a/heat/vFW_CNF_CDS/automation/instantiate.py +++ b/heat/vFW_CNF_CDS/automation/instantiate.py @@ -18,6 +18,7 @@ import logging import zipfile from io import BytesIO +from time import sleep from uuid import uuid4 import oyaml as yaml @@ -37,6 +38,7 @@ from onapsdk.so.instantiation import ( InstantiationParameter, VnfParameters, VfmoduleParameters) from onapsdk.sdc.service import Service from onapsdk.vid import LineOfBusiness, OwningEntity, Platform, Project +from onapsdk.so.so_element import OrchestrationRequest logger = logging.getLogger("") logger.setLevel(logging.DEBUG) @@ -141,10 +143,10 @@ for vnf in service.vnfs: vf_module_label = vf_module.properties["vf_module_label"] if vf_module_label == "base_template_dummy_ignore": continue - profile_name = Config.VF_MODULE_LIST[vf_module_label]["k8s-rb-profile-name"] + profile_name = Config.VF_MODULE_PARAM_LIST[vf_module_label]["k8s-rb-profile-name"] try: profile = definition.get_profile_by_name(profile_name) - if profile.namespace != Config.VF_MODULE_LIST[vf_module_label]["k8s-rb-profile-namespace"]: + if profile.namespace != Config.VF_MODULE_PARAM_LIST[vf_module_label]["k8s-rb-profile-namespace"]: profile.delete() logger.info("Profile: " + profile_name + " for " + vf_module.name + " deleted") else: @@ -153,6 +155,7 @@ for vnf in service.vnfs: except ValueError: logger.info("Profile: " + profile_name + " for " + vf_module.name + " not found") + # Read SDNC MODEL NAME and VERSION from CBA.zip logger.info("*******************************") logger.info("Retrieving SDNC MODEL NAME and VERSION") @@ -175,23 +178,32 @@ for se in service_subscription.service_instances: if not service_instance: logger.info("******** Service Instance not existing: Instantiate *******") # Instantiate service - vfmodules_list = Config.VF_MODULE_LIST + vfmodules_list = Config.VF_MODULE_PARAM_LIST + vnf_param_list = Config.VNF_PARAM_LIST vnf_param = [ InstantiationParameter(name="sdnc_model_name", value=SDNC_MODEL_NAME), InstantiationParameter(name="sdnc_model_version", value=SDNC_MODEL_VERSION), InstantiationParameter(name="sdnc_artifact_name", value=Config.SDNC_ARTIFACT_NAME)] + for vnf_param_name, vnf_param_value in vnf_param_list.items(): + vnf_param.append( + InstantiationParameter(name=vnf_param_name, value=vnf_param_value) + ) + vfmodules_param = [] for vfmodule in vfmodules_list: params = [ - InstantiationParameter(name="k8s-rb-profile-name", value=vfmodules_list[vfmodule]["k8s-rb-profile-name"]), - InstantiationParameter(name="k8s-rb-profile-namespace", value=vfmodules_list[vfmodule]["k8s-rb-profile-namespace"]), InstantiationParameter(name="sdnc_model_name", value=SDNC_MODEL_NAME), InstantiationParameter(name="sdnc_model_version", value=SDNC_MODEL_VERSION), - InstantiationParameter(name="vf_module_label", value=vfmodules_list[vfmodule]["name"])] + InstantiationParameter(name="vf_module_label", value=vfmodule)] + + for vfmodule_param_name, vfmodule_param_value in vfmodules_list[vfmodule].items(): + params.append( + InstantiationParameter(name=vfmodule_param_name, value=vfmodule_param_value) + ) - vfmodules_param.append(VfmoduleParameters(vfmodules_list[vfmodule]["name"], params)) + vfmodules_param.append(VfmoduleParameters(vfmodule, params)) vnf_params = VnfParameters(name=Config.VFNAME, vnf_parameters=vnf_param, vfmodule_parameters=vfmodules_param) @@ -207,3 +219,9 @@ if not service_instance: service_instance_name=Config.SERVICE_INSTANCE_NAME, vnf_parameters=[vnf_params] ) + status = None + while not (status == OrchestrationRequest.StatusEnum.COMPLETED + or status == OrchestrationRequest.StatusEnum.FAILED): + sleep(10) + status = service_instantiation.status + logger.info(f"Orchestration status is: {status.value}")