def set_custom_sfc(sfcr_id, sfc_name, sfc_path, vnfi_info): ni_nfvo_sfc_api = get_nfvo_sfc_api() vnf_names = [ vnfi.name for vnfi in vnfi_info ] vnf_instance_ids= [] for vnf_list in sfc_path: if sfc_path.index(vnf_list) == 0: continue temp = [] for vnf in vnf_list: index = vnf_names.index(vnf) temp.append(vnfi_info[index].id) vnf_instance_ids.append(temp) sfc_spec = ni_nfvo_client.SfcSpec(sfc_name=sfc_name, sfcr_ids=[ sfcr_id ], vnf_instance_ids=vnf_instance_ids) api_response = ni_nfvo_sfc_api.set_sfc(sfc_spec) return api_response
def api_call_set_sfc(**sfc_spec_dict): ni_nfvo_sfc_api = get_nfvo_sfc_api() sfc_spec = ni_nfvo_client.SfcSpec( sfc_name=sfc_spec_dict["sfc_name"], sfcr_ids=sfc_spec_dict["sfcr_ids"], vnf_instance_ids=sfc_spec_dict["vnf_instance_ids"]) api_response = ni_nfvo_sfc_api.set_sfc(sfc_spec) print("### set_sfc_api_response", api_response)
def create_sample_sfc(sfc_name, sfcr_id, vnf_instance_id, is_symmetric): sfc_spec = ni_nfvo_client.SfcSpec(sfc_name=sfc_name, sfcr_ids=[sfcr_id], vnf_instance_ids=[[vnf_instance_id]], is_symmetric=is_symmetric) sfc_id = ni_nfvo_sfc_api.set_sfc(sfc_spec) assert check_sfc_exist(sfc_id) == True return sfc_id
def handle(self, request, data): try: sfc_spec = ni_nfvo_client.SfcSpec( sfc_name=data['sfc_name'], sfcr_ids=json.loads(data['sfcr_ids']), vnf_instance_ids=json.loads(data['vnf_instance_ids']), is_symmetric=data['is_symmetric']) sfc_id = ni_nfvo_sfc_api.set_sfc(sfc_spec) sfcs = ni_nfvo_sfc_api.get_sfcs() for sfc in sfcs: if sfc.id == sfc_id: return sfc raise Exception() except Exception as e: exceptions.handle(request, str(e))
def set_sfc(sfcr_id, sfc_name, inst_in_sfc): ni_nfvo_sfc_api = get_nfvo_sfc_api() del inst_in_sfc[0] instIDs = [] for inst in inst_in_sfc: instIDs.append([inst.id]) sfc_spec = ni_nfvo_client.SfcSpec(sfc_name=sfc_name, sfcr_ids=[sfcr_id], vnf_instance_ids=instIDs) api_response = ni_nfvo_sfc_api.set_sfc(sfc_spec) return api_response
def set_sfc(sfcr_id, sfc_name, sfc_path, vnfi_info): ni_nfvo_sfc_api = get_nfvo_sfc_api() vnf_instance_ids= [] for vnfi in vnfi_info: for vnf in sfc_path: if sfc_path.index(vnf) == 0: continue if vnfi.name == vnf: vnf_instance_ids.append([ vnfi.id ]) sfc_spec = ni_nfvo_client.SfcSpec(sfc_name=sfc_name, sfcr_ids=[ sfcr_id ], vnf_instance_ids=vnf_instance_ids) api_response = ni_nfvo_sfc_api.set_sfc(sfc_spec) return api_response