Skip to content

Commit

Permalink
Merge pull request #6889 from GuoLiBin6/feat/glb-to-3.12/compute
Browse files Browse the repository at this point in the history
feat(v3.12/4611): cloudpods support select ios images to create vm
  • Loading branch information
GuoLiBin6 committed Jul 5, 2024
2 parents df2359c + b869cc9 commit d8bbf87
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 12 deletions.
8 changes: 7 additions & 1 deletion containers/Compute/sections/OsSelect/ImageSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,13 @@ export default {
if (params['filter.0'] && params['filter.0'] === 'disk_format.notequals(iso)') Reflect.deleteProperty(params, 'filter.0')
Reflect.deleteProperty(params, 'is_standard')
} else if (this.imageType === IMAGES_TYPE_MAP.standard.key || this.imageType === IMAGES_TYPE_MAP.customize.key || this.imageType === IMAGES_TYPE_MAP.host.key) {
params['filter.0'] = 'disk_format.notequals(iso)'
// Cloudpods 支持选择iso
const target = (this.cloudproviderList || []).filter(item => item.id === this.cloudprovider)
if (target.length && target[0].provider === 'Cloudpods') {
if (params['filter.0'] && params['filter.0'] === 'disk_format.notequals(iso)') Reflect.deleteProperty(params, 'filter.0')
} else {
params['filter.0'] = 'disk_format.notequals(iso)'
}
}
if (this.imageType === IMAGES_TYPE_MAP.customize.key) {
params.owner = this.$store.getters.userInfo.projectId
Expand Down
2 changes: 1 addition & 1 deletion containers/Compute/sections/OsSelect/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export default {
ret.unshift(IMAGES_TYPE_MAP.vmware)
ret.push(IMAGES_TYPE_MAP.iso)
ret.push({ ...IMAGES_TYPE_MAP.snapshot, label: this.$t(IMAGES_TYPE_MAP.snapshot.t) })
} else if (this.hypervisor === HYPERVISORS_MAP.proxmox.key || (this.isPrivate && this.hypervisor === HYPERVISORS_MAP.kvm.key)) {
} else if (this.hypervisor === HYPERVISORS_MAP.proxmox.key) {
ret = [IMAGES_TYPE_MAP.private, IMAGES_TYPE_MAP.iso, IMAGES_TYPE_MAP.private_iso]
} else if (this.hypervisor === HYPERVISORS_MAP.sangfor.key) {
ret = [IMAGES_TYPE_MAP.private_iso]
Expand Down
13 changes: 13 additions & 0 deletions containers/Compute/utils/createServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,19 @@ export class GenCreateData {
}
})
}
// cloudpods iso 镜像需加参数 cdrom,并移除磁盘中的image_id参数
if (this.fi.imageMsg?.disk_format === 'iso' || this.fi.imageMsg?.info?.disk_format === 'iso' || (this.fd.image?.label || '').endsWith('.iso')) {
const { hypervisor_info = {} } = this.fi.capability || {}
const keys = Object.keys(hypervisor_info)
if (keys.length === 1 && keys[0] === HYPERVISORS_MAP.cloudpods.provider) {
data.cdrom = this.fd.image.key
data.disks = (data.disks || []).map(item => {
const ret = { ...item }
delete ret.image_id
return ret
})
}
}
// 主机快照需要instance_snapshot_id参数
if (this.fd.imageType === IMAGES_TYPE_MAP.snapshot.key) {
data.instance_snapshot_id = this.fd.image.key
Expand Down
4 changes: 2 additions & 2 deletions containers/Compute/views/vminstance/create/form/IDC.vue
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,8 @@ export default {
const params = {
...this.scopeParams,
}
if (this.form.fd.hypervisor && this.form.fd.hypervisor) {
params.provider = HYPERVISORS_MAP[this.form.fd.hypervisor].provider
if (this.cloudregionZoneParams?.cloudregion) {
params.cloudregion_id = this.cloudregionZoneParams.cloudregion
}
return params
},
Expand Down
7 changes: 3 additions & 4 deletions containers/Compute/views/vminstance/create/form/Private.vue
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,11 @@ export default {
},
cloudproviderParamsExtra () {
const params = {
cloud_env: 'private',
manager_id: this.form.fd.cloudprovider,
...this.scopeParams,
}
if (this.form.fd.hypervisor && this.form.fd.hypervisor) {
params.provider = HYPERVISORS_MAP[this.form.fd.hypervisor].provider
if (this.cloudregionZoneParams.cloudregion) {
params.cloudregion_id = this.cloudregionZoneParams.cloudregion
}
return params
},
Expand Down Expand Up @@ -370,7 +369,7 @@ export default {
if (this.isInCloudSphere) {
return ['standard', 'customize']
}
if (this.form.fd.hypervisor === HYPERVISORS_MAP.proxmox.key || this.form.fd.hypervisor === HYPERVISORS_MAP.kvm.key) {
if (this.form.fd.hypervisor === HYPERVISORS_MAP.proxmox.key) {
return ['private']
}
return []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</template>
<a-radio value="disk" :disabled="isEsxi">{{$t('compute.text_101')}}</a-radio>
</a-tooltip>
<a-radio value="instance" :disabled="isCloudpods">{{$t('compute.text_102')}}</a-radio>
<a-radio value="instance">{{$t('compute.text_102')}}</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item
Expand Down Expand Up @@ -147,9 +147,6 @@ export default {
isEsxi () {
return this.params.data[0].hypervisor === hypervisorMap.esxi.key
},
isCloudpods () {
return this.params.data[0].brand === 'Cloudpods'
},
diskParams () {
return {
scope: this.$store.getters.scope,
Expand Down

0 comments on commit d8bbf87

Please sign in to comment.