Merge pull request #13677 from swordqiu/hotfix/qj-server-inherit-image-vdi-property

fix: server inherit the vdi_protocol of image property
This commit is contained in:
Zexi Li
2022-03-11 21:09:16 +08:00
committed by GitHub
3 changed files with 8 additions and 0 deletions
+4
View File
@@ -61,6 +61,7 @@ type ImageOptionalOptions struct {
NetDriver string `help:"Preferred network driver" choices:"virtio|e1000|vmxnet3"`
DisableUsbKbd bool `help:"Disable usb keyboard on this image(for hypervisor kvm)"`
BootMode string `help:"UEFI support" choices:"UEFI|BIOS"`
VdiProtocol string `help:"VDI protocol" choices:"vnc|spice"`
}
func addImageOptionalOptions(s *mcclient.ClientSession, params *jsonutils.JSONDict, args ImageOptionalOptions) error {
@@ -146,6 +147,9 @@ func addImageOptionalOptions(s *mcclient.ClientSession, params *jsonutils.JSONDi
} else if args.BootMode == "BIOS" {
params.Add(jsonutils.JSONFalse, "properties", "uefi_support")
}
if len(args.VdiProtocol) > 0 {
params.Add(jsonutils.NewString(args.VdiProtocol), "properties", "vdi_protocol")
}
return nil
}
+1
View File
@@ -58,6 +58,7 @@ const (
IMAGE_PARTITION_TYPE = "partition_type"
IMAGE_INSTALLED_CLOUDINIT = "installed_cloud_init"
IMAGE_DISABLE_USB_KBD = "disable_usb_kbd"
IMAGE_VDI_PROTOCOL = "vdi_protocol"
IMAGE_STATUS_UPDATING = "updating"
)
+3
View File
@@ -1332,6 +1332,9 @@ func (manager *SGuestManager) validateCreateData(
}
input.DisableUsbKbd = imgProperties[imageapi.IMAGE_DISABLE_USB_KBD] == "true"
if vdi, ok := imgProperties[imageapi.IMAGE_VDI_PROTOCOL]; ok && len(vdi) > 0 {
input.Vdi = vdi
}
osType := input.OsType
osProf, err = osprofile.GetOSProfileFromImageProperties(imgProperties, hypervisor)
if err != nil {