X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_ro%2Fnfvo.py;h=b0a6a6481ac2a572c96fdf440758dbfc1fca8765;hb=c19c5653c9ca00d27f4a9247973e5a811f14dfde;hp=d433ac96c386bfad62c8cc8598c946ac9b559214;hpb=8a2d20725d5b3ad32946affd7bea7388434094e9;p=osm%2FRO.git diff --git a/osm_ro/nfvo.py b/osm_ro/nfvo.py index d433ac96..b0a6a648 100644 --- a/osm_ro/nfvo.py +++ b/osm_ro/nfvo.py @@ -126,11 +126,12 @@ def get_non_used_vim_name(datacenter_name, datacenter_id, tenant_name, tenant_id if name not in vim_threads["names"]: vim_threads["names"].append(name) return name - name = datacenter_name[:16] + "." + tenant_name[:16] - if name not in vim_threads["names"]: - vim_threads["names"].append(name) - return name - name = datacenter_id + "-" + tenant_id + if tenant_name: + name = datacenter_name[:16] + "." + tenant_name[:16] + if name not in vim_threads["names"]: + vim_threads["names"].append(name) + return name + name = datacenter_id vim_threads["names"].append(name) return name @@ -237,7 +238,7 @@ def start_service(mydb, persistence=None, wim=None): except Exception as e: raise NfvoException("Error at VIM {}; {}: {}".format(vim["type"], type(e).__name__, e), httperrors.Internal_Server_Error) - thread_name = get_non_used_vim_name(vim['datacenter_name'], vim['vim_tenant_id'], vim['vim_tenant_name'], + thread_name = get_non_used_vim_name(vim['datacenter_name'], vim['datacenter_id'], vim['vim_tenant_name'], vim['vim_tenant_id']) new_thread = vim_thread.vim_thread(task_lock, thread_name, vim['datacenter_name'], vim['datacenter_tenant_id'], db=db, db_lock=db_lock, ovim=ovim) @@ -880,6 +881,21 @@ def _lookfor_or_create_image(db_image, mydb, descriptor): db_image["uuid"] = image_uuid return None +def get_resource_allocation_params(quota_descriptor): + """ + read the quota_descriptor from vnfd and fetch the resource allocation properties from the descriptor object + :param quota_descriptor: cpu/mem/vif/disk-io quota descriptor + :return: quota params for limit, reserve, shares from the descriptor object + """ + quota = {} + if quota_descriptor.get("limit"): + quota["limit"] = int(quota_descriptor["limit"]) + if quota_descriptor.get("reserve"): + quota["reserve"] = int(quota_descriptor["reserve"]) + if quota_descriptor.get("shares"): + quota["shares"] = int(quota_descriptor["shares"]) + return quota + def new_vnfd_v3(mydb, tenant_id, vnf_descriptor): """ Parses an OSM IM vnfd_catalog and insert at DB @@ -1264,6 +1280,15 @@ def new_vnfd_v3(mydb, tenant_id, vnf_descriptor): numa["cores"] = max(db_flavor["vcpus"], 1) else: numa["threads"] = max(db_flavor["vcpus"], 1) + epa_vcpu_set = True + if vdu["guest-epa"].get("cpu-quota") and not epa_vcpu_set: + extended["cpu-quota"] = get_resource_allocation_params(vdu["guest-epa"].get("cpu-quota")) + if vdu["guest-epa"].get("mem-quota"): + extended["mem-quota"] = get_resource_allocation_params(vdu["guest-epa"].get("mem-quota")) + if vdu["guest-epa"].get("disk-io-quota"): + extended["disk-io-quota"] = get_resource_allocation_params(vdu["guest-epa"].get("disk-io-quota")) + if vdu["guest-epa"].get("vif-quota"): + extended["vif-quota"] = get_resource_allocation_params(vdu["guest-epa"].get("vif-quota")) if numa: extended["numas"] = [numa] if extended: @@ -4591,6 +4616,7 @@ def instance_action(mydb,nfvo_tenant,instance_id, action_dict): for sce_vnf in instanceDict['vnfs']: for vm in sce_vnf['vms']: if vm["uuid"] == vdu_id: + # TODO revise this should not be vm["uuid"] instance_vms["vm_id"] vm_interfaces = vm["interfaces"] break @@ -4602,7 +4628,7 @@ def instance_action(mydb,nfvo_tenant,instance_id, action_dict): "status": "SCHEDULED", "item": "instance_vms", "item_id": vdu_id, - "related": vm["related"], + "related": target_vm["related"], "extra": yaml.safe_dump({"params": vm_interfaces}, default_flow_style=True, width=256) } @@ -4650,9 +4676,10 @@ def instance_action(mydb,nfvo_tenant,instance_id, action_dict): pass db_instance_vm = { "uuid": vm_uuid, + 'related': vm_uuid, 'instance_vnf_id': target_vm['instance_vnf_id'], 'vm_id': target_vm['vm_id'], - 'vim_name': vm_name + 'vim_name': vm_name, } db_instance_vms.append(db_instance_vm) @@ -4693,7 +4720,7 @@ def instance_action(mydb,nfvo_tenant,instance_id, action_dict): "status": "SCHEDULED", "item": "instance_vms", "item_id": vm_uuid, - "related": target_vm["related"], + "related": vm_uuid, # ALF # ALF # TODO examinar parametros, quitar MAC o incrementar. Incrementar IP y colocar las dependencias con ACTION-asdfasd.