fix: add vm state check for modify instance tags

Modify instance tags is allowed when the vm_state value is one of active, paused, suspended, stopped

Closes-Bug: #1991202
Change-Id: I1275053dd0aa57d777ba23046861d4c1b551ee03
This commit is contained in:
Jingwei.Zhang 2022-09-29 15:51:04 +08:00
parent be289f56cb
commit 79d41791bd

View File

@ -28,7 +28,11 @@ export class ModifyTags extends ModalAction {
static policy = 'os_compute_api:os-server-tags:update_all';
static allowed = () => Promise.resolve(true);
static allowed = (item) => {
const allowedStates = ['active', 'paused', 'suspended', 'stopped'];
const { vm_state = '' } = item || {};
return Promise.resolve(allowedStates.includes(vm_state.toLowerCase()));
};
get name() {
return t('modify instance tags');