mirror of https://github.com/rancher/dashboard.git
HARVESTER: fixed create multiple vm instance (1504) & migration list filter(1501)
This commit is contained in:
parent
d3d8bcbeed
commit
7aed108422
|
|
@ -48,7 +48,7 @@ export default {
|
||||||
|
|
||||||
return nodes.filter((n) => {
|
return nodes.filter((n) => {
|
||||||
// do not allow to migrate to self node
|
// do not allow to migrate to self node
|
||||||
return n.id !== this.vmi?.status?.nodeName && !n.metadata?.annotations?.[HCI_ANNOTATIONS.MAINTENANCE_STATUS];
|
return n.id !== this.vmi?.status?.nodeName && !n.metadata?.annotations?.[HCI_ANNOTATIONS.MAINTENANCE_STATUS] && !n.isUnSchedulable;
|
||||||
}).map((n) => {
|
}).map((n) => {
|
||||||
let label = n?.metadata?.name;
|
let label = n?.metadata?.name;
|
||||||
const value = n?.metadata?.name;
|
const value = n?.metadata?.name;
|
||||||
|
|
|
||||||
|
|
@ -144,13 +144,10 @@ export default {
|
||||||
const templates = await this.$store.dispatch('harvester/findAll', { type: HCI.VM_TEMPLATE });
|
const templates = await this.$store.dispatch('harvester/findAll', { type: HCI.VM_TEMPLATE });
|
||||||
const template = templates.find( O => O.metadata.name === this.templateValue.metadata.name);
|
const template = templates.find( O => O.metadata.name === this.templateValue.metadata.name);
|
||||||
|
|
||||||
|
try {
|
||||||
if (!this.templateId) {
|
if (!this.templateId) {
|
||||||
if (this.templateValue?.metadata?.name) {
|
if (this.templateValue?.metadata?.name) {
|
||||||
try {
|
|
||||||
await this.templateValue.save();
|
await this.templateValue.save();
|
||||||
} catch (err) {
|
|
||||||
this.errors = [err];
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.errors = ['"Name" is required'];
|
this.errors = ['"Name" is required'];
|
||||||
buttonCb(false);
|
buttonCb(false);
|
||||||
|
|
@ -180,6 +177,10 @@ export default {
|
||||||
|
|
||||||
await this.saveSecret(res);
|
await this.saveSecret(res);
|
||||||
this.done();
|
this.done();
|
||||||
|
} catch (e) {
|
||||||
|
this.errors = [e];
|
||||||
|
buttonCb(false);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onTabChanged({ tab }) {
|
onTabChanged({ tab }) {
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,13 @@ import CpuMemory from '@/edit/kubevirt.io.virtualmachine/VirtualMachineCpuMemory
|
||||||
import CloudConfig from '@/edit/kubevirt.io.virtualmachine/VirtualMachineCloudConfig';
|
import CloudConfig from '@/edit/kubevirt.io.virtualmachine/VirtualMachineCloudConfig';
|
||||||
import NodeScheduling from '@/components/form/NodeScheduling';
|
import NodeScheduling from '@/components/form/NodeScheduling';
|
||||||
|
|
||||||
|
import { clear } from '@/utils/array';
|
||||||
import { clone } from '@/utils/object';
|
import { clone } from '@/utils/object';
|
||||||
import { HCI } from '@/config/types';
|
import { HCI } from '@/config/types';
|
||||||
|
import { exceptionToErrorsArray } from '@/utils/error';
|
||||||
import { cleanForNew } from '@/plugins/steve/normalize';
|
import { cleanForNew } from '@/plugins/steve/normalize';
|
||||||
import { HCI as HCI_ANNOTATIONS } from '@/config/labels-annotations';
|
import { HCI as HCI_ANNOTATIONS } from '@/config/labels-annotations';
|
||||||
|
import { BEFORE_SAVE_HOOKS, AFTER_SAVE_HOOKS } from '@/mixins/child-hook';
|
||||||
|
|
||||||
import VM_MIXIN from '@/mixins/harvester-vm';
|
import VM_MIXIN from '@/mixins/harvester-vm';
|
||||||
import CreateEditView from '@/mixins/create-edit-view';
|
import CreateEditView from '@/mixins/create-edit-view';
|
||||||
|
|
@ -219,11 +222,15 @@ export default {
|
||||||
this.$set(this.value.spec.template.spec, 'hostname', this.value.metadata.name);
|
this.$set(this.value.spec.template.spec, 'hostname', this.value.metadata.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.save(buttonCb);
|
try {
|
||||||
|
await this._save(this.value, buttonCb);
|
||||||
|
buttonCb(true);
|
||||||
|
|
||||||
const res = this.$store.getters['harvester/byId'](HCI.VM, `${ this.value.metadata.namespace }/${ this.value.metadata.name }`);
|
this.done();
|
||||||
|
} catch (e) {
|
||||||
await this.saveSecret(res);
|
this.errors = exceptionToErrorsArray(e);
|
||||||
|
buttonCb(false);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async saveMultiple(buttonCb) {
|
async saveMultiple(buttonCb) {
|
||||||
|
|
@ -248,23 +255,36 @@ export default {
|
||||||
const hostname = `${ baseHostname }${ join }${ suffix }`;
|
const hostname = `${ baseHostname }${ join }${ suffix }`;
|
||||||
|
|
||||||
this.$set(this.value.spec.template.spec, 'hostname', hostname);
|
this.$set(this.value.spec.template.spec, 'hostname', hostname);
|
||||||
|
this.secretName = '';
|
||||||
await this.parseVM();
|
await this.parseVM();
|
||||||
const basicValue = await this.$store.dispatch('harvester/create', clone(this.value));
|
const basicValue = await this.$store.dispatch('harvester/clone', { resource: this.value });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (i === 1) {
|
await this._save(basicValue);
|
||||||
await this.save();
|
|
||||||
} else {
|
if (i === this.count) {
|
||||||
basicValue.save();
|
buttonCb(true);
|
||||||
|
this.done();
|
||||||
}
|
}
|
||||||
const res = this.$store.getters['harvester/byId'](HCI.VM, `${ this.value.metadata.namespace }/${ this.value.metadata.name }`);
|
} catch (e) {
|
||||||
|
this.errors = exceptionToErrorsArray(e);
|
||||||
|
buttonCb(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async _save(value) {
|
||||||
|
if ( this.errors ) {
|
||||||
|
clear(this.errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.applyHooks(BEFORE_SAVE_HOOKS);
|
||||||
|
|
||||||
|
const res = await value.save();
|
||||||
|
|
||||||
|
await this.applyHooks(AFTER_SAVE_HOOKS);
|
||||||
|
|
||||||
await this.saveSecret(res);
|
await this.saveSecret(res);
|
||||||
} catch (err) {
|
|
||||||
return Promise.reject(new Error(err));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
restartVM() {
|
restartVM() {
|
||||||
|
|
|
||||||
|
|
@ -882,6 +882,8 @@ export default {
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
new Error(`Function(saveSecret) error ${ e }`);
|
new Error(`Function(saveSecret) error ${ e }`);
|
||||||
|
|
||||||
|
return Promise.reject(e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ export default class HciNode extends SteveModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
get isCordoned() {
|
get isCordoned() {
|
||||||
return !!this.spec.unschedulable;
|
return this.isUnSchedulable;
|
||||||
}
|
}
|
||||||
|
|
||||||
get isEnteringMaintenance() {
|
get isEnteringMaintenance() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue