def NFFG_Update(self, new_nffg): # Check and get the session id for this user-graph couple logging.debug( "Update NF-FG: check if the user " + self.user_data.user_id + " has already instantiated the graph " + new_nffg.id + ".") session = GraphSession().getActiveUserGraphSession(self.user_data.user_id, new_nffg.id, error_aware=True) if session is None: return None self.__session_id = session.session_id logging.debug("Update NF-FG: already instantiated, trying to update it") try: logging.debug( "Update NF-FG: updating session " + self.__session_id + " from user " + self.user_data.username + " on tenant " + self.user_data.tenant) GraphSession().updateStatus(self.__session_id, 'updating') # Get the old NFFG old_nffg = GraphSession().getNFFG(self.__session_id) logging.debug("Update NF-FG: the old session: " + old_nffg.getJSON()) # Get the updated NFFG updated_nffg = old_nffg.diff(new_nffg) logging.debug("Update NF-FG: coming updates: " + updated_nffg.getJSON(True)) # Delete useless endpoints and flowrules, from DB and Network Controller self.__NFFG_NC_DeleteAndUpdate(updated_nffg) # Update database GraphSession().updateNFFG(updated_nffg, self.__session_id) # Send flowrules to Network Controller self.__NC_FlowsInstantiation(updated_nffg) logging.debug("Update NF-FG: session " + self.__session_id + " correctly updated!") GraphSession().updateStatus(self.__session_id, 'complete') # Update the resource description .json ResourceDescription().updateAll() ResourceDescription().saveFile() Messaging().PublishDomainConfig() except Exception as ex: logging.error("Update NF-FG: ", ex) self.__NFFG_NC_deleteGraph() GraphSession().updateError(self.__session_id) raise ex return self.__session_id
def NFFG_Delete(self, nffg_id): session = GraphSession().getActiveUserGraphSession(self.user_data.user_id, nffg_id, error_aware=False) if session is None: raise sessionNotFound("Delete NF-FG: session not found for graph " + str(nffg_id)) self.__session_id = session.session_id try: instantiated_nffg = GraphSession().getNFFG(self.__session_id) logging.debug("Delete NF-FG: [session=" + str( self.__session_id) + "] we are going to delete: " + instantiated_nffg.getJSON()) self.__NFFG_NC_deleteGraph() logging.debug("Delete NF-FG: session " + self.__session_id + " correctly deleted!") # Update the resource description .json ResourceDescription().updateAll() ResourceDescription().saveFile() Messaging().PublishDomainConfig() except Exception as ex: logging.error("Delete NF-FG: ", ex) raise ex