diff --git a/src/fireedge/etc/sunstone/admin/vnet-tab.yaml b/src/fireedge/etc/sunstone/admin/vnet-tab.yaml index 977bc80f31..d3b27453a6 100644 --- a/src/fireedge/etc/sunstone/admin/vnet-tab.yaml +++ b/src/fireedge/etc/sunstone/admin/vnet-tab.yaml @@ -35,6 +35,7 @@ actions: delete: true lock: true unlock: true + recover: true # Filters - List of criteria to filter the resources diff --git a/src/fireedge/src/client/constants/translates.js b/src/fireedge/src/client/constants/translates.js index c7f7b162cb..98732e44b8 100644 --- a/src/fireedge/src/client/constants/translates.js +++ b/src/fireedge/src/client/constants/translates.js @@ -790,6 +790,14 @@ module.exports = { UsedLeases: 'Used leases', TotalLeases: 'Total leases', TotalClusters: 'Total clusters', + RecoverNetworkDescription: ` + Recovers a Virtual Network in ERROR state or waiting for a driver operation to complete. + The recovery may be done by failing, succeeding or retrying the current operation. + YOU NEED TO MANUALLY CHECK THE VN STATUS, to decide if the operation was successful or not, or if it can be retried. + + States for success/failure recovers: LOCK_CREATE, LOCK_DELETE state. + States for a retry recover: LOCK_CREATE, LOCK_DELETE state. + States for delete: Any but READY.`, /* security group schema */ TCP: 'TCP', diff --git a/src/fireedge/src/client/features/OneApi/network.js b/src/fireedge/src/client/features/OneApi/network.js index e3a9fb09af..254bbf8c7d 100644 --- a/src/fireedge/src/client/features/OneApi/network.js +++ b/src/fireedge/src/client/features/OneApi/network.js @@ -402,6 +402,27 @@ const vNetworkApi = oneApi.injectEndpoints({ }, invalidatesTags: (_, __, { id }) => [{ type: VNET, id }, VNET_POOL], }), + recoverVNet: builder.mutation({ + /** + * Recovers a stuck Virtual Network which is waiting for a driver operation. + * The recovery may be done by failing or succeeding the pending operation. + * You need to manually check the VN status, to decide if the operation was successful or not. + * + * @param {object} params - Request parameters + * @param {string} params.id - Virtual network id + * @param {0|1|2|3} params.operation - Recover operation: + * failure (0), success (1), retry (2), delete (3) + * @returns {number} Virtual network id + * @throws Fails when response isn't code 200 + */ + query: (params) => { + const name = Actions.VN_RECOVER + const command = { name, ...Commands[name] } + + return { params, command } + }, + invalidatesTags: (_, __, { id }) => [{ type: VNET, id }, VNET_POOL], + }), }), }) diff --git a/src/fireedge/src/server/utils/constants/commands/vn.js b/src/fireedge/src/server/utils/constants/commands/vn.js index afdce0daa2..ca62b3c5ff 100644 --- a/src/fireedge/src/server/utils/constants/commands/vn.js +++ b/src/fireedge/src/server/utils/constants/commands/vn.js @@ -35,6 +35,7 @@ const VN_RENAME = 'vn.rename' const VN_INFO = 'vn.info' const VN_LOCK = 'vn.lock' const VN_UNLOCK = 'vn.unlock' +const VN_RECOVER = 'vn.recover' const VN_POOL_INFO = 'vnpool.info' const Actions = { @@ -54,6 +55,7 @@ const Actions = { VN_INFO, VN_LOCK, VN_UNLOCK, + VN_RECOVER, VN_POOL_INFO, } @@ -316,6 +318,20 @@ module.exports = { }, }, }, + [VN_RECOVER]: { + // inspected + httpMethod: PUT, + params: { + id: { + from: resource, + default: 0, + }, + operation: { + from: postBody, + default: 1, + }, + }, + }, [VN_POOL_INFO]: { // inspected httpMethod: GET,