fix(region): aws create storage type fix

This commit is contained in:
TangBin
2020-12-15 14:42:17 +08:00
parent fc64ea3252
commit 208adf8a02
5 changed files with 17 additions and 6 deletions

View File

@@ -45,6 +45,7 @@ const (
// aws storage type
STORAGE_GP2_SSD = "gp2" // aws general purpose ssd
STORAGE_GP3_SSD = "gp3" // aws General Purpose SSD (gp3)
STORAGE_IO1_SSD = "io1" // aws Provisioned IOPS SSD
STORAGE_IO2_SSD = "io2" // aws Provisioned IOPS 2 SSD
STORAGE_ST1_HDD = "st1" // aws Throughput Optimized HDD
@@ -125,7 +126,7 @@ var (
STORAGE_PUBLIC_CLOUD, STORAGE_CLOUD_SSD, STORAGE_CLOUD_ESSD, STORAGE_CLOUD_ESSD_PL2, STORAGE_CLOUD_ESSD_PL3,
STORAGE_EPHEMERAL_SSD, STORAGE_CLOUD_EFFICIENCY,
STORAGE_STANDARD_LRS, STORAGE_STANDARDSSD_LRS, STORAGE_PREMIUM_LRS,
STORAGE_GP2_SSD, STORAGE_IO1_SSD, STORAGE_ST1_HDD, STORAGE_SC1_HDD, STORAGE_STANDARD_HDD,
STORAGE_GP2_SSD, STORAGE_GP3_SSD, STORAGE_IO1_SSD, STORAGE_ST1_HDD, STORAGE_SC1_HDD, STORAGE_STANDARD_HDD,
STORAGE_LOCAL_BASIC, STORAGE_LOCAL_SSD, STORAGE_CLOUD_BASIC, STORAGE_CLOUD_PREMIUM,
STORAGE_HUAWEI_SSD, STORAGE_HUAWEI_SAS, STORAGE_HUAWEI_SATA,
STORAGE_OPENSTACK_ISCSI, STORAGE_UCLOUD_CLOUD_NORMAL, STORAGE_UCLOUD_CLOUD_SSD,

View File

@@ -103,6 +103,7 @@ func (self *SAwsGuestDriver) GetInstanceCapability() cloudprovider.SInstanceCapa
Storages: cloudprovider.Storage{
DataDisk: []cloudprovider.StorageInfo{
cloudprovider.StorageInfo{StorageType: api.STORAGE_GP2_SSD, MaxSizeGb: 16384, MinSizeGb: 1, StepSizeGb: 1, Resizable: true},
cloudprovider.StorageInfo{StorageType: api.STORAGE_GP3_SSD, MaxSizeGb: 16384, MinSizeGb: 1, StepSizeGb: 1, Resizable: true},
cloudprovider.StorageInfo{StorageType: api.STORAGE_IO1_SSD, MaxSizeGb: 16384, MinSizeGb: 4, StepSizeGb: 1, Resizable: true},
cloudprovider.StorageInfo{StorageType: api.STORAGE_ST1_HDD, MaxSizeGb: 16384, MinSizeGb: 500, StepSizeGb: 1, Resizable: true},
cloudprovider.StorageInfo{StorageType: api.STORAGE_SC1_HDD, MaxSizeGb: 16384, MinSizeGb: 500, StepSizeGb: 1, Resizable: true},
@@ -157,6 +158,7 @@ func (self *SAwsGuestDriver) GetMinimalSysDiskSizeGb() int {
func (self *SAwsGuestDriver) GetStorageTypes() []string {
return []string{
api.STORAGE_GP2_SSD,
api.STORAGE_GP3_SSD,
api.STORAGE_IO1_SSD,
api.STORAGE_IO2_SSD,
api.STORAGE_ST1_HDD,
@@ -215,10 +217,10 @@ func (self *SAwsGuestDriver) ValidateResizeDisk(guest *models.SGuest, disk *mode
if !utils.IsInStringArray(guest.Status, []string{api.VM_RUNNING, api.VM_READY}) {
return fmt.Errorf("Cannot resize disk when guest in status %s", guest.Status)
}
if disk.DiskType == api.DISK_TYPE_SYS && !utils.IsInStringArray(storage.StorageType, []string{api.STORAGE_IO1_SSD, api.STORAGE_IO2_SSD, api.STORAGE_STANDARD_HDD, api.STORAGE_GP2_SSD}) {
if disk.DiskType == api.DISK_TYPE_SYS && !utils.IsInStringArray(storage.StorageType, []string{api.STORAGE_IO1_SSD, api.STORAGE_IO2_SSD, api.STORAGE_STANDARD_HDD, api.STORAGE_GP2_SSD, api.STORAGE_GP3_SSD}) {
return fmt.Errorf("Cannot resize system disk with unsupported volumes type %s", storage.StorageType)
}
if !utils.IsInStringArray(storage.StorageType, []string{api.STORAGE_GP2_SSD, api.STORAGE_IO1_SSD, api.STORAGE_IO2_SSD, api.STORAGE_ST1_HDD, api.STORAGE_SC1_HDD, api.STORAGE_STANDARD_HDD}) {
if !utils.IsInStringArray(storage.StorageType, []string{api.STORAGE_GP2_SSD, api.STORAGE_GP3_SSD, api.STORAGE_IO1_SSD, api.STORAGE_IO2_SSD, api.STORAGE_ST1_HDD, api.STORAGE_SC1_HDD, api.STORAGE_STANDARD_HDD}) {
return fmt.Errorf("Cannot resize %s disk", storage.StorageType)
}
return nil

View File

@@ -45,7 +45,7 @@ func (self *SAwsHostDriver) GetHypervisor() string {
}
func (self *SAwsHostDriver) ValidateDiskSize(storage *models.SStorage, sizeGb int) error {
if storage.StorageType == api.STORAGE_GP2_SSD {
if storage.StorageType == api.STORAGE_GP2_SSD || storage.StorageType == api.STORAGE_GP3_SSD {
if sizeGb < 1 || sizeGb > 16384 {
return fmt.Errorf("The %s disk size must be in the range of 1G ~ 16384GB", storage.StorageType)
}

View File

@@ -515,7 +515,11 @@ func getStorageTypes(
if !ok {
sts = make([]string, 0)
}
sts = append(sts, storageType)
if !utils.IsInStringArray(storageType, sts) {
sts = append(sts, storageType)
}
hypervisorStorageTypes[storageHypervisor] = sts
}
addStorageInfo = func(storage *StorageInfo, simpleStorage *SimpleStorageInfo) {

View File

@@ -66,7 +66,11 @@ func (self *SZone) getHost() *SHost {
func (self *SZone) getStorageType() {
if len(self.storageTypes) == 0 {
self.storageTypes = StorageTypes
if !utils.IsInStringArray(self.GetId(), []string{"af-south-1", "eu-south-1", "eu-west-3", "sa-east-1", "cn-north-1", "cn-northwest-1"}) {
if utils.IsInStringArray(self.region.GetId(), []string{"cn-north-1", "cn-northwest-1"}) {
self.storageTypes = append(self.storageTypes, api.STORAGE_GP3_SSD)
}
if !utils.IsInStringArray(self.region.GetId(), []string{"af-south-1", "eu-south-1", "eu-west-3", "sa-east-1", "cn-north-1", "cn-northwest-1"}) {
self.storageTypes = append(self.storageTypes, api.STORAGE_IO2_SSD)
}
}