mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-13 13:17:39 +03:00
parent
292b62d7ce
commit
22f5a6ef14
@ -86,6 +86,8 @@ export const addScheduledAction = createAction(`${VM}/add/scheduled-action`, vmS
|
||||
export const updateScheduledAction = createAction(`${VM}/update/scheduled-action`, vmService.updateScheduledAction)
|
||||
export const deleteScheduledAction = createAction(`${VM}/delete/scheduled-action`, vmService.deleteScheduledAction)
|
||||
export const recover = createAction(`${VM}/recover`, vmService.recover)
|
||||
export const lock = createAction(`${VM}/lock`, vmService.lock)
|
||||
export const unlock = createAction(`${VM}/unlock`, vmService.unlock)
|
||||
export const deploy = createAction(`${VM}/deploy`, vmService.deploy)
|
||||
export const migrate = createAction(`${VM}/migrate`, vmService.migrate)
|
||||
export const migrateLive = createAction(`${VM}/migrate-live`, vmService.migrate)
|
||||
|
@ -86,6 +86,8 @@ export const useVmApi = () => {
|
||||
deleteScheduledAction: (id, data) =>
|
||||
unwrapDispatch(actions.deleteScheduledAction({ id, ...data })),
|
||||
recover: (id, operation) => unwrapDispatch(actions.recover({ id, operation })),
|
||||
lock: (id, data) => unwrapDispatch(actions.lock({ id, ...data })),
|
||||
unlock: id => unwrapDispatch(actions.unlock({ id })),
|
||||
deploy: (id, data) => unwrapDispatch(actions.deploy({ id, ...data })),
|
||||
migrate: (id, data) => unwrapDispatch(actions.migrate({ id, ...data, live: false })),
|
||||
migrateLive: (id, data) => unwrapDispatch(actions.migrate({ id, ...data, live: true }))
|
||||
|
@ -597,6 +597,53 @@ export const vmService = ({
|
||||
return res?.data
|
||||
},
|
||||
|
||||
/**
|
||||
* Locks a virtual machine. Lock certain actions depending on blocking level.
|
||||
*
|
||||
* @param {object} params - Request parameters
|
||||
* @param {string|number} params.id - Virtual machine id
|
||||
* @param {1|2|3|4} params.level
|
||||
* - Lock level:
|
||||
* ``1``: Use
|
||||
* ``2``: Manage
|
||||
* ``3``: Admin
|
||||
* ``4``: All
|
||||
* @param {boolean} params.test - Check if the object is already locked to return an error
|
||||
* @returns {number} Virtual machine id
|
||||
* @throws Fails when response isn't code 200
|
||||
*/
|
||||
lock: async params => {
|
||||
const name = Actions.VM_LOCK
|
||||
const command = { name, ...Commands[name] }
|
||||
const config = requestConfig(params, command)
|
||||
|
||||
const res = await RestClient.request(config)
|
||||
|
||||
if (!res?.id || res?.id !== httpCodes.ok.id) throw res?.data
|
||||
|
||||
return res?.data
|
||||
},
|
||||
|
||||
/**
|
||||
* Unlocks a virtual machine.
|
||||
*
|
||||
* @param {object} params - Request parameters
|
||||
* @param {string|number} params.id - Virtual machine id
|
||||
* @returns {number} Virtual machine id
|
||||
* @throws Fails when response isn't code 200
|
||||
*/
|
||||
unlock: async params => {
|
||||
const name = Actions.VM_UNLOCK
|
||||
const command = { name, ...Commands[name] }
|
||||
const config = requestConfig(params, command)
|
||||
|
||||
const res = await RestClient.request(config)
|
||||
|
||||
if (!res?.id || res?.id !== httpCodes.ok.id) throw res?.data
|
||||
|
||||
return res?.data
|
||||
},
|
||||
|
||||
/**
|
||||
* Initiates the instance of the given VM id on the target host.
|
||||
*
|
||||
|
@ -234,7 +234,7 @@ export const vmTemplateService = ({
|
||||
*
|
||||
* @param {object} params - Request parameters
|
||||
* @param {string|number} params.id - Template id
|
||||
* @param {1|2|3|4} params.lock
|
||||
* @param {1|2|3|4} params.level
|
||||
* - Lock level:
|
||||
* ``1``: Use
|
||||
* ``2``: Manage
|
||||
|
@ -226,7 +226,7 @@ module.exports = {
|
||||
from: resource,
|
||||
default: 0
|
||||
},
|
||||
lock: {
|
||||
level: {
|
||||
from: postBody,
|
||||
default: 4
|
||||
},
|
||||
|
@ -575,6 +575,10 @@ module.exports = {
|
||||
level: {
|
||||
from: postBody,
|
||||
default: 4
|
||||
},
|
||||
test: {
|
||||
from: postBody,
|
||||
default: false
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user