diff --git a/ui/src/views/offering/AddComputeOffering.vue b/ui/src/views/offering/AddComputeOffering.vue index f6aa9838bf9..579e46a6910 100644 --- a/ui/src/views/offering/AddComputeOffering.vue +++ b/ui/src/views/offering/AddComputeOffering.vue @@ -29,14 +29,14 @@ }]" :placeholder="this.$t('Name')"/> - + + :placeholder="this.$t('displaytext ')"/> - + + + @@ -87,9 +87,9 @@ - + { @@ -101,9 +101,9 @@ } ] }]" - :placeholder="this.$t('label.cpucores')"/> + :placeholder="this.$t('cpunumber')"/> - + + :placeholder="this.$t('cpuspeed')"/> - + { @@ -133,11 +133,11 @@ } ] }]" - :placeholder="this.$t('label.mincpucores')"/> + :placeholder="this.$t('mincpunumber')"/> - + { @@ -149,9 +149,9 @@ } ] }]" - :placeholder="this.$t('label.maxcpucores')"/> + :placeholder="this.$t('maxcpunumber')"/> - + + :placeholder="this.$t('memory')"/> - + + :placeholder="this.$t('minmemory')"/> - + + :placeholder="this.$t('maxmemory')"/> - + + + :placeholder="this.$t('diskbytesreadrate')"/> - + + :placeholder="this.$t('diskbyteswriterate')"/> - + + :placeholder="this.$t('diskiopsreadrate')"/> - + + :placeholder="this.$t('diskiopswriterate')"/> - - + + - + + :placeholder="this.$t('diskiopsmin')"/> - + + :placeholder="this.$t('diskiopsmax')"/> - + + :placeholder="this.$t('hypervisorsnapshotreserve')"/> - - + + - + + :placeholder="this.$t('hosttags')"/> - + = 0 }" :loading="storageTagLoading" - :placeholder="this.$t('label.storage.tags')" + :placeholder="this.$t('tags')" v-if="this.isAdmin()"> {{ opt.name || opt.description }} - - + + - - + + - + = 0 }" :loading="deploymentPlannerLoading" - :placeholder="this.$t('label.deploymentplanner')" - @change="val => { this.handleDeploymentPlannerChange(this.deploymentPlanners[val]) }"> - + :placeholder="this.$t('deploymentplanner')" + @change="val => { this.handleDeploymentPlannerChange(val) }"> + {{ opt.name || opt.description }} - + + - + + :placeholder="this.$t('vgputype')"> {{ opt }} - + = 0 }" :loading="domainLoading" - :placeholder="this.$t('label.domain')"> + :placeholder="this.$t('domainid')"> {{ opt.name || opt.description }} @@ -465,7 +459,7 @@ return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0 }" :loading="zoneLoading" - :placeholder="this.$t('label.zone')"> + :placeholder="this.$t('zoneid')"> {{ opt.name || opt.description }} @@ -493,7 +487,7 @@ export default { return { storageType: 'shared', provisioningType: 'thin', - computeOfferingType: 'fixed', + offeringType: 'fixed', qosType: '', isCustomizedDiskIops: false, isPublic: true, @@ -610,6 +604,7 @@ export default { api('listDeploymentPlanners', params).then(json => { const planners = json.listdeploymentplannersresponse.deploymentPlanner this.deploymentPlanners = this.deploymentPlanners.concat(planners) + this.deploymentPlanners.unshift({ name: '' }) }).finally(() => { this.deploymentPlannerLoading = false }) @@ -621,7 +616,7 @@ export default { this.provisioningType = val }, handleComputeOfferingTypeChange (val) { - this.computeOfferingType = val + this.offeringType = val }, handleQosTypeChange (val) { this.qosType = val @@ -629,7 +624,7 @@ export default { handleDeploymentPlannerChange (planner) { this.selectedDeployementPlanner = planner this.plannerModeVisible = false - if (this.selectedDeployementPlanner.name === 'ImplicitDedicationPlanner') { + if (this.selectedDeployementPlanner === 'ImplicitDedicationPlanner') { this.plannerModeVisible = this.isAdmin() } }, @@ -655,8 +650,131 @@ export default { if (err) { return } - var params = {} - console.log(params) + console.log(values) + var params = { + issystem: false, + name: values.name, + displaytext: values.displaytext, + storagetype: values.storageType, + provisioningtype: values.provisioningtype, + customized: values.offeringtype !== 'fixed', + offerha: values.offerha === true, + limitcpuuse: values.limitcpuuse === true, + isvolatile: values.isvolatile === true + } + + // custom fields (begin) + if (values.offeringtype === 'fixed') { + params.cpunumber = values.cpunumber + params.cpuspeed = values.cpuspeed + params.memory = values.memory + } else { + if (values.cpuspeed != null && + values.mincpunumber != null && + values.maxcpunumber != null && + values.minmemory != null && + values.maxmemory != null) { + params.cpuspeed = values.cpuspeed + params.mincpunumber = values.mincpunumber + params.maxcpunumber = values.maxcpunumber + params.minmemory = values.minmemory + params.maxmemory = values.maxmemory + } + } + // custom fields (end) + + if (values.qostype === 'storage') { + var customIops = values.iscustomizeddiskiops === true + params.customizediops = customIops + if (!customIops) { + if (values.diskiopsmin != null && values.diskiopsmin.length > 0) { + params.miniops = values.diskiopsmin + } + if (values.diskiopsmax != null && values.diskiopsmax.length > 0) { + params.maxiops = values.diskiopsmax + } + if (values.hypervisorsnapshotreserve != null && values.hypervisorsnapshotreserve.length > 0) { + params.hypervisorsnapshotreserve = values.hypervisorsnapshotreserve + } + } + } else if (values.qostype === 'hypervisor') { + if (values.diskbytesreadrate != null && values.diskbytesreadrate.length > 0) { + params.bytesreadrate = values.diskbytesreadrate + } + if (values.diskbyteswriterate != null && values.diskbyteswriterate.length > 0) { + params.byteswriterate = values.diskbyteswriterate + } + if (values.diskiopsreadrate != null && values.diskiopsreadrate.length > 0) { + params.iopsreadrate = values.diskiopsreadrate + } + if (values.diskiopswriterate != null && values.diskiopswriterate.length > 0) { + params.iopswriterate = values.diskiopswriterate + } + } + if (values.storagetags != null && values.storagetags.length > 0) { + var tags = values.storagetags.join(',') + params.tags = tags + } + if (values.hosttags != null && values.hosttags.length > 0) { + params.hosttags = values.hosttags + } + if (values.deploymentplanner != null && values.deploymentplanner.length > 0) { + params.deploymentplanner = values.deploymentplanner + } + if (values.deploymentplanner === 'ImplicitDedicationPlanner' && values.plannermode !== '') { + params['serviceofferingdetails[0].key'] = 'ImplicitDedicationMode' + params['serviceofferingdetails[0].value'] = values.plannermode + } + if (values.pcidevice !== '') { + params['serviceofferingdetails[1].key'] = 'pciDevice' + params['serviceofferingdetails[1].value'] = values.pcidevice + } + if ('vgputype' in values && + this.vGpuTypes != null && this.vGpuTypes !== undefined && + values.vgputype > this.vGpuTypes.length) { + params['serviceofferingdetails[2].key'] = 'vgpuType' + params['serviceofferingdetails[2].value'] = this.vGpuTypes[values.vgputype] + } + if (values.ispublic !== true) { + var domainIndexes = values.domainid + var domainId = null + if (domainIndexes && domainIndexes.length > 0) { + var domainIds = [] + for (var i = 0; i < domainIndexes.length; i++) { + domainIds = domainIds.concat(this.domains[domainIndexes[i]].id) + } + domainId = domainIds.join(',') + } + if (domainId) { + params.domainid = domainId + } + } + var zoneIndexes = values.zoneid + var zoneId = null + if (zoneIndexes && zoneIndexes.length > 0) { + var zoneIds = [] + for (var j = 0; j < zoneIndexes.length; j++) { + zoneIds = zoneIds.concat(this.zones[zoneIndexes[j]].id) + } + zoneId = zoneIds.join(',') + } + if (zoneId) { + params.zoneid = zoneId + } + api('createServiceOffering', params).then(json => { + this.$notification.success({ + message: this.$t('message.add.service.offering'), + description: this.$t('message.add.service.offering') + }) + }).catch(error => { + this.$notification.error({ + message: 'Request Failed', + description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message + }) + }).finally(() => { + this.loading = false + this.closeAction() + }) }) }, closeAction () {