def get_all_slice_instances(): LOG.info("Request to retreive all the Network Slice Instantiations.") sbi.send_metrics('all_slices', 'start', 'query') allNSI = nsi_translator.get_all_nsi() sbi.send_metrics('all_slices', 'stop', 'query') return jsonify(allNSI[0]), allNSI[1]
def get_slice_instance(name): LOG.info( "Request to retrieve the Network Slice Instantiation with Name: " + str(name)) timestamp = str(datetime.datetime.now().isoformat()) returnedNSI = nsi_translator.get_nsi(str(name), timestamp) sbi.send_metrics(name, 'stop', returnedNSI[2]) return jsonify(returnedNSI[0]), returnedNSI[1]
def terminate_slice_instance(name): LOG.info( "Request to terminate the Network Slice Instantiation according to the following: " + str(request.json)) sbi.send_metrics(name, 'start', 'termination') # validates the fields with uuids (if they are right UUIDv4 format), 400 Bad request / 200 ok terminating_nsi = json_validator.validate_terminate_instantiation( request.json) if (terminating_nsi[1] == 200): terminating_nsi = nsi_translator.terminate_nsi(name, request.json) return jsonify(terminating_nsi[0]), terminating_nsi[1]
def instantiate_slice_instance(name): LOG.info( "Request to create a Network Slice Instantiation with the following information: " + str(request.json)) sbi.send_metrics(name, 'start', 'instantiation') # validates the fields with uuids (if they are right UUIDv4 format), 400 Bad request / 201 ok instantiating_nsi = json_validator.validate_instantiate_instantiation( request.json) if (instantiating_nsi[1] == 200): instantiating_nsi = nsi_translator.instantiate_nsi(request.json) return jsonify(instantiating_nsi[0]), instantiating_nsi[1]
def create_slice_identifier(): LOG.info( "Request to create a Network Slice Identifier with the following information: " + str(request.json)) timestamp = str(datetime.datetime.now().isoformat()) # validates the fields with uuids (if they are right UUIDv4 format), 400 Bad request / 201 ok creating_nsiId = json_validator.validate_create_instantiation(request.json) if (creating_nsiId[1] == 200): creating_nsiId = nsi_translator.create_nsi(request.json) sbi.send_metrics(creating_nsiId[0], 'start', 'creation', timestamp) sbi.send_metrics(creating_nsiId[0], 'stop', 'creation') #return jsonify(creating_nsiId[0]), creating_nsiId[1] return app.response_class( creating_nsiId[0], mimetype=app.config["JSONIFY_MIMETYPE"]), creating_nsiId[1]
def get_nsi(nsiName, timestamp): # Get the uuid from the name provided name = 'query' uuid = sbi.get_nsi_id_from_name(nsiName) if (uuid): LOG.info("Retrieving Network Slice Instance with ID: " + str(uuid)) nsirepo_jsonresponse = sbi.get_saved_nsi(uuid) if (nsirepo_jsonresponse): fsm_name = db.get_fsm_name_slice(nsiName) if fsm_name is not None: if (fsm_name != ""): if (fsm_name == "tunnel"): name = "getvnfinfo" elif (fsm_name == "MTD"): name = "getmtdinfo" nsirepo_jsonresponse['parameters'] = sbi.ws_get_info( uuid, fsm_name) sbi.send_metrics(nsiName, 'start', name, timestamp) # Translate the response new_nsirepo_jsonresponse = translate_nsi_from_sonata_to_vs( nsiName, nsirepo_jsonresponse) return (new_nsirepo_jsonresponse, 200, name) else: sbi.send_metrics(nsiName, 'start', name, timestamp) return_msg = {} return_msg['msg'] = "There are no NSIR with this uuid in the db." return (return_msg, 404, name) else: sbi.send_metrics(nsiName, 'start', name, timestamp) return_msg = {} return_msg['msg'] = "There are no NSIR with this uuid in the db." return (return_msg, 404, name)
def configure_slice_instance(name): LOG.info( "Request to configure a Network Slice Instantiation with the following information: " + str(request.json)) if (request.json['parameters']['ruleName'] == "getvnfinfo"): sbi.send_metrics(name, 'start', 'config') elif (request.json['parameters']['ruleName'] == "getmtdinfo"): sbi.send_metrics(name, 'start', 'config') else: sbi.send_metrics(name, 'start', request.json['parameters']['ruleName']) # validates the fields with uuids (if they are right UUIDv4 format), 400 Bad request / 201 ok configuring_nsi = json_validator.validate_configure_instantiation( request.json) if (configuring_nsi[1] == 200): configuring_nsi = nsi_translator.configure_nsi(name, request.json) if (request.json['parameters']['ruleName'] == "getvnfinfo"): sbi.send_metrics(name, 'stop', 'config') elif (request.json['parameters']['ruleName'] == "getmtdinfo"): sbi.send_metrics(name, 'stop', 'config') return jsonify(configuring_nsi[0]), configuring_nsi[1]
def update_nsi_notify_instantiate(self): sbi.send_metrics(str(self.NSI['name']), 'stop', 'instantiation') """ mutex_slice2db_access.acquire()
def update_nsi_notify_configure(self): sbi.send_metrics(self.NSI['name'], 'stop', self.NSI['parameters']['ruleName'])