1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-23 22:50:09 +03:00

F #5422: Add recover action to vnet api (#2004)

Co-authored-by: Tino Vázquez <cvazquez@opennebula.io>
This commit is contained in:
Sergio Betanzos 2022-05-10 19:25:14 +02:00 committed by GitHub
parent c3dd4124e6
commit 20456090e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 0 deletions

View File

@ -35,6 +35,7 @@ actions:
delete: true
lock: true
unlock: true
recover: true
# Filters - List of criteria to filter the resources

View File

@ -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',

View File

@ -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],
}),
}),
})

View File

@ -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,