Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3785,6 +3785,8 @@ private DiskOfferingVO createDiskOfferingInternal(final String name, final Strin
diskOffering.setMinIops(minIops);
diskOffering.setMaxIops(maxIops);
diskOffering.setEncrypt(encrypt);
diskOffering.setShareable(shareable);
diskOffering.setKvdoEnable(kvdoEnable);

setBytesRate(diskOffering, bytesReadRate, bytesReadRateMax, bytesReadRateMaxLength, bytesWriteRate, bytesWriteRateMax, bytesWriteRateMaxLength);
setIopsRate(diskOffering, iopsReadRate, iopsReadRateMax, iopsReadRateMaxLength, iopsWriteRate, iopsWriteRateMax, iopsWriteRateMaxLength);
Expand Down
75 changes: 65 additions & 10 deletions ui/src/components/offering/ComputeOfferingForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,11 @@
<template #label>
<tooltip-label :title="$t('label.computeonly.offering')" :tooltip="$t('label.computeonly.offering.tooltip')"/>
</template>
<a-switch v-model:checked="form.computeonly" :checked="computeonly" @change="val => { computeonly = val }"/>
<a-switch v-model:checked="form.computeonly" />
</a-form-item>

<a-card style="margin-bottom: 10px;">
<span v-if="computeonly">
<span v-if="form.computeonly">
<a-form-item name="storagetype" ref="storagetype">
<template #label>
<tooltip-label :title="$t('label.storagetype')" :tooltip="apiParams.storagetype.description"/>
Expand All @@ -390,14 +390,28 @@
<a-radio-button value="fat">{{ $t('label.provisioningtype.fat') }}</a-radio-button>
</a-radio-group>
</a-form-item>
<a-form-item name="cachemode" ref="cachemode">
<a-form-item v-if="!form.shareable" name="kvdoenable" ref="kvdoenable">
<template #label>
<tooltip-label :title="$t('label.kvdoenable')" :tooltip="apiParams.kvdoenable ? apiParams.kvdoenable.description : ''"/>
</template>
<a-switch v-model:checked="form.kvdoenable" />
</a-form-item>

<a-form-item v-if="!form.kvdoenable" name="shareable" ref="shareable">
<template #label>
<tooltip-label :title="$t('label.shareable')" :tooltip="apiParams.shareable ? apiParams.shareable.description : ''"/>
</template>
<a-switch v-model:checked="form.shareable" />
</a-form-item>

<a-form-item v-if="!form.shareable" name="cachemode" ref="cachemode">
<template #label>
<tooltip-label :title="$t('label.cachemode')" :tooltip="apiParams.cachemode.description"/>
</template>
<a-radio-group v-model:value="form.cachemode" buttonStyle="solid" @change="selected => { handleCacheModeChange(selected.target.value) }">
<a-radio-button value="none">{{ $t('label.nodiskcache') }}</a-radio-button>
<a-radio-button value="writeback">{{ $t('label.writeback') }}</a-radio-button>
<a-radio-button value="writethrough">{{ $t('label.writethrough') }}</a-radio-button>
<a-radio-button value="none">{{ $t('label.nodiskcache') }}</a-radio-button>
<a-radio-button value="hypervisor_default">{{ $t('label.hypervisor.default') }}</a-radio-button>
</a-radio-group>
</a-form-item>
Expand Down Expand Up @@ -517,7 +531,7 @@
<a-switch v-model:checked="form.encryptdisk" :checked="encryptdisk" @change="val => { encryptdisk = val }" />
</a-form-item>
</span>
<span v-if="!computeonly">
<span v-if="!form.computeonly">
<a-form-item>
<a-button type="primary" @click="addDiskOffering()"> {{ $t('label.add.disk.offering') }} </a-button>
<a-modal
Expand Down Expand Up @@ -615,20 +629,22 @@ export default {
computeonly: true,
storagetype: 'shared',
provisioningtype: 'thin',
cachemode: 'none',
cachemode: 'writeback',
qostype: '',
iscustomizeddiskiops: false,
diskofferingid: null,
diskofferingstrictness: false,
encryptdisk: false,
kvdoenable: false,
shareable: false,
leaseduration: undefined,
leaseexpiryaction: undefined
}, this.initialValues || {})),
rules: reactive({}),
// other UI state copied
storageType: 'shared',
provisioningType: 'thin',
cacheMode: 'none',
cacheMode: 'writeback',
offeringType: 'fixed',
isCustomizedDiskIops: false,
isPublic: true,
Expand Down Expand Up @@ -670,9 +686,18 @@ export default {
externalDetailsEnabled: false
}
},
watch: {
initialValues: {
deep: true,
handler (values) {
this.applyInitialValues(values)
}
}
},
created () {
this.zones = [{ id: null, name: this.$t('label.all.zone') }]
this.initForm()
this.syncUiStateFromForm()
this.fetchData()
this.isPublic = isAdmin()
this.form.ispublic = this.isPublic
Expand All @@ -684,6 +709,28 @@ export default {
name: [{ required: true, message: this.$t('message.error.required.input') }]
})
},
applyInitialValues (values) {
if (!values) {
return
}
Object.assign(this.form, values)
this.syncUiStateFromForm()
},
syncUiStateFromForm () {
this.offeringType = this.form.offeringtype || 'fixed'
this.computeonly = this.form.computeonly !== false
this.qosType = this.form.qostype || ''
this.isCustomizedDiskIops = this.form.iscustomizeddiskiops === true
this.selectedDiskOfferingId = this.form.diskofferingid || ''
this.diskofferingstrictness = this.form.diskofferingstrictness === true
this.encryptdisk = this.form.encryptdisk === true
this.selectedGpuCard = this.form.gpucardid || ''
this.showLeaseOptions = this.form.leaseduration !== undefined && this.form.leaseduration !== null
this.externalDetailsEnabled = !!(this.form.externaldetails && Object.keys(this.form.externaldetails).length > 0)
if (this.form.deploymentplanner) {
this.handleDeploymentPlannerChange(this.form.deploymentplanner)
}
},
fetchData () {
this.fetchDomainData()
this.fetchZoneData()
Expand Down Expand Up @@ -714,12 +761,18 @@ export default {
this.diskOfferingLoading = true
getAPI('listDiskOfferings', { listall: true }).then(json => {
this.diskOfferings = json.listdiskofferingsresponse.diskoffering || []
if (this.selectedDiskOfferingId === '') {
if (!this.form.diskofferingid) {
this.selectedDiskOfferingId = this.diskOfferings[0]?.id || ''
this.form.diskofferingid = this.selectedDiskOfferingId
}
}).finally(() => { this.diskOfferingLoading = false })
},
updateSelectedDiskOffering (id) { if (id) this.selectedDiskOfferingId = id },
updateSelectedDiskOffering (id) {
if (id) {
this.selectedDiskOfferingId = id
this.form.diskofferingid = id
}
},
closeDiskOfferingModal () { this.fetchDiskOfferings(); this.showDiskOfferingModal = false },
isDomainAdmin () {
return ['DomainAdmin'].includes(this.$store.getters.userInfo.roletype)
Expand Down Expand Up @@ -771,7 +824,9 @@ export default {
const planners = json.listdeploymentplannersresponse.deploymentPlanner
this.deploymentPlanners = this.deploymentPlanners.concat(planners)
this.deploymentPlanners.unshift({ name: '' })
this.form.deploymentplanner = this.deploymentPlanners.length > 0 ? this.deploymentPlanners[0].name : ''
if (!this.form.deploymentplanner) {
this.form.deploymentplanner = this.deploymentPlanners.length > 0 ? this.deploymentPlanners[0].name : ''
}
}).finally(() => { this.deploymentPlannerLoading = false })
},
fetchvSphereStoragePolicies (zoneIndex) {
Expand Down
115 changes: 101 additions & 14 deletions ui/src/components/offering/DiskOfferingForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@
<template #label>
<tooltip-label :title="$t('label.encrypt')" :tooltip="apiParams.encrypt.description" />
</template>
<a-switch v-model:checked="form.encryptdisk" :checked="encryptdisk" @change="val => { encryptdisk = val }" />
<a-switch v-model:checked="form.encryptdisk" />
</a-form-item>
<a-form-item name="disksizestrictness" ref="disksizestrictness">
<template #label>
<tooltip-label :title="$t('label.disksizestrictness')" :tooltip="apiParams.disksizestrictness.description" />
</template>
<a-switch v-model:checked="form.disksizestrictness" :checked="disksizestrictness" @change="val => { disksizestrictness = val }" />
<a-switch v-model:checked="form.disksizestrictness" />
</a-form-item>
<a-form-item name="customdisksize" ref="customdisksize">
<template #label>
Expand Down Expand Up @@ -191,23 +191,35 @@
v-model:value="form.hypervisorsnapshotreserve"
:placeholder="apiParams.hypervisorsnapshotreserve.description"/>
</a-form-item>
<a-form-item name="writecachetype" ref="writecachetype">
<a-form-item v-if="!form.shareable" name="kvdoenable" ref="kvdoenable">
<template #label>
<tooltip-label :title="$t('label.kvdoenable')" :tooltip="apiParams.kvdoenable ? apiParams.kvdoenable.description : ''"/>
</template>
<a-switch v-model:checked="form.kvdoenable" />
</a-form-item>
<a-form-item v-if="!form.kvdoenable" name="shareable" ref="shareable">
<template #label>
<tooltip-label :title="$t('label.shareable')" :tooltip="apiParams.shareable ? apiParams.shareable.description : ''"/>
</template>
<a-switch v-model:checked="form.shareable" />
</a-form-item>
<a-form-item v-if="!form.shareable" name="writecachetype" ref="writecachetype">
<template #label>
<tooltip-label :title="$t('label.writecachetype')" :tooltip="apiParams.cachemode.description"/>
</template>
<a-radio-group
v-model:value="form.writecachetype"
buttonStyle="solid"
@change="selected => { handleWriteCacheTypeChange(selected.target.value) }">
<a-radio-button value="none">
{{ $t('label.nodiskcache') }}
</a-radio-button>
<a-radio-button value="writeback">
{{ $t('label.writeback') }}
</a-radio-button>
<a-radio-button value="writethrough">
{{ $t('label.writethrough') }}
</a-radio-button>
<a-radio-button value="none">
{{ $t('label.nodiskcache') }}
</a-radio-button>
<a-radio-button value="hypervisor_default">
{{ $t('label.hypervisor.default') }}
</a-radio-button>
Expand Down Expand Up @@ -235,9 +247,9 @@
</a-select>
</a-form-item>
<a-form-item :label="$t('label.ispublic')" v-show="isAdmin()" name="ispublic" ref="ispublic">
<a-switch v-model:checked="form.ispublic" @change="val => { isPublic = val }" />
<a-switch v-model:checked="form.ispublic" />
</a-form-item>
<a-form-item v-if="!isPublic" name="domainid" ref="domainid">
<a-form-item v-if="!form.ispublic" name="domainid" ref="domainid">
<template #label>
<tooltip-label :title="$t('label.domainid')" :tooltip="apiParams.domainid.description"/>
</template>
Expand Down Expand Up @@ -349,11 +361,13 @@ export default {
storagetype: 'shared',
provisioningtype: 'thin',
customdisksize: true,
writecachetype: 'none',
writecachetype: 'writeback',
qostype: '',
ispublic: true,
disksizestrictness: false,
encryptdisk: false
encryptdisk: false,
kvdoenable: false,
shareable: false
}, this.initialValues || {})),
rules: reactive({}),
storageTags: [],
Expand All @@ -364,17 +378,25 @@ export default {
domainLoading: false,
zones: [],
zoneLoading: false,
disksizestrictness: false,
encryptdisk: false,
isDomainAdminAllowedToInformTags: false
}
},
watch: {
initialValues: {
deep: true,
handler (values) {
this.applyInitialValues(values)
}
}
},
created () {
this.zones = [{ id: null, name: this.$t('label.all.zone') }]
this.initForm()
this.applyInitialValues(this.initialValues)
this.fetchData()
this.isPublic = isAdmin()
this.form.ispublic = this.isPublic
if (this.form.ispublic === undefined) {
this.form.ispublic = isAdmin()
}
},
methods: {
initForm () {
Expand Down Expand Up @@ -406,6 +428,40 @@ export default {
}]
})
},
applyInitialValues (values) {
if (!values) {
return
}
Object.assign(this.form, values)
this.normalizeQosType()
this.syncUiStateFromForm()
},
normalizeQosType () {
const hasHypervisorQos = [
this.form.diskbytesreadrate,
this.form.diskbytesreadratemax,
this.form.diskbyteswriterate,
this.form.diskbyteswriteratemax,
this.form.diskiopsreadrate,
this.form.diskiopswriterate
].some(value => value !== undefined && value !== null && value !== '')
const hasStorageQos = [
this.form.diskiopsmin,
this.form.diskiopsmax,
this.form.hypervisorsnapshotreserve
].some(value => value !== undefined && value !== null && value !== '') || this.form.iscustomizeddiskiops === true

if (hasHypervisorQos) {
this.form.qostype = 'hypervisor'
} else if (hasStorageQos) {
this.form.qostype = 'storage'
}
},
syncUiStateFromForm () {
this.isPublic = this.form.ispublic !== false
this.normalizeDomainSelection()
this.normalizeZoneSelection()
},
fetchData () {
this.fetchDomainData()
this.fetchZoneData()
Expand Down Expand Up @@ -440,6 +496,7 @@ export default {
getAPI('listDomains', params).then(json => {
const listDomains = json.listdomainsresponse.domain
this.domains = this.domains.concat(listDomains)
this.normalizeDomainSelection()
}).finally(() => {
this.domainLoading = false
})
Expand All @@ -453,6 +510,7 @@ export default {
if (listZones) {
this.zones = this.zones.concat(listZones)
}
this.normalizeZoneSelection()
}).finally(() => {
this.zoneLoading = false
})
Expand Down Expand Up @@ -486,6 +544,35 @@ export default {
})
}
},
normalizeDomainSelection () {
if (!Array.isArray(this.form.domainid) || this.form.domainid.length === 0 || this.domains.length === 0) {
return
}
if (typeof this.form.domainid[0] === 'number') {
return
}
const domainIndexes = this.form.domainid.map(domainId => {
return this.domains.findIndex(domain => domain.id === domainId)
}).filter(index => index >= 0)
if (domainIndexes.length > 0) {
this.form.domainid = domainIndexes
}
},
normalizeZoneSelection () {
if (!Array.isArray(this.form.zoneid) || this.form.zoneid.length === 0 || this.zones.length === 0) {
return
}
if (typeof this.form.zoneid[0] === 'number') {
return
}
const zoneIndexes = this.form.zoneid.map(zoneId => {
return this.zones.findIndex(zone => zone.id === zoneId)
}).filter(index => index >= 0)
if (zoneIndexes.length > 0) {
this.form.zoneid = zoneIndexes
this.fetchvSphereStoragePolicies(zoneIndexes[0])
}
},
validate () {
return this.$refs.internalFormRef.validate().then(() => {
const formRaw = toRaw(this.form)
Expand Down
Loading
Loading