fix: Zun container operate adjust
Zun container operate adjust Change-Id: Ic78aab76e4a921a3e512d87975b1a82431bd8824
This commit is contained in:
parent
6b34ad1b05
commit
95fc8be2a1
@ -14,6 +14,7 @@
|
||||
|
||||
import { ConfirmAction } from 'containers/Action';
|
||||
import globalContainersStore from 'src/stores/zun/containers';
|
||||
import { checkItemAction } from 'resources/zun/container';
|
||||
|
||||
export default class DeleteContainer extends ConfirmAction {
|
||||
get id() {
|
||||
@ -38,7 +39,7 @@ export default class DeleteContainer extends ConfirmAction {
|
||||
|
||||
policy = 'container:container:delete';
|
||||
|
||||
allowedCheckFunc = () => true;
|
||||
allowedCheckFunc = (item) => checkItemAction(item, 'delete');
|
||||
|
||||
onSubmit = (data) => globalContainersStore.delete({ id: data.uuid });
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
import { ConfirmAction } from 'containers/Action';
|
||||
import globalContainersStore from 'src/stores/zun/containers';
|
||||
import { checkItemAction } from 'resources/zun/container';
|
||||
|
||||
export default class PauseContainer extends ConfirmAction {
|
||||
get id() {
|
||||
@ -32,7 +33,7 @@ export default class PauseContainer extends ConfirmAction {
|
||||
|
||||
policy = 'container:container:pause';
|
||||
|
||||
allowedCheckFunc = () => true;
|
||||
allowedCheckFunc = (item) => checkItemAction(item, 'pause');
|
||||
|
||||
onSubmit = (data) => globalContainersStore.pause({ id: data.uuid });
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
import { ConfirmAction } from 'containers/Action';
|
||||
import globalContainersStore from 'src/stores/zun/containers';
|
||||
import { checkItemAction } from 'resources/zun/container';
|
||||
|
||||
export default class RebootContainer extends ConfirmAction {
|
||||
get id() {
|
||||
@ -32,7 +33,7 @@ export default class RebootContainer extends ConfirmAction {
|
||||
|
||||
policy = 'container:container:reboot';
|
||||
|
||||
allowedCheckFunc = () => true;
|
||||
allowedCheckFunc = (item) => checkItemAction(item, 'reboot');
|
||||
|
||||
onSubmit = (data) => globalContainersStore.reboot({ id: data.uuid });
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
import { ConfirmAction } from 'containers/Action';
|
||||
import globalContainersStore from 'src/stores/zun/containers';
|
||||
import { checkItemAction } from 'resources/zun/container';
|
||||
|
||||
export default class StartContainer extends ConfirmAction {
|
||||
get id() {
|
||||
@ -32,7 +33,7 @@ export default class StartContainer extends ConfirmAction {
|
||||
|
||||
policy = 'container:container:start';
|
||||
|
||||
allowedCheckFunc = () => true;
|
||||
allowedCheckFunc = (item) => checkItemAction(item, 'start');
|
||||
|
||||
onSubmit = (data) => globalContainersStore.start({ id: data.uuid });
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
import { ConfirmAction } from 'containers/Action';
|
||||
import globalContainersStore from 'src/stores/zun/containers';
|
||||
import { checkItemAction } from 'resources/zun/container';
|
||||
|
||||
export default class StopContainer extends ConfirmAction {
|
||||
get id() {
|
||||
@ -34,7 +35,7 @@ export default class StopContainer extends ConfirmAction {
|
||||
|
||||
policy = 'container:container:stop';
|
||||
|
||||
allowedCheckFunc = () => true;
|
||||
allowedCheckFunc = (item) => checkItemAction(item, 'stop');
|
||||
|
||||
onSubmit = (data) => globalContainersStore.stop({ id: data.uuid });
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
import { ConfirmAction } from 'containers/Action';
|
||||
import globalContainersStore from 'src/stores/zun/containers';
|
||||
import { checkItemAction } from 'resources/zun/container';
|
||||
|
||||
export default class UnpauseContainer extends ConfirmAction {
|
||||
get id() {
|
||||
@ -34,7 +35,7 @@ export default class UnpauseContainer extends ConfirmAction {
|
||||
|
||||
policy = 'container:container:unpause';
|
||||
|
||||
allowedCheckFunc = () => true;
|
||||
allowedCheckFunc = (item) => checkItemAction(item, 'unpause');
|
||||
|
||||
onSubmit = (data) => globalContainersStore.unpause({ id: data.uuid });
|
||||
}
|
||||
|
@ -6,6 +6,9 @@ export const containerStatus = {
|
||||
Paused: t('Paused'),
|
||||
Restarting: t('Restarting'),
|
||||
Deleting: t('Deleting'),
|
||||
Error: t('Error'),
|
||||
Unknown: t('Unknown'),
|
||||
Rebuilding: t('Rebuilding'),
|
||||
};
|
||||
|
||||
export const containerTaskStatus = {
|
||||
@ -16,3 +19,70 @@ export const containerTaskStatus = {
|
||||
container_rebooting: t('Container Rebooting'),
|
||||
container_deleting: t('Container Deleting'),
|
||||
};
|
||||
|
||||
const states = {
|
||||
ERROR: 'Error',
|
||||
RUNNING: 'Running',
|
||||
STOPPED: 'Stopped',
|
||||
PAUSED: 'Paused',
|
||||
UNKNOWN: 'Unknown',
|
||||
CREATING: 'Creating',
|
||||
CREATED: 'Created',
|
||||
DELETED: 'Deleted',
|
||||
DELETING: 'Deleting',
|
||||
REBUILDING: 'Rebuilding',
|
||||
DEAD: 'Dead',
|
||||
RESTARTING: 'Restarting',
|
||||
};
|
||||
|
||||
const validStates = {
|
||||
update: [states.CREATED, states.RUNNING, states.STOPPED, states.PAUSED],
|
||||
start: [states.CREATED, states.STOPPED, states.ERROR],
|
||||
stop: [states.RUNNING],
|
||||
reboot: [states.CREATED, states.RUNNING, states.STOPPED, states.ERROR],
|
||||
rebuild: [states.CREATED, states.RUNNING, states.STOPPED, states.ERROR],
|
||||
pause: [states.RUNNING],
|
||||
unpause: [states.PAUSED],
|
||||
execute: [states.RUNNING],
|
||||
kill: [states.RUNNING],
|
||||
delete: [
|
||||
states.CREATED,
|
||||
states.ERROR,
|
||||
states.STOPPED,
|
||||
states.DELETED,
|
||||
states.DEAD,
|
||||
],
|
||||
delete_force: [
|
||||
states.CREATED,
|
||||
states.CREATING,
|
||||
states.ERROR,
|
||||
states.RUNNING,
|
||||
states.STOPPED,
|
||||
states.UNKNOWN,
|
||||
states.DELETED,
|
||||
states.DEAD,
|
||||
states.RESTARTING,
|
||||
states.REBUILDING,
|
||||
states.DELETING,
|
||||
],
|
||||
delete_stop: [
|
||||
states.RUNNING,
|
||||
states.CREATED,
|
||||
states.ERROR,
|
||||
states.STOPPED,
|
||||
states.DELETED,
|
||||
states.DEAD,
|
||||
],
|
||||
manage_security_groups: [
|
||||
states.CREATED,
|
||||
states.RUNNING,
|
||||
states.STOPPED,
|
||||
states.PAUSED,
|
||||
],
|
||||
};
|
||||
|
||||
export const checkItemAction = (item, actionName) => {
|
||||
if (!item) return false;
|
||||
const { status } = item;
|
||||
return validStates[actionName].includes(status);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user