X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_ro%2Fnfvo.py;h=7c5870ce7332ecea593d5748b40b483ec1256f8c;hb=7f426e900d00a76c3d583839f299982bbaf4c317;hp=b4a50f1599a6eef9af0f10392f551e639fbadf10;hpb=d2836fcc27661ec1638c464850bc76da067deb11;p=osm%2FRO.git diff --git a/osm_ro/nfvo.py b/osm_ro/nfvo.py index b4a50f15..7c5870ce 100644 --- a/osm_ro/nfvo.py +++ b/osm_ro/nfvo.py @@ -306,7 +306,7 @@ def get_imagelist(mydb, vnf_id, nfvo_tenant=None): def get_vim(mydb, nfvo_tenant=None, datacenter_id=None, datacenter_name=None, datacenter_tenant_id=None, - vim_tenant=None, vim_tenant_name=None, vim_user=None, vim_passwd=None): + vim_tenant=None, vim_tenant_name=None, vim_user=None, vim_passwd=None, ignore_errors=False): '''Obtain a dictionary of VIM (datacenter) classes with some of the input parameters return dictionary with {datacenter_id: vim_class, ... }. vim_class contain: 'nfvo_tenant_id','datacenter_id','vim_tenant_id','vim_url','vim_url_admin','datacenter_name','type','user','passwd' @@ -350,6 +350,10 @@ def get_vim(mydb, nfvo_tenant=None, datacenter_id=None, datacenter_name=None, da except (IOError, ImportError) as e: # if module_info and module_info[0]: # file.close(module_info[0]) + if ignore_errors: + logger.error("Unknown vim type '{}'. Can not open file '{}.py'; {}: {}".format( + vim["type"], module, type(e).__name__, str(e))) + continue raise NfvoException("Unknown vim type '{}'. Can not open file '{}.py'; {}: {}".format( vim["type"], module, type(e).__name__, str(e)), HTTP_Bad_Request) @@ -372,6 +376,9 @@ def get_vim(mydb, nfvo_tenant=None, datacenter_id=None, datacenter_name=None, da config=extra, persistent_info=persistent_info ) except Exception as e: + if ignore_errors: + logger.error("Error at VIM {}; {}: {}".format(vim["type"], type(e).__name__, str(e))) + continue http_code = HTTP_Internal_Server_Error if isinstance(e, vimconn.vimconnException): http_code = e.http_code @@ -1309,7 +1316,7 @@ def new_vnf(mydb, tenant_id, vnf_descriptor): vnf_descriptor['vnf']['tenant_id'] = tenant_id # Step 3. Get the URL of the VIM from the nfvo_tenant and the datacenter if global_config["auto_push_VNF_to_VIMs"]: - vims = get_vim(mydb, tenant_id) + vims = get_vim(mydb, tenant_id, ignore_errors=True) # Step 4. Review the descriptor and add missing fields #print vnf_descriptor @@ -1446,7 +1453,7 @@ def new_vnf_v02(mydb, tenant_id, vnf_descriptor): vnf_descriptor['vnf']['tenant_id'] = tenant_id # Step 3. Get the URL of the VIM from the nfvo_tenant and the datacenter if global_config["auto_push_VNF_to_VIMs"]: - vims = get_vim(mydb, tenant_id) + vims = get_vim(mydb, tenant_id, ignore_errors=True) # Step 4. Review the descriptor and add missing fields #print vnf_descriptor @@ -1630,7 +1637,7 @@ def delete_vnf(mydb,tenant_id,vnf_id,datacenter=None,vim_tenant=None): if tenant_id != "any": check_tenant(mydb, tenant_id) # Get the URL of the VIM from the nfvo_tenant and the datacenter - vims = get_vim(mydb, tenant_id) + vims = get_vim(mydb, tenant_id, ignore_errors=True) else: vims={} @@ -3533,7 +3540,8 @@ def instantiate_vnf(mydb, sce_vnf, params, params_out, rollbackList): for vm in sce_vnf['vms']: myVMDict = {} - myVMDict['name'] = "{}.{}.{}".format(instance_name[:64], sce_vnf['name'][:64], vm["name"][:64]) + sce_vnf_name = sce_vnf['member_vnf_index'] if sce_vnf['member_vnf_index'] else sce_vnf['name'] + myVMDict['name'] = "{}-{}-{}".format(instance_name[:64], sce_vnf_name[:64], vm["name"][:64]) myVMDict['description'] = myVMDict['name'][0:99] # if not startvms: # myVMDict['start'] = "no" @@ -4017,6 +4025,26 @@ def delete_instance(mydb, tenant_id, instance_id): else: return "action_id={} instance {} deleted".format(instance_action_id, message) +def get_instance_id(mydb, tenant_id, instance_id): + global ovim + #check valid tenant_id + check_tenant(mydb, tenant_id) + #obtain data + + instance_dict = mydb.get_instance_scenario(instance_id, tenant_id, verbose=True) + for net in instance_dict["nets"]: + if net.get("sdn_net_id"): + net_sdn = ovim.show_network(net["sdn_net_id"]) + net["sdn_info"] = { + "admin_state_up": net_sdn.get("admin_state_up"), + "flows": net_sdn.get("flows"), + "last_error": net_sdn.get("last_error"), + "ports": net_sdn.get("ports"), + "type": net_sdn.get("type"), + "status": net_sdn.get("status"), + "vlan": net_sdn.get("vlan"), + } + return instance_dict def refresh_instance(mydb, nfvo_tenant, instanceDict, datacenter=None, vim_tenant=None): '''Refreshes a scenario instance. It modifies instanceDict''' @@ -5071,13 +5099,15 @@ def datacenter_sdn_port_mapping_set(mydb, tenant_id, datacenter_id, sdn_port_map element = dict() element["compute_node"] = compute_node["compute_node"] for port in compute_node["ports"]: - element["pci"] = port.get("pci") + pci = port.get("pci") element["switch_port"] = port.get("switch_port") element["switch_mac"] = port.get("switch_mac") - if not element["pci"] or not (element["switch_port"] or element["switch_mac"]): + if not pci or not (element["switch_port"] or element["switch_mac"]): raise NfvoException ("The mapping must contain the 'pci' and at least one of the elements 'switch_port'" " or 'switch_mac'", HTTP_Bad_Request) - maps.append(dict(element)) + for pci_expanded in utils.expand_brackets(pci): + element["pci"] = pci_expanded + maps.append(dict(element)) return ovim.set_of_port_mapping(maps, ofc_id=sdn_controller_id, switch_dpid=switch_dpid, region=datacenter_id)