X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_ro%2Fnfvo.py;h=1d55a3c9ecf684bb065f3b5314a86d49ee61a4bc;hb=ae5f52ca92fe953fd7b7448f945bf12eb2d62afc;hp=1efd144cc488f71c4e0a3aeaf4585b52e76c1d98;hpb=8039182f401b4fed6f72f0fb881276afffa86276;p=osm%2FRO.git diff --git a/osm_ro/nfvo.py b/osm_ro/nfvo.py index 1efd144c..1d55a3c9 100644 --- a/osm_ro/nfvo.py +++ b/osm_ro/nfvo.py @@ -877,6 +877,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 @@ -888,7 +903,8 @@ def new_vnfd_v3(mydb, tenant_id, vnf_descriptor): try: myvnfd = vnfd_catalog.vnfd() try: - pybindJSONDecoder.load_ietf_json(vnf_descriptor, None, None, obj=myvnfd, path_helper=True) + pybindJSONDecoder.load_ietf_json(vnf_descriptor, None, None, obj=myvnfd, path_helper=True, + skip_unknown=True) except Exception as e: raise NfvoException("Error. Invalid VNF descriptor format " + str(e), httperrors.Bad_Request) db_vnfs = [] @@ -1260,6 +1276,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: @@ -1291,8 +1316,7 @@ def new_vnfd_v3(mydb, tenant_id, vnf_descriptor): "'member-vdus':'{vdu}'. Reference to a non-existing vdu".format( vnf=vnfd_id, pg=pg_name, vdu=vdu_id), httperrors.Bad_Request) - if vdu_id2db_table_index[vdu_id]: - db_vms[vdu_id2db_table_index[vdu_id]]["availability_zone"] = pg_name + db_vms[vdu_id2db_table_index[vdu_id]]["availability_zone"] = pg_name # TODO consider the case of isolation and not colocation # if pg.get("strategy") == "ISOLATION": @@ -2265,7 +2289,7 @@ def new_nsd_v3(mydb, tenant_id, nsd_descriptor): try: mynsd = nsd_catalog.nsd() try: - pybindJSONDecoder.load_ietf_json(nsd_descriptor, None, None, obj=mynsd) + pybindJSONDecoder.load_ietf_json(nsd_descriptor, None, None, obj=mynsd, skip_unknown=True) except Exception as e: raise NfvoException("Error. Invalid NS descriptor format: " + str(e), httperrors.Bad_Request) db_scenarios = [] @@ -2440,7 +2464,6 @@ def new_nsd_v3(mydb, tenant_id, nsd_descriptor): db_sce_vnffgs.append(db_sce_vnffg) # deal with rsps - db_sce_rsps = [] for rsp in vnffg.get("rsp").itervalues(): sce_rsp_uuid = str(uuid4()) uuid_list.append(sce_rsp_uuid) @@ -2451,7 +2474,6 @@ def new_nsd_v3(mydb, tenant_id, nsd_descriptor): "id": get_str(rsp, "id", 255), # only useful to link with classifiers; will be removed later in the code } db_sce_rsps.append(db_sce_rsp) - db_sce_rsp_hops = [] for iface in rsp.get("vnfd-connection-point-ref").itervalues(): vnf_index = str(iface['member-vnf-index-ref']) if_order = int(iface['order']) @@ -2504,7 +2526,6 @@ def new_nsd_v3(mydb, tenant_id, nsd_descriptor): db_sce_rsp_hops.append(db_sce_rsp_hop) # deal with classifiers - db_sce_classifiers = [] for classifier in vnffg.get("classifier").itervalues(): sce_classifier_uuid = str(uuid4()) uuid_list.append(sce_classifier_uuid) @@ -2543,7 +2564,6 @@ def new_nsd_v3(mydb, tenant_id, nsd_descriptor): db_sce_classifier["sce_rsp_id"] = rsp["uuid"] db_sce_classifiers.append(db_sce_classifier) - db_sce_classifier_matches = [] for match in classifier.get("match-attributes").itervalues(): sce_classifier_match_uuid = str(uuid4()) uuid_list.append(sce_classifier_match_uuid) @@ -3592,12 +3612,14 @@ def create_instance(mydb, tenant_id, instance_dict): returned_instance = mydb.get_instance_scenario(instance_uuid) returned_instance["action_id"] = instance_action_id return returned_instance - except (NfvoException, vimconn.vimconnException, db_base_Exception) as e: + except (NfvoException, vimconn.vimconnException, wimconn.WimConnectorError, db_base_Exception) as e: message = rollback(mydb, myvims, rollbackList) if isinstance(e, db_base_Exception): error_text = "database Exception" elif isinstance(e, vimconn.vimconnException): error_text = "VIM Exception" + elif isinstance(e, wimconn.WimConnectorError): + error_text = "WIM Exception" else: error_text = "Exception" error_text += " {} {}. {}".format(type(e).__name__, str(e), message)