mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-08-29 03:51:54 +08:00
fix(region): support use cached iso image for create cloudpods vm (#20685)
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
||||
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/cloudinit"
|
||||
"yunion.io/x/pkg/util/rbacscope"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
@@ -166,3 +167,13 @@ func (self *SCloudpodsGuestDriver) GetInstanceCapability() cloudprovider.SInstan
|
||||
func (self *SCloudpodsGuestDriver) GetMinimalSysDiskSizeGb() int {
|
||||
return options.Options.DefaultDiskSizeMB / 1024
|
||||
}
|
||||
|
||||
func (self *SCloudpodsGuestDriver) ValidateCreateData(ctx context.Context, userCred mcclient.TokenCredential, input *api.ServerCreateInput) (*api.ServerCreateInput, error) {
|
||||
if len(input.UserData) > 0 {
|
||||
_, err := cloudinit.ParseUserData(input.UserData)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return input, nil
|
||||
}
|
||||
|
||||
@@ -516,9 +516,18 @@ func (self *SRegion) CreateInstance(hostId, hypervisor string, opts *cloudprovid
|
||||
if opts.BillingCycle != nil {
|
||||
input.Duration = opts.BillingCycle.String()
|
||||
}
|
||||
image, err := self.GetImage(opts.ExternalImageId)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "GetImage")
|
||||
}
|
||||
imageId := opts.ExternalImageId
|
||||
if image.DiskFormat == "iso" {
|
||||
input.Cdrom = opts.ExternalImageId
|
||||
imageId = ""
|
||||
}
|
||||
input.Disks = append(input.Disks, &api.DiskConfig{
|
||||
Index: 0,
|
||||
ImageId: opts.ExternalImageId,
|
||||
ImageId: imageId,
|
||||
DiskType: api.DISK_TYPE_SYS,
|
||||
SizeMb: opts.SysDisk.SizeGB * 1024,
|
||||
Backend: opts.SysDisk.StorageType,
|
||||
|
||||
Reference in New Issue
Block a user