Example #1
0
def removeNSIinNST(nstId):
    # ------ OLD VERSION ---------
    #nstParameter2update = "NSI_list_ref.pop="+str(nsiId)
    #updatedNST_jsonresponse = nst_catalogue.update_nst(nstParameter2update, nstId)

    # if there are no more NSI assigned to the NST, updates usageState parameter
    # catalogue_response = nst_catalogue.get_saved_nst(nstId)
    # nst_json = catalogue_response['nstd']
    # if not nst_json['NSI_list_ref']:
    #   if (nst_json['usageState'] == "IN_USE"):
    #     nstParameter2update = "usageState=NOT_IN_USE"
    #     updatedNST_jsonresponse = nst_catalogue.update_nst(nstParameter2update, nstId)
    # ----------------------------
    nsis_list = nsi_repo.getAll_saved_nsi()
    all_nsis_terminated = True
    for nsis_item in nsis_list:
        if (nsis_item['nst-ref'] == nstd_id
                and nsis_item['nsi-status'] == "INSTANTIATED"
                or nsis_item['nsi-status'] == "INSTANTIATING"
                or nsis_item['nsi-status'] == "READY"):
            all_nsis_terminated = False
            break

    if (all_nsis_terminated):
        nst_descriptor = nst_catalogue.get_saved_nst(nstId)
        nst_json = nst_descriptor['nstd']
        if (nst_json['usageState'] == "IN_USE"):
            nstParameter2update = "usageState=NOT_IN_USE"
            updatedNST_jsonresponse = nst_catalogue.update_nst(
                nstParameter2update, nstId)
Example #2
0
    def run(self):
        mutex.acquire()
        try:
            LOG.info(
                "NSI_MNGR_Notify: Slice instantitaion Notification to GTK.")
            jsonNSI = nsi_repo.get_saved_nsi(self.nsiId)
            #TODO: improve the next 2 lines to not use this delete.
            jsonNSI["id"] = jsonNSI["uuid"]
            del jsonNSI["uuid"]

            # checks if all services are READY/ERROR to update the slice_status
            all_services_ready = True
            for service_item in jsonNSI['nsr-list']:
                if (service_item['working-status'] == "INSTANTIATING"):
                    all_services_ready = False
                    break

            if (all_services_ready == True):
                jsonNSI['nsi-status'] = "INSTANTIATED"

                # validates if any service has error status to apply it to the slice status
                for service_item in jsonNSI['nsr-list']:
                    if (service_item['working-status'] == "ERROR"):
                        jsonNSI['nsi-status'] = "ERROR"
                        break

                # sends the updated NetSlice instance to the repositories
                jsonNSI['updateTime'] = str(
                    datetime.datetime.now().isoformat())

                repo_responseStatus = nsi_repo.update_nsi(jsonNSI, self.nsiId)

                # updates NetSlice template usageState
                if (jsonNSI['nsi-status'] == "INSTANTIATED"):
                    nst_descriptor = nst_catalogue.get_saved_nst(
                        jsonNSI['nst-ref'])
                    if (nst_descriptor['nstd'].get('usageState') ==
                            "NOT_IN_USE"):
                        #updateNST_jsonresponse = nstd_usagesstatus_update(jsonNSI['nst-ref'], nst_descriptor['nstd'])
                        nstParameter2update = "usageState=IN_USE"
                        updatedNST_jsonresponse = nst_catalogue.update_nst(
                            nstParameter2update, jsonNSI['nst-ref'])

        finally:
            mutex.release()
            #INFO: leave here & don't join with the same previous IF, as the multiple return(s) depend on this order
            if (all_services_ready == True):
                # creates a thread with the callback URL to advise the GK this slice is READY
                slice_callback = jsonNSI['sliceCallback']
                json_slice_info = {}
                json_slice_info['status'] = jsonNSI['nsi-status']
                json_slice_info['updateTime'] = jsonNSI['updateTime']

                thread_response = mapper.sliceUpdated(slice_callback,
                                                      json_slice_info)
Example #3
0
def nstd_usagesstatus_update(nstId, nstd_item):
    #nst_json = nst_catalogue.get_saved_nst(nstId)['nstd']
    #if (nstd_item['usageState'] == "NOT_IN_USE"):
    # updates (adds) the list of NSIref of original NST
    # nstParameter2update = "NSI_list_ref.append="+str(nsiId)
    # updatedNST_jsonresponse = nst_catalogue.update_nst(nstParameter2update, nstId)

    # updates the usageState parameter
    if (nstd_item['usageState'] == "NOT_IN_USE"):
        nstParameter2update = "usageState=IN_USE"
        updatedNST_jsonresponse = nst_catalogue.update_nst(
            nstParameter2update, nstId)

    return updatedNST_jsonresponse
Example #4
0
def updateNST(nstId, NST_string):
    logging.info("NST_MNGR: Updating NST with id: " + str(nstId))
    nstcatalogue_jsonresponse = nst_catalogue.update_nst(update_NST, nstId)

    return nstcatalogue_jsonresponse
Example #5
0
def updateNST(nstId, NST_string):
    LOG.info("Update Network Slice Template with ID: " + str(nstId))
    nstcatalogue_jsonresponse = nst_catalogue.update_nst(update_NST, nstId)

    return nstcatalogue_jsonresponse