def instantiate_ns(nsId, body): # noqa: E501 """Instantiates the Network Service referenced by nsId # noqa: E501 :param nsId: :type nsId: str :param body: Network Service information :type body: dict | bytes :rtype: InlineResponse200 """ log_queue.put( ["INFO", "*****Time measure: NBI starting instantiating ns at SM"]) if connexion.request.is_json: body = NsInstantiationRequest.from_dict( connexion.request.get_json()) # noqa: E501 requester = connexion.request.remote_addr operationId = soep.instantiate_ns(nsId, body, requester) # process errors if operationId == 400: return error400("network service is not in NOT_INSTANTIATED state") if operationId == 404: return error404( "nsId not found, not a valid requester or nestedInstanceId cannot be shared" ) log_queue.put([ "INFO", "*****Time measure: NBI returning operation ID instantiating ns at SM" ]) return {"operationId": operationId}
def create_ns_identifier(body): # noqa: E501 """Creates and returns a Network Service identifier (nsId) # noqa: E501 :param body: Network Service information :type body: dict | bytes :rtype: InlineResponse201 """ current_time = datetime.now(pytz.utc) log_queue.put( ["INFO", "*****Time measure: NBI NBI creation of ns_identifier"]) if connexion.request.is_json: body = CreateNsIdentifierRequest.from_dict( connexion.request.get_json()) # noqa: E501 nsId = soep.create_ns_identifier(body) if nsId == 404: return error404("nsdId not found") current_time2 = datetime.now(pytz.utc) timeout = current_time2 - current_time #log_queue.put(["INFO", "*****Time measure for nsId %s : NBI returning nsID instantiating ns at SM" % (nsId)]) log_queue.put([ "INFO", "*****Time measure for nsId: %s with nsdId: %s: NBI NBI time to create nsID at SM: %s " % (nsId, body.nsd_id, timeout) ]) # TODO: debug, in return the 201 should not be needed but if it is missing the REST API returns a 200 return {"nsId": nsId}, 201
def query_nsd(nsdId, version): # noqa: E501 """Returns information of the network service referenced by nsId # noqa: E501 :param nsdId: ID of the network service descriptor :type nsdId: str :param version: Version of the network service descriptor :type version: str :rtype: object """ nsd = soe.query_nsd(nsdId, version) if nsd == 404: return error404("nsdId/version not found") nsd["nsdId"] = nsd["nsd"]["nsdIdentifier"] nsd["name"] = nsd["nsd"]["nsdName"] nsd["designer"] = nsd["nsd"]["designer"] nsd["version"] = nsd["nsd"]["version"] nsd["operationalState"] = "ENABLED" nsd["usageState"] = "NOT_IN_USE" nsd["deletionPending"] = False nsd["userDefinedData"] = {} total_return = {"queryResult": [nsd]} return total_return
def query_vnfd(vnfdId, version): # noqa: E501 """Returns information of the virtual network function referenced by vnfId # noqa: E501 :param vnfdId: ID of the virtual network function descriptor :type vnfdId: str :param version: Version of the virtual network function descriptor :type version: str :rtype: object """ vnfd = soe.query_vnfd(vnfdId, version) if vnfd == 404: return error404("vnfdId/version not found") vnfd = {"vnfd": vnfd} vnfd["vnfdId"] = vnfd["vnfd"]["vnfdId"] vnfd["vnfProvider"] = vnfd["vnfd"]["vnfProvider"] vnfd["vnfProductName"] = vnfd["vnfd"]["vnfProductName"] vnfd["vnfSoftwareVersion"] = vnfd["vnfd"]["vnfSoftwareVersion"] vnfd["vnfdVersion"] = vnfd["vnfd"]["vnfdVersion"] vnfd["checksum"] = "TEST CHECKSUM" vnfd["softwareImage"] = [] vnfd["operationalState"] = "ENABLED" vnfd["usageState"] = "NOT_IN_USE" vnfd["deletionPending"] = False total_return = {"queryResult": [vnfd]} return total_return
def query_appd(appdId, version): # noqa: E501 """Returns information of the MEC app function referenced by appdId # noqa: E501 :param appdId: ID of the MEC app descriptor :type appdId: str :param version: Version of the MEC app descriptor :type version: str :rtype: object """ appd = soe.query_appd(appdId, version) if appd == 404: return error404("appdId/version not found") appd = {"appd": appd} appd["appdId"] = appd["appd"]["appDId"] appd["appPackageInfoId"] = appd["appd"]["appDId"] appd["version"] = appd["appd"]["appDVersion"] appd["provider"] = appd["appd"]["appProvider"] appd["name"] = appd["appd"]["appName"] appd["operationalState"] = "ENABLED" appd["usageState"] = "NOT_IN_USE" appd["deletionPending"] = False total_return = {"queryResult": [appd]} return total_return
def terminate_ns(nsId): # noqa: E501 """Terminates the Network Service identified by nsId. # noqa: E501 :param nsId: ID of the network service :type nsId: str :rtype: InlineResponse200 """ log_queue.put( ["INFO", "*****Time measure: NBI starting termination ns at SM"]) requester = connexion.request.remote_addr operationId = soep.terminate_ns(nsId, requester) if operationId == 400: return error400( "network service is not in INSTANTIATED or INSTANTIATING state") if operationId == 404: return error404( "nsId not found or the requester has not authorization to perform this operation" ) log_queue.put([ "INFO", "*****Time measure: NBI returning operation ID termination ns at SM" ]) return {"operationId": operationId}
def query_pnfd(pnfdId, version): # noqa: E501 """Returns information of the Physical Network Function (PNF) referenced by pnfdId # noqa: E501 :param pnfdId: ID of the physical network function descriptor :type pnfdId: str :param version: Version of the physical network function descriptor :type version: str :rtype: object """ pnfd = soe.query_pnfd(pnfdId, version) if pnfd == 404: return error404("pnfdId/version not found") pnfd["pnfdId"] = pnfd["pnfd"]["pnfdId"] pnfd["name"] = pnfd["pnfd"]["name"] pnfd["version"] = pnfd["pnfd"]["version"] pnfd["provider"] = pnfd["pnfd"]["provider"] pnfd["usageState"] = "NOT_IN_USE" pnfd["deletionPending"] = False pnfd["userDefinedData"] = {} total_return = {"queryResult": [pnfd]} return total_return
def delete_pnfd(pnfdId, version): # noqa: E501 """Delete the onboarded physical network function referenced by pnfdId # noqa: E501 :param pnfdId: ID of the physical network function descriptor :type pnfdId: str :param version: Version of the physical network function descriptor :type version: str :rtype: object """ if soe.delete_pnfd(pnfdId, version): return {"deletedPnfdInfoId": pnfdId} else: return error404("pnfdId not found")
def get_operation_status(operationId): # noqa: E501 """Returns the status of an operation by its operation Id # noqa: E501 :param operationId: ID of the operation to return its status :type operationId: str :rtype: InlineResponse2001 """ status = soe.get_operation_status(operationId) if status == 404: return error404("operationId not found") return {"status": status}
def delete_nsd(nsdId, version): # noqa: E501 """Delete the onboarded network service referenced by nsdId # noqa: E501 :param nsdId: ID of the network service descriptor :type nsdId: str :param version: Version of the network service descriptor :type version: str :rtype: InlineResponse201 + nsdId """ if soe.delete_nsd(nsdId, version): return {"deletedNsdInfoId": nsdId} else: return error404("nsdId not found")
def delete_appd(appdId, version): # noqa: E501 """Deletes the specified MEC application # noqa: E501 :param appdId: ID of the MEC app descriptor :type appdId: str :param version: Version of the MEC app descriptor :type version: str :rtype: None """ if soe.delete_appd(appdId, version): return {"deletedAppdInfoId": appdId} else: return error404("appdId not found")
def query_ns(nsId): # noqa: E501 """Returns information of the network service referenced by nsId # noqa: E501 :param nsId: ID of the network service :type nsId: str :rtype: NsInfo """ info = soep.query_ns(nsId) if info == 404: return error404("nsId not found") return {"queryNsResult": [info]}
def delete_vnfd(vnfdId, version): # noqa: E501 """Deletes the specified virtual network function # noqa: E501 :param vnfdId: ID of the virtual network function descriptor :type vnfdId: str :param version: Version of the virtual network function descriptor :type version: str :rtype: None """ if soe.delete_vnfd(vnfdId, version): return {"deletedVnfdInfoId": vnfdId} else: return error404("vnfdId not found")
def terminate_ns(nsId): # noqa: E501 """Terminates the Network Service identified by nsId. # noqa: E501 :param nsId: ID of the network service :type nsId: str :rtype: InlineResponse200 """ operationId = soe.terminate_ns(nsId) if operationId == 400: return error400( "network service is not in INSTANTIATED or INSTANTIATING state") if operationId == 404: return error404("nsId not found") return {"operationId": operationId}
def instantiate_ns(nsId, body): # noqa: E501 """Instantiates the Network Service referenced by nsId # noqa: E501 :param nsId: :type nsId: str :param body: Network Service information :type body: dict | bytes :rtype: InlineResponse200 """ notification_db.create_notification_record({ "nsId": nsId, "type": "fa-send-o", "text": "INSTANTIATION Request for " + nsId, "time": datetime.now().strftime("%d/%m/%Y %H:%M:%S.%f") }) log_queue.put([ "INFO", "*****Time measure for nsId: %s: NBI NBI starting instantiating ns at SM" % (nsId) ]) if connexion.request.is_json: body = NsInstantiationRequest.from_dict( connexion.request.get_json()) # noqa: E501 requester = connexion.request.remote_addr operationId = soep.instantiate_ns(nsId, body, requester) # process errors if operationId == 400: return error400("network service is not in NOT_INSTANTIATED state") if operationId == 404: return error404( "nsId not found, not a valid requester or nestedInstanceId cannot be shared" ) log_queue.put([ "INFO", "*****Time measure for nsId: %s: NBI NBI returning operation ID instantiating ns at SM" % (nsId) ]) return {"operationId": operationId}
def create_ns_identifier(body): # noqa: E501 """Creates and returns a Network Service identifier (nsId) # noqa: E501 :param body: Network Service information :type body: dict | bytes :rtype: InlineResponse201 """ if connexion.request.is_json: body = CreateNsIdentifierRequest.from_dict( connexion.request.get_json()) # noqa: E501 nsId = soe.create_ns_identifier(body) if nsId == 404: return error404("nsdId not found") # TODO: debug, in return the 201 should not be needed but if it is missing the REST API returns a 200 return {"nsId": nsId}, 201
def onboard_nsd(body): # noqa: E501 """Returns information of the onboarded network service # noqa: E501 :param body: The NSD descriptor :type body: :rtype: NsOnboardingReply """ if connexion.request.is_json: nsd_json = connexion.request.get_json() requester = connexion.request.remote_addr nsdInfoId = soep.onboard_nsd(nsd_json, requester) if nsdInfoId == 404: return error404("Network service descriptor has not been onboarded in the catalog") info = {"nsdInfoId": nsdInfoId} return info
def scale_ns(nsId, body): # noqa: E501 """Scales the Network Service referenced by nsId # noqa: E501 :param nsId: Identifier of the NS to be scaled :type nsId: str :param body: Scale information :type body: dict | bytes :rtype: InlineResponse200 """ notification_db.create_notification_record({ "nsId": nsId, "type": "fa-gears", "text": "SCALING Request for " + nsId, "time": datetime.now().strftime("%d/%m/%Y %H:%M:%S.%f") }) log_queue.put([ "INFO", "*****Time measure for nsId: %s: NBI NBI starting scaling ns at SM" % nsId ]) if connexion.request.is_json: body = NsScaleRequest.from_dict( connexion.request.get_json()) # noqa: E501 # SCALING is done with requester = connexion.request.remote_addr operationId = soep.scale_ns(nsId, body, requester) # process errors if operationId == 400: return error400("network service is not in NOT_INSTANTIATED state") if operationId == 404: return error404("nsId not found or network service cannot be scaled") log_queue.put([ "INFO", "*****Time measure for nsId: %s: NBI NBI returning operation ID scaling ns at SM" % nsId ]) return {"operationId": operationId}
def onboard_pnfd(body): # noqa: E501 """Returns information of the onboarded physical network function # noqa: E501 :param body: The PNFD descriptor :type body: :rtype: PnfOnboardingReply """ if connexion.request.is_json: pnfd_json = connexion.request.get_json() # requester = connexion.request.remote_addr pnfdInfoId = soe.onboard_pnfd(pnfd_json) if pnfdInfoId == 404: return error404( "Physical Network function has not been onboarded in the catalog") info = {"pnfdInfoId": pnfdInfoId} return info
def update_federated_connections_paths(nsId, body): # noqa: E501 """Query towards the federated/provider domain to update connections towards the local and other federate domains after a scaling operation # noqa: E501 :param nsId: nsId of the nested federated network service in federated domain :type nsId: str :param body: Set of pairs of interconnections between VNFs to be established or removed :type body: dict | bytes :rtype: None """ if connexion.request.is_json: body = UpdateInterconnectionPaths.from_dict(connexion.request.get_json()) # noqa: E501 requester = connexion.request.remote_addr pathInfo = crooe.update_federated_internested_connections_reply(nsId, body, requester) if pathInfo == 404: return error404("The update requests coming from the federated domain are not returning valid information") log_queue.put(["DEBUG", "EWBI UPDATED pathInfo: %s"%pathInfo]) return {"updatedPathInfo": pathInfo}
def federated_instance_info(nsId, body): # noqa: E501 """Query towards the federated/provider domain to know info about: CIDR/pools that have to be used/not used in the federated domain # noqa: E501 :param nsId: nsId of the nested federated network service in federated domain :type nsId: str :param body: Identifier of the descriptor in the federated domain :type body: dict | bytes :rtype: InlineResponse2002 """ if connexion.request.is_json: body = FederatedInfo.from_dict(connexion.request.get_json()) # noqa: E501 requester = connexion.request.remote_addr instanceInfo = crooe.get_federated_network_instance_info_reply(nsId, body.nsd_id, requester) if instanceInfo == 404: return error404("The requests coming from the local domain is not returning valid information") log_queue.put(["DEBUG", "EWBI instance_info: %s"%instanceInfo]) return {"instanceInfo": instanceInfo}
def federated_network_info(nsId, body): # noqa: E501 """Query towards the consumer/local domain about the information: CIDR/pools that have to be used/not used in the federated domain # noqa: E501 :param nsId: nsId of the composite in consumer domain :type nsId: str :param body: Identifier of the descriptor in the federated domain :type body: dict | bytes :rtype: InlineResponse2001 """ if connexion.request.is_json: body = FederatedInfo.from_dict(connexion.request.get_json()) # noqa: E501 requester = connexion.request.remote_addr networkInfo = crooe.get_federated_network_info_reply(nsId, body.nsd_id,requester) if networkInfo == 404: return error404("The requests coming from the federated domain are not returning valid information") log_queue.put(["DEBUG", "EWBI network_info: %s"%networkInfo]) return {"networkInfo": networkInfo}
def federated_connection_paths(nsId, body): # noqa: E501 """Query towards the federated/provider domain to perform connections towards the local and other federate domains # noqa: E501 :param nsId: nsId of the nested federated network service in federated domain :type nsId: str :param body: Identifier of the descriptor in the federated domain :type body: dict | bytes :rtype: None """ if connexion.request.is_json: body = InterconnectionPaths.from_dict(connexion.request.get_json()) # noqa: E501 requester = connexion.request.remote_addr pathInfo = crooe.set_federated_internested_connections_reply(nsId, body, requester) if pathInfo == 404: return error404("The requests coming from the federated domain is not returning valid information") log_queue.put(["DEBUG", "EWBI pathInfo: %s"%pathInfo]) return {"pathInfo": pathInfo}
def terminate_ns(nsId): # noqa: E501 """Terminates the Network Service identified by nsId. # noqa: E501 :param nsId: ID of the network service :type nsId: str :rtype: InlineResponse200 """ notification_db.create_notification_record({ "nsId": nsId, "type": "fa-trash-o", "text": "TERMINATION Request for " + nsId, "time": datetime.now().strftime("%d/%m/%Y %H:%M:%S.%f") }) log_queue.put([ "INFO", "*****Time measure for nsId: %s: NBI NBI starting termination ns at SM" % (nsId) ]) requester = connexion.request.remote_addr operationId = soep.terminate_ns(nsId, requester) if operationId == 400: return error400( "network service is not in INSTANTIATED or INSTANTIATING state") if operationId == 404: return error404( "nsId not found or the requester has not authorization to perform this operation" ) log_queue.put([ "INFO", "*****Time measure for nsId: %s: NBI NBI returning operation ID termination ns at SM" % (nsId) ]) return {"operationId": operationId}
def scale_ns(nsId, body): # noqa: E501 """Scales the Network Service referenced by nsId # noqa: E501 :param nsId: Identifier of the NS to be scaled :type nsId: str :param body: Scale information :type body: dict | bytes :rtype: InlineResponse200 """ if connexion.request.is_json: body = NsScaleRequest.from_dict(connexion.request.get_json()) # noqa: E501 # SCALING is done with operationId = soep.scale_ns(nsId, body) # process errors if operationId == 400: return error400("network service is not in NOT_INSTANTIATED state") if operationId == 404: return error404("nsId not found or network service cannot be scaled") return {"operationId": operationId}
def instantiate_ns(nsId, body): # noqa: E501 """Instantiates the Network Service referenced by nsId # noqa: E501 :param nsId: :type nsId: str :param body: Network Service information :type body: dict | bytes :rtype: InlineResponse200 """ if connexion.request.is_json: body = NsInstantiationRequest.from_dict( connexion.request.get_json()) # noqa: E501 operationId = soe.instantiate_ns(nsId, body) # process errors if operationId == 400: return error400("network service is not in NOT_INSTANTIATED state") if operationId == 404: return error404("nsId not found") return {"operationId": operationId}
def create_ns_identifier(body): # noqa: E501 """Creates and returns a Network Service identifier (nsId) # noqa: E501 :param body: Network Service information :type body: dict | bytes :rtype: InlineResponse201 """ log_queue.put(["INFO", "*****Time measure: NBI creation of ns_identifier"]) if connexion.request.is_json: body = CreateNsIdentifierRequest.from_dict( connexion.request.get_json()) # noqa: E501 nsId = soep.create_ns_identifier(body) if nsId == 404: return error404("nsdId not found") log_queue.put([ "INFO", "*****Time measure: NBI returning operation ID instantiating ns at SM" ]) # TODO: debug, in return the 201 should not be needed but if it is missing the REST API returns a 200 return {"nsId": nsId}, 201