From 33e82d237e7e0b29ff1048cbc056f2427a47c4fe Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 10 Feb 2020 12:22:59 +0530 Subject: [PATCH] changes for add disk offering handling Signed-off-by: Abhishek Kumar Signed-off-by: Rohit Yadav --- ui/src/views/offering/AddDiskOffering.vue | 142 +++++++++++++++++----- 1 file changed, 112 insertions(+), 30 deletions(-) diff --git a/ui/src/views/offering/AddDiskOffering.vue b/ui/src/views/offering/AddDiskOffering.vue index e59200829bb..ece4230e4eb 100644 --- a/ui/src/views/offering/AddDiskOffering.vue +++ b/ui/src/views/offering/AddDiskOffering.vue @@ -36,7 +36,7 @@ }]" :placeholder="this.$t('Description')"/> - + + - + + - + + :placeholder="this.$t('disksize')"/> - + + :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')"/> - + + {{ opt.name || opt.description }} @@ -262,7 +262,7 @@ return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0 }" :loading="domainLoading" - :placeholder="this.$t('label.domain')"> + :placeholder="this.$t('domainid')"> {{ opt.name || opt.description }} @@ -290,7 +290,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 }} @@ -318,7 +318,7 @@ export default { return { storageType: 'shared', provisioningType: 'thin', - isCustomDiskSize: false, + isCustomDiskSize: true, qosType: '', isCustomizedDiskIops: false, writeCacheType: 'nodiskcache', @@ -421,8 +421,90 @@ export default { if (err) { return } - var params = {} - console.log(params) + var params = { + isMirrored: false, + name: values.name, + displaytext: values.description, + storageType: values.storagetype, + cacheMode: values.writecachetype, + provisioningType: values.provisioningtype, + customized: (values.customdisksize === true) + } + if (values.customdisksize !== true) { + params.disksize = values.disksize + } + 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.tags != null && values.tags.length > 0) { + var tags = values.tags.join(',') + params.tags = tags + } + 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('createDiskOffering', params).then(json => { + this.$notification.success({ + message: this.$t('message.add.disk.offering'), + description: this.$t('message.add.disk.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 () {