From f68a07f959913d1f5bc97ad7dd78109b5f2dd12e Mon Sep 17 00:00:00 2001 From: utchoang Date: Tue, 31 Mar 2020 19:04:45 +0700 Subject: [PATCH 01/24] hidden: Pod, cluster, host for normal and domain admin user --- src/views/compute/DeployVM.vue | 41 +++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/src/views/compute/DeployVM.vue b/src/views/compute/DeployVM.vue index f1a4c9eb7..a633dc43c 100644 --- a/src/views/compute/DeployVM.vue +++ b/src/views/compute/DeployVM.vue @@ -44,21 +44,27 @@ :loading="loading.zones" > - + - + - + { + if (param.isLoad) { + this.fetchOptions(param, name) + } + }) + this.fetchKeyboard() Vue.nextTick().then(() => { this.instanceConfig = this.form.getFieldsValue() // ToDo: maybe initialize with some other defaults @@ -919,7 +938,9 @@ export default { }) this.tabKey = 'templateid' _.each(this.params, (param, name) => { - this.fetchOptions(param, name, ['zones', 'groups']) + if (!('isLoad' in param) || param.isLoad) { + this.fetchOptions(param, name, ['zones', 'groups']) + } }) this.fetchAllTemplates() }, From 49eb970bce67c1044c7b2bbe86ce734755f07f3e Mon Sep 17 00:00:00 2001 From: utchoang Date: Wed, 1 Apr 2020 09:46:00 +0700 Subject: [PATCH 02/24] add filter template/iso by featured, community, shared, self --- src/views/compute/DeployVM.vue | 22 +++- .../compute/wizard/TemplateIsoSelection.vue | 124 +++++++++++++++++- 2 files changed, 133 insertions(+), 13 deletions(-) diff --git a/src/views/compute/DeployVM.vue b/src/views/compute/DeployVM.vue index a633dc43c..88418e703 100644 --- a/src/views/compute/DeployVM.vue +++ b/src/views/compute/DeployVM.vue @@ -615,13 +615,14 @@ export default { created () { this.fetchData() }, + provide () { + return { + vmFetchTemplates: this.fetchAllTemplates, + vmFetchIsos: this.fetchAllIsos + } + }, methods: { fetchData () { - // this.fetchOptions(this.params.zones, 'zones') - // this.fetchOptions(this.params.pods, 'pods') - // this.fetchOptions(this.params.clusters, 'clusters') - // this.fetchOptions(this.params.hosts, 'hosts') - // this.fetchOptions(this.params.groups, 'groups') _.each(this.params, (param, name) => { if (param.isLoad) { this.fetchOptions(param, name) @@ -888,11 +889,14 @@ export default { }) }) }, - fetchAllTemplates () { + fetchAllTemplates (filterKey) { const promises = [] this.options.templates = [] this.loading.templates = true this.templateFilter.forEach((filter) => { + if (filterKey && filterKey !== filter) { + return true + } promises.push(this.fetchTemplates(filter)) }) Promise.all(promises).then(response => { @@ -907,11 +911,14 @@ export default { this.loading.templates = false }) }, - fetchAllIsos () { + fetchAllIsos (filterKey) { const promises = [] this.options.isos = [] this.loading.isos = true this.isoFilter.forEach((filter) => { + if (filterKey && filterKey !== filter) { + return true + } promises.push(this.fetchIsos(filter)) }) Promise.all(promises).then(response => { @@ -928,6 +935,7 @@ export default { }, onSelectZoneId (value) { this.zoneId = value + this.zone = _.find(this.options.zones, (option) => option.id === this.zoneId) this.zoneSelected = true this.form.setFieldsValue({ clusterid: undefined, diff --git a/src/views/compute/wizard/TemplateIsoSelection.vue b/src/views/compute/wizard/TemplateIsoSelection.vue index b26f89327..ee1e0f5d9 100644 --- a/src/views/compute/wizard/TemplateIsoSelection.vue +++ b/src/views/compute/wizard/TemplateIsoSelection.vue @@ -17,11 +17,55 @@ @@ -70,6 +117,10 @@ export default { loading: { type: Boolean, default: false + }, + zoneId: { + type: String, + default: () => '' } }, data () { @@ -77,7 +128,13 @@ export default { filter: '', selectedRowKeys: [], vpcs: [], - filteredInfo: null + filteredInfo: null, + showActionForm: false, + actionLoading: false, + networkOffering: { + loading: false, + opts: [] + } } }, computed: { @@ -149,6 +206,9 @@ export default { } } }, + beforeCreate () { + this.form = this.$form.createForm(this) + }, created () { api('listVPCs', { projectid: store.getters.project.id @@ -156,6 +216,7 @@ export default { this.vpcs = _.get(response, 'listvpcsresponse.vpc') }) }, + inject: ['vmFetchNetworks'], methods: { getDetails (network) { return [ @@ -178,6 +239,72 @@ export default { this.options.page = pagination.current this.options.pageSize = pagination.pageSize this.$emit('handle-search-filter', this.options) + }, + async onShowActionForm () { + this.showActionForm = true + this.networkOffering.loading = true + + try { + this.networkOffering.opts = await this.listNetworkOfferings() + this.networkOffering.loading = false + this.$forceUpdate() + } catch (e) { + console.log(e.stack) + this.networkOffering.loading = false + } + }, + onCloseAction () { + this.showActionForm = false + this.form.setFieldsValue({ + name: undefined, + networkOfferingId: undefined + }) + }, + listNetworkOfferings () { + return new Promise((resolve, reject) => { + const args = {} + args.forvpc = false + args.zoneid = this.zoneId + args.guestiptype = 'Isolated' + args.supportedServices = 'SourceNat' + args.specifyvlan = false + args.state = 'Enabled' + + api('listNetworkOfferings', args).then(json => { + const listNetworkOfferings = json.listnetworkofferingsresponse.networkoffering || [] + resolve(listNetworkOfferings) + }).catch(error => { + resolve(error) + }) + }) + }, + handleSubmit (e) { + e.preventDefault() + + this.form.validateFields((error, values) => { + if (error) { + return + } + const params = {} + params.zoneId = this.zoneId + params.name = values.name + params.displayText = values.name + params.networkOfferingId = values.networkOfferingId + + this.actionLoading = true + api('createNetwork', params).then(json => { + this.vmFetchNetworks() + this.onCloseAction() + }).catch(error => { + const errorMsg = 'Failed to create new network, unable to proceed to deploy VM. Error: ' + error.message + this.$notification.error({ + message: 'Request Failed', + description: errorMsg + }) + }).finally(() => { + this.actionLoading = false + }) + }) } } } From bce9148fa187844094de13a8110505dbdbc05884 Mon Sep 17 00:00:00 2001 From: utchoang Date: Wed, 1 Apr 2020 11:45:48 +0700 Subject: [PATCH 05/24] Fixes duplicate data of diskoffering, sshKeyPair --- .../compute/wizard/DiskOfferingSelection.vue | 22 +++++++++++-------- .../compute/wizard/SshKeyPairSelection.vue | 16 +++++++++----- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/views/compute/wizard/DiskOfferingSelection.vue b/src/views/compute/wizard/DiskOfferingSelection.vue index 33d94ac9e..23441bdab 100644 --- a/src/views/compute/wizard/DiskOfferingSelection.vue +++ b/src/views/compute/wizard/DiskOfferingSelection.vue @@ -93,15 +93,7 @@ export default { } }, created () { - this.dataItems = [] - this.dataItems.push({ - id: '0', - name: this.$t('noselect'), - diskSize: undefined, - miniops: undefined, - maxiops: undefined, - isCustomized: undefined - }) + this.initDataItem() }, computed: { options () { @@ -139,11 +131,23 @@ export default { }, items (newData, oldData) { if (newData && newData.length > 0) { + this.initDataItem() this.dataItems = this.dataItems.concat(newData) } } }, methods: { + initDataItem () { + this.dataItems = [] + this.dataItems.push({ + id: '0', + name: this.$t('noselect'), + diskSize: undefined, + miniops: undefined, + maxiops: undefined, + isCustomized: undefined + }) + }, onSelectRow (value) { this.selectedRowKeys = value this.$emit('select-disk-offering-item', value[0]) diff --git a/src/views/compute/wizard/SshKeyPairSelection.vue b/src/views/compute/wizard/SshKeyPairSelection.vue index 420f406fc..a3b2f3c6d 100644 --- a/src/views/compute/wizard/SshKeyPairSelection.vue +++ b/src/views/compute/wizard/SshKeyPairSelection.vue @@ -80,12 +80,7 @@ export default { } }, created () { - this.dataItems = [] - this.dataItems.push({ - name: this.$t('noselect'), - account: '-', - domain: '-' - }) + this.initDataItem() }, computed: { options () { @@ -121,11 +116,20 @@ export default { }, items (newData, oldData) { if (newData && newData.length > 0) { + this.initDataItem() this.dataItems = this.dataItems.concat(newData) } } }, methods: { + initDataItem () { + this.dataItems = [] + this.dataItems.push({ + name: this.$t('noselect'), + account: '-', + domain: '-' + }) + }, onSelectRow (value) { this.selectedRowKeys = value this.$emit('select-ssh-key-pair-item', value[0]) From 068ae54d171c02e4b8a11124bd4171193721542b Mon Sep 17 00:00:00 2001 From: utchoang Date: Mon, 6 Apr 2020 13:14:10 +0700 Subject: [PATCH 06/24] add domain, account to get data list networks --- src/views/compute/DeployVM.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/views/compute/DeployVM.vue b/src/views/compute/DeployVM.vue index 2157e6cb2..176cb3af0 100644 --- a/src/views/compute/DeployVM.vue +++ b/src/views/compute/DeployVM.vue @@ -446,6 +446,8 @@ export default { zoneid: _.get(this.zone, 'id'), canusefordeploy: true, projectid: store.getters.project.id, + domainid: store.getters.project.id ? null : store.getters.userInfo.domainid, + account: store.getters.project.id ? null : store.getters.userInfo.account, page: 1, pageSize: 10, keyword: undefined From 3d4111ab42e5dde9a0c4c6a539fe38be9dff1764 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 6 Apr 2020 16:17:27 +0530 Subject: [PATCH 07/24] view: fix deployvm user fields visibility Signed-off-by: Abhishek Kumar --- src/views/compute/DeployVM.vue | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/views/compute/DeployVM.vue b/src/views/compute/DeployVM.vue index f1a4c9eb7..c1f90591e 100644 --- a/src/views/compute/DeployVM.vue +++ b/src/views/compute/DeployVM.vue @@ -44,21 +44,21 @@ :loading="loading.zones" > - + - + - + Date: Mon, 6 Apr 2020 16:20:45 +0530 Subject: [PATCH 08/24] revert previous commit Already fixed in another PR Signed-off-by: Abhishek Kumar --- src/views/compute/DeployVM.vue | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/views/compute/DeployVM.vue b/src/views/compute/DeployVM.vue index c1f90591e..f1a4c9eb7 100644 --- a/src/views/compute/DeployVM.vue +++ b/src/views/compute/DeployVM.vue @@ -44,21 +44,21 @@ :loading="loading.zones" > - + - + - + Date: Wed, 8 Apr 2020 11:59:50 +0530 Subject: [PATCH 09/24] view: vm deployment, changes for variable offerings Signed-off-by: Abhishek Kumar --- src/views/compute/wizard/ComputeSelection.vue | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/views/compute/wizard/ComputeSelection.vue b/src/views/compute/wizard/ComputeSelection.vue index e44d17ad9..c7fd3140b 100644 --- a/src/views/compute/wizard/ComputeSelection.vue +++ b/src/views/compute/wizard/ComputeSelection.vue @@ -88,11 +88,28 @@ export default { }, tableSource () { return this.computeItems.map((item) => { + var cpuNumberValue = item.cpunumber + '' + var cpuSpeedValue = (item.cpuspeed !== null && item.cpuspeed !== undefined && item.cpuspeed > 0) ? parseFloat(item.cpuspeed / 1000.0).toFixed(2) + '' : '' + var ramValue = item.memory + '' + if (item.iscustomized === true) { + cpuNumberValue = '' + ramValue = '' + if ('serviceofferingdetails' in item && + 'mincpunumber' in item.serviceofferingdetails && + 'maxcpunumber' in item.serviceofferingdetails) { + cpuNumberValue = item.serviceofferingdetails.mincpunumber + '-' + item.serviceofferingdetails.maxcpunumber + } + if ('serviceofferingdetails' in item && + 'minmemory' in item.serviceofferingdetails && + 'maxmemory' in item.serviceofferingdetails) { + ramValue = item.serviceofferingdetails.minmemory + '-' + item.serviceofferingdetails.maxmemory + } + } return { key: item.id, name: item.name, - cpu: `${item.cpunumber} CPU x ${parseFloat(item.cpuspeed / 1000.0).toFixed(2)} Ghz`, - ram: `${item.memory} MB` + cpu: cpuNumberValue.length > 0 ? `${cpuNumberValue} CPU x ${cpuSpeedValue} Ghz` : '', + ram: ramValue.length > 0 ? `${ramValue} MB` : '' } }) }, From 68c21b96684926afa87d65bf8fca67fc7d9e6d05 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 8 Apr 2020 15:23:46 +0530 Subject: [PATCH 10/24] added support for custom compute offering Signed-off-by: Abhishek Kumar --- src/views/compute/DeployVM.vue | 35 ++- .../wizard/ComputeOfferingSelection.vue | 154 +++++++++++++ src/views/compute/wizard/ComputeSelection.vue | 204 ++++++++---------- 3 files changed, 280 insertions(+), 113 deletions(-) create mode 100644 src/views/compute/wizard/ComputeOfferingSelection.vue diff --git a/src/views/compute/DeployVM.vue b/src/views/compute/DeployVM.vue index f1a4c9eb7..4d040af58 100644 --- a/src/views/compute/DeployVM.vue +++ b/src/views/compute/DeployVM.vue @@ -134,13 +134,31 @@ :status="zoneSelected ? 'process' : 'wait'"> @@ -261,6 +279,7 @@ import { mixin, mixinDevice } from '@/utils/mixin.js' import store from '@/store' import InfoCard from '@/components/view/InfoCard' +import ComputeOfferingSelection from './wizard/ComputeOfferingSelection' import ComputeSelection from './wizard/ComputeSelection' import DiskOfferingSelection from '@views/compute/wizard/DiskOfferingSelection' import DiskSizeSelection from '@views/compute/wizard/DiskSizeSelection' @@ -281,6 +300,7 @@ export default { DiskSizeSelection, DiskOfferingSelection, InfoCard, + ComputeOfferingSelection, ComputeSelection }, props: { @@ -743,6 +763,17 @@ export default { } // step 3: select service offering deployVmData.serviceofferingid = values.computeofferingid + if (values.cpunumber || values.cpuspeed || values.memory) { + if (values.cpunumber) { + deployVmData['details[0].cpuNumber'] = values.cpunumber + } + if (values.cpuspeed) { + deployVmData['details[0].cpuSpeed'] = values.cpuspeed + } + if (values.memory) { + deployVmData['details[0].memory'] = values.memory + } + } // step 4: select disk offering deployVmData.diskofferingid = values.diskofferingid if (values.size) { diff --git a/src/views/compute/wizard/ComputeOfferingSelection.vue b/src/views/compute/wizard/ComputeOfferingSelection.vue new file mode 100644 index 000000000..52f60b193 --- /dev/null +++ b/src/views/compute/wizard/ComputeOfferingSelection.vue @@ -0,0 +1,154 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + + + + + + diff --git a/src/views/compute/wizard/ComputeSelection.vue b/src/views/compute/wizard/ComputeSelection.vue index c7fd3140b..3580361d6 100644 --- a/src/views/compute/wizard/ComputeSelection.vue +++ b/src/views/compute/wizard/ComputeSelection.vue @@ -16,139 +16,121 @@ // under the License. - From c0efb1e3ffcb749673242d4615ba31631f91440e Mon Sep 17 00:00:00 2001 From: utchoang Date: Thu, 9 Apr 2020 14:23:40 +0700 Subject: [PATCH 11/24] fix selected template/iso --- .../compute/wizard/TemplateIsoRadioGroup.vue | 13 +++++-------- .../compute/wizard/TemplateIsoSelection.vue | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/views/compute/wizard/TemplateIsoRadioGroup.vue b/src/views/compute/wizard/TemplateIsoRadioGroup.vue index 594b2d05a..8c2c94569 100644 --- a/src/views/compute/wizard/TemplateIsoRadioGroup.vue +++ b/src/views/compute/wizard/TemplateIsoRadioGroup.vue @@ -81,6 +81,10 @@ export default { itemCount: { type: Number, default: 0 + }, + osType: { + type: String, + default: '' } }, data () { @@ -90,17 +94,10 @@ export default { pageSize: 10 } }, - created () { + mounted () { this.value = this.selected this.$emit('emit-update-template-iso', this.inputDecorator, this.value) }, - watch: { - inputDecorator (value) { - if (value === 'templateid') { - this.value = this.selected - } - } - }, computed: { pagination () { return { diff --git a/src/views/compute/wizard/TemplateIsoSelection.vue b/src/views/compute/wizard/TemplateIsoSelection.vue index ee1e0f5d9..c23a42a60 100644 --- a/src/views/compute/wizard/TemplateIsoSelection.vue +++ b/src/views/compute/wizard/TemplateIsoSelection.vue @@ -68,15 +68,18 @@ + :defaultActiveKey="Object.keys(dataSource)[0]" + tabPosition="top" + v-model="osType" + @change="changeOsName"> Date: Thu, 9 Apr 2020 14:04:26 +0530 Subject: [PATCH 12/24] fix userdata param Signed-off-by: Abhishek Kumar --- src/views/compute/DeployVM.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/compute/DeployVM.vue b/src/views/compute/DeployVM.vue index 4d040af58..51f1d880f 100644 --- a/src/views/compute/DeployVM.vue +++ b/src/views/compute/DeployVM.vue @@ -749,8 +749,8 @@ export default { deployVmData.hostid = values.hostid deployVmData.group = values.group deployVmData.keyboard = values.keyboard - if (values.keyboard && values.keyboard.length > 0) { - deployVmData.userdata = encodeURIComponent(btoa(this.sanitizeReverse(values.keyboard))) + if (values.userdata && values.userdata.length > 0) { + deployVmData.userdata = encodeURIComponent(btoa(this.sanitizeReverse(values.userdata))) } // step 2: select template/iso if (this.tabKey === 'templateid') { From f4663734fd7e2733f0ebfbbed1dc812518f326b5 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 9 Apr 2020 14:27:21 +0530 Subject: [PATCH 13/24] fix zone selection Signed-off-by: Abhishek Kumar --- src/views/compute/DeployVM.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/src/views/compute/DeployVM.vue b/src/views/compute/DeployVM.vue index 51f1d880f..691107600 100644 --- a/src/views/compute/DeployVM.vue +++ b/src/views/compute/DeployVM.vue @@ -940,6 +940,7 @@ export default { }, onSelectZoneId (value) { this.zoneId = value + this.zone = _.find(this.options.zones, (option) => option.id === value) this.zoneSelected = true this.form.setFieldsValue({ clusterid: undefined, From 088a3c393562d360d2c3d4b1a549e56923435ffb Mon Sep 17 00:00:00 2001 From: utchoang Date: Thu, 9 Apr 2020 16:54:56 +0700 Subject: [PATCH 14/24] fix merge conflit --- src/views/compute/DeployVM.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/views/compute/DeployVM.vue b/src/views/compute/DeployVM.vue index 180ca0e78..e3f9f7e26 100644 --- a/src/views/compute/DeployVM.vue +++ b/src/views/compute/DeployVM.vue @@ -973,7 +973,6 @@ export default { }, onSelectZoneId (value) { this.zoneId = value - this.zone = _.find(this.options.zones, (option) => option.id === this.zoneId) this.zoneSelected = true this.form.setFieldsValue({ clusterid: undefined, From b8f1253cbd4ffd96ba9b5fdda283f6b6556bf2ab Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 9 Apr 2020 18:18:11 +0530 Subject: [PATCH 15/24] views: iso hypervisor field fixes #265 Signed-off-by: Abhishek Kumar --- src/views/compute/DeployVM.vue | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/views/compute/DeployVM.vue b/src/views/compute/DeployVM.vue index 691107600..d0d3e745c 100644 --- a/src/views/compute/DeployVM.vue +++ b/src/views/compute/DeployVM.vue @@ -115,6 +115,17 @@ :loading="loading.isos" @update-template-iso="updateFieldValue" > + + + +

@@ -317,6 +328,7 @@ export default { options: { templates: [], isos: [], + hypervisors: [], serviceOfferings: [], diskOfferings: [], zones: [], @@ -333,6 +345,7 @@ export default { deploy: false, templates: false, isos: false, + hypervisors: false, serviceOfferings: false, diskOfferings: false, affinityGroups: false, @@ -347,6 +360,7 @@ export default { instanceConfig: [], template: {}, iso: {}, + hypervisor: '', serviceOffering: {}, diskOffering: {}, affinityGroups: [], @@ -433,6 +447,12 @@ export default { zones: { list: 'listZones' }, + hypervisors: { + list: 'listHypervisors', + options: { + zoneid: _.get(this.zone, 'id') + } + }, affinityGroups: { list: 'listAffinityGroups', options: { @@ -497,6 +517,14 @@ export default { } }) }, + hypervisorSelectOptions () { + return this.options.hypervisors.map((hypervisor) => { + return { + label: hypervisor.name, + value: hypervisor.name + } + }) + }, podSelectOptions () { return this.options.pods.map((pod) => { return { @@ -547,6 +575,8 @@ export default { instanceConfig (instanceConfig) { this.template = _.find(this.options.templates, (option) => option.id === instanceConfig.templateid) this.iso = _.find(this.options.isos, (option) => option.id === instanceConfig.isoid) + var hypervisorItem = _.find(this.options.hypervisors, (option) => option.name === instanceConfig.hypervisor) + this.hypervisor = hypervisorItem ? hypervisorItem.name : null this.serviceOffering = _.find(this.options.serviceOfferings, (option) => option.id === instanceConfig.computeofferingid) this.diskOffering = _.find(this.options.diskOfferings, (option) => option.id === instanceConfig.diskofferingid) this.zone = _.find(this.options.zones, (option) => option.id === instanceConfig.zoneid) @@ -571,6 +601,9 @@ export default { this.vm.templatename = this.iso.displaytext this.vm.ostypeid = this.iso.ostypeid this.vm.ostypename = this.iso.ostypename + if (this.hypervisor) { + this.vm.hypervisor = this.hypervisor + } } if (this.serviceOffering) { @@ -761,6 +794,9 @@ export default { if (values.rootdisksize && values.rootdisksize > 0) { deployVmData.rootdisksize = values.rootdisksize } + if (values.hypervisor && values.hypervisor.length > 0) { + deployVmData.hypervisor = values.hypervisor + } // step 3: select service offering deployVmData.serviceofferingid = values.computeofferingid if (values.cpunumber || values.cpuspeed || values.memory) { From f38f429586767182992812a6628603a0b2816067 Mon Sep 17 00:00:00 2001 From: utchoang Date: Fri, 10 Apr 2020 14:08:09 +0700 Subject: [PATCH 16/24] add support for type of compute offering --- src/locales/en.json | 2 + src/views/compute/DeployVM.vue | 24 +- src/views/compute/wizard/ComputeSelection.vue | 207 +++++++++++++----- .../compute/wizard/DiskSizeSelection.vue | 10 +- 4 files changed, 172 insertions(+), 71 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index 7db942c07..c3f845994 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1146,6 +1146,8 @@ "message.required.traffic.type": "Error in configuration! All required traffic types should be added and with multiple physical networks each network should have a label.", "message.desc.primary.storage": "Each cluster must contain one or more primary storage servers, and we will add the first one now. Primary storage contains the disk volumes for all the VMs running on hosts in the cluster. Use any standards-compliant protocol that is supported by the underlying hypervisor.", "message.desc.secondary.storage": "Each zone must have at least one NFS or secondary storage server, and we will add the first one now. Secondary storage stores VM templates, ISO images, and VM disk volume snapshots. This server must be available to all hosts in the zone.

Provide the IP address and exported path.", +"message.error.required.input": "Please enter input", +"message.error.invalid.range": "Please enter values from {min} to {max}", "label.name": "Name", "label.ipv4.dns1": "IPv4 DNS1", "label.ipv4.dns2": "IPv4 DNS2", diff --git a/src/views/compute/DeployVM.vue b/src/views/compute/DeployVM.vue index 0b9265d04..a1b507210 100644 --- a/src/views/compute/DeployVM.vue +++ b/src/views/compute/DeployVM.vue @@ -152,6 +152,7 @@ cpunumber-input-decorator="cpunumber" cpuspeed-input-decorator="cpuspeed" memory-input-decorator="memory" + :computeOfferingId="instanceConfig.computeofferingid" :isConstrained="'serviceofferingdetails' in serviceOffering" :minCpu="'serviceofferingdetails' in serviceOffering ? serviceOffering.serviceofferingdetails.mincpunumber*1 : 1" :maxCpu="'serviceofferingdetails' in serviceOffering ? serviceOffering.serviceofferingdetails.maxcpunumber*1 : Number.MAX_SAFE_INTEGER" @@ -160,11 +161,19 @@ @update-compute-cpunumber="updateFieldValue" @update-compute-cpuspeed="updateFieldValue" @update-compute-memory="updateFieldValue" /> - - - - - + + + + + + + + + + + @@ -350,7 +359,7 @@ export default { hosts: false, groups: false }, - instanceConfig: [], + instanceConfig: {}, template: {}, iso: {}, serviceOffering: {}, @@ -628,6 +637,9 @@ export default { this.form.getFieldDecorator('isoid', { initialValue: undefined, preserve: true }) this.form.getFieldDecorator('networkids', { initialValue: [], preserve: true }) this.form.getFieldDecorator('keypair', { initialValue: undefined, preserve: true }) + this.form.getFieldDecorator('cpunumber', { initialValue: undefined, preserve: true }) + this.form.getFieldDecorator('cpuSpeed', { initialValue: undefined, preserve: true }) + this.form.getFieldDecorator('memory', { initialValue: undefined, preserve: true }) this.apiParams = {} this.apiDeployVirtualMachine = this.$store.getters.apis.deployVirtualMachine || {} this.apiDeployVirtualMachine.params.forEach(param => { diff --git a/src/views/compute/wizard/ComputeSelection.vue b/src/views/compute/wizard/ComputeSelection.vue index 3580361d6..b12713b34 100644 --- a/src/views/compute/wizard/ComputeSelection.vue +++ b/src/views/compute/wizard/ComputeSelection.vue @@ -16,66 +16,82 @@ // under the License. - - diff --git a/src/views/compute/wizard/DiskSizeSelection.vue b/src/views/compute/wizard/DiskSizeSelection.vue index bec025a47..23613ba30 100644 --- a/src/views/compute/wizard/DiskSizeSelection.vue +++ b/src/views/compute/wizard/DiskSizeSelection.vue @@ -17,8 +17,8 @@ @@ -133,8 +93,6 @@ export default { selectedRowKeys: [], vpcs: [], filteredInfo: null, - showActionForm: false, - actionLoading: false, networkOffering: { loading: false, opts: [] @@ -255,26 +213,6 @@ export default { this.options.pageSize = pagination.pageSize this.$emit('handle-search-filter', this.options) }, - async onShowActionForm () { - this.showActionForm = true - this.networkOffering.loading = true - - try { - this.networkOffering.opts = await this.listNetworkOfferings() - this.networkOffering.loading = false - this.$forceUpdate() - } catch (e) { - console.log(e.stack) - this.networkOffering.loading = false - } - }, - onCloseAction () { - this.showActionForm = false - this.form.setFieldsValue({ - name: undefined, - networkOfferingId: undefined - }) - }, listNetworkOfferings () { return new Promise((resolve, reject) => { const args = {} @@ -292,34 +230,6 @@ export default { resolve(error) }) }) - }, - handleSubmit (e) { - e.preventDefault() - - this.form.validateFields((error, values) => { - if (error) { - return - } - const params = {} - params.zoneId = this.zoneId - params.name = values.name - params.displayText = values.name - params.networkOfferingId = values.networkOfferingId - - this.actionLoading = true - api('createNetwork', params).then(json => { - this.vmFetchNetworks() - this.onCloseAction() - }).catch(error => { - const errorMsg = 'Failed to create new network, unable to proceed to deploy VM. Error: ' + error.message - this.$notification.error({ - message: 'Request Failed', - description: errorMsg - }) - }).finally(() => { - this.actionLoading = false - }) - }) } } }