hotfix: essd PerformanceLevel sync

This commit is contained in:
ioito
2019-08-07 15:30:19 +08:00
parent f6482ee3f1
commit 339145ec4a
7 changed files with 95 additions and 23 deletions
+6 -3
View File
@@ -28,8 +28,10 @@ const (
STORAGE_PUBLIC_CLOUD = "cloud"
STORAGE_CLOUD_EFFICIENCY = "cloud_efficiency"
STORAGE_CLOUD_SSD = "cloud_ssd"
STORAGE_CLOUD_ESSD = "cloud_essd" //增强型(Enhanced)SSD 云盘
STORAGE_EPHEMERAL_SSD = "ephemeral_ssd" //单块本地SSD盘, 容量最大不能超过800 GiB
STORAGE_CLOUD_ESSD = "cloud_essd" //增强型(Enhanced)SSD 云盘, 单盘最高随机读写IOPS 5万
STORAGE_CLOUD_ESSD_PL2 = "cloud_essd_pl2" //单盘最高随机读写IOPS 10万
STORAGE_CLOUD_ESSD_PL3 = "cloud_essd_pl3" //单盘最高随机读写IOPS 100万
STORAGE_EPHEMERAL_SSD = "ephemeral_ssd" //单块本地SSD盘, 容量最大不能超过800 GiB
//Azure hdd and ssd storagetype
STORAGE_STANDARD_LRS = "standard_lrs"
@@ -98,7 +100,8 @@ var (
}
STORAGE_TYPES = []string{STORAGE_LOCAL, STORAGE_BAREMETAL, STORAGE_SHEEPDOG,
STORAGE_RBD, STORAGE_DOCKER, STORAGE_NAS, STORAGE_VSAN, STORAGE_NFS,
STORAGE_PUBLIC_CLOUD, STORAGE_CLOUD_SSD, STORAGE_CLOUD_ESSD, STORAGE_EPHEMERAL_SSD, STORAGE_CLOUD_EFFICIENCY,
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_LOCAL_BASIC, STORAGE_LOCAL_SSD, STORAGE_CLOUD_BASIC, STORAGE_CLOUD_PREMIUM,
+8
View File
@@ -65,6 +65,8 @@ func (self *SAliyunGuestDriver) GetStorageTypes() []string {
api.STORAGE_CLOUD_EFFICIENCY,
api.STORAGE_CLOUD_SSD,
api.STORAGE_CLOUD_ESSD,
api.STORAGE_CLOUD_ESSD_PL2,
api.STORAGE_CLOUD_ESSD_PL3,
api.STORAGE_PUBLIC_CLOUD,
api.STORAGE_EPHEMERAL_SSD,
}
@@ -122,6 +124,12 @@ func (self *SAliyunGuestDriver) ValidateCreateData(ctx context.Context, userCred
case api.STORAGE_CLOUD_EFFICIENCY, api.STORAGE_CLOUD_SSD, api.STORAGE_CLOUD_ESSD:
minGB = 20
maxGB = 32768
case api.STORAGE_CLOUD_ESSD_PL2:
minGB = 461
maxGB = 32768
case api.STORAGE_CLOUD_ESSD_PL3:
minGB = 1261
maxGB = 32768
case api.STORAGE_PUBLIC_CLOUD:
minGB = 5
maxGB = 2000
+20 -12
View File
@@ -17,8 +17,6 @@ package hostdrivers
import (
"fmt"
"yunion.io/x/pkg/utils"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/compute/models"
)
@@ -41,16 +39,26 @@ func (self *SAliyunHostDriver) GetHypervisor() string {
}
func (self *SAliyunHostDriver) ValidateDiskSize(storage *models.SStorage, sizeGb int) error {
if utils.IsInStringArray(storage.StorageType, []string{api.STORAGE_CLOUD_EFFICIENCY, api.STORAGE_CLOUD_SSD, api.STORAGE_CLOUD_ESSD}) {
if sizeGb < 20 || sizeGb > 32768 {
return fmt.Errorf("The %s disk size must be in the range of 20G ~ 32768GB", storage.StorageType)
}
} else if storage.StorageType == api.STORAGE_PUBLIC_CLOUD {
if sizeGb < 5 || sizeGb > 2000 {
return fmt.Errorf("The %s disk size must be in the range of 5G ~ 2000GB", storage.StorageType)
}
} else {
return fmt.Errorf("Not support create %s disk", storage.StorageType)
minGB := -1
maxGB := -1
switch storage.StorageType {
case api.STORAGE_CLOUD_EFFICIENCY, api.STORAGE_CLOUD_SSD, api.STORAGE_CLOUD_ESSD:
minGB = 20
maxGB = 32768
case api.STORAGE_CLOUD_ESSD_PL2:
minGB = 461
maxGB = 32768
case api.STORAGE_CLOUD_ESSD_PL3:
minGB = 1261
maxGB = 32768
case api.STORAGE_PUBLIC_CLOUD:
minGB = 5
maxGB = 2000
default:
return fmt.Errorf("Not support resize %s disk", storage.StorageType)
}
if sizeGb < minGB || sizeGb > maxGB {
return fmt.Errorf("The %s disk size must be in the range of %dG ~ %dGB", storage.StorageType, minGB, maxGB)
}
return nil
}
+9
View File
@@ -43,6 +43,7 @@ type SDisk struct {
AttachedTime time.Time
AutoSnapshotPolicyId string
Category string
PerformanceLevel string
CreationTime time.Time
DeleteAutoSnapshot bool
DeleteWithInstance bool
@@ -257,6 +258,14 @@ func (self *SRegion) CreateDisk(zoneId string, category string, name string, siz
}
params["Encrypted"] = "false"
params["DiskCategory"] = category
if category == api.STORAGE_CLOUD_ESSD_PL2 {
params["DiskCategory"] = api.STORAGE_CLOUD_ESSD
params["PerformanceLevel"] = "PL2"
}
if category == api.STORAGE_CLOUD_ESSD_PL3 {
params["DiskCategory"] = api.STORAGE_CLOUD_ESSD
params["PerformanceLevel"] = "PL3"
}
params["Size"] = fmt.Sprintf("%d", sizeGb)
params["ClientToken"] = utils.GenRequestId(20)
+16
View File
@@ -573,12 +573,28 @@ func (self *SRegion) CreateInstance(name string, imageId string, instanceType st
for i, d := range disks {
if i == 0 {
params["SystemDisk.Category"] = d.Category
if d.Category == api.STORAGE_CLOUD_ESSD_PL2 {
params["SystemDisk.Category"] = api.STORAGE_CLOUD_ESSD
params["SystemDisk.PerformanceLevel"] = "PL2"
}
if d.Category == api.STORAGE_CLOUD_ESSD_PL3 {
params["SystemDisk.Category"] = api.STORAGE_CLOUD_ESSD
params["SystemDisk.PerformanceLevel"] = "PL3"
}
params["SystemDisk.Size"] = fmt.Sprintf("%d", d.Size)
params["SystemDisk.DiskName"] = d.GetName()
params["SystemDisk.Description"] = d.Description
} else {
params[fmt.Sprintf("DataDisk.%d.Size", i)] = fmt.Sprintf("%d", d.Size)
params[fmt.Sprintf("DataDisk.%d.Category", i)] = d.Category
if d.Category == api.STORAGE_CLOUD_ESSD_PL2 {
params[fmt.Sprintf("DataDisk.%d.Category", i)] = api.STORAGE_CLOUD_ESSD
params[fmt.Sprintf("DataDisk.%d..PerformanceLevel", i)] = "PL2"
}
if d.Category == api.STORAGE_CLOUD_ESSD_PL3 {
params[fmt.Sprintf("DataDisk.%d.Category", i)] = api.STORAGE_CLOUD_ESSD
params[fmt.Sprintf("DataDisk.%d..PerformanceLevel", i)] = "PL3"
}
params[fmt.Sprintf("DataDisk.%d.DiskName", i)] = d.GetName()
params[fmt.Sprintf("DataDisk.%d.Description", i)] = d.Description
params[fmt.Sprintf("DataDisk.%d.Encrypted", i)] = "false"
+23 -5
View File
@@ -1,4 +1,3 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -57,14 +56,33 @@ func (self *SStorage) GetIZone() cloudprovider.ICloudZone {
func (self *SStorage) GetIDisks() ([]cloudprovider.ICloudDisk, error) {
disks := make([]SDisk, 0)
offset := 0
storageType := self.storageType
if self.storageType == api.STORAGE_CLOUD_ESSD_PL2 || self.storageType == api.STORAGE_CLOUD_ESSD_PL3 {
storageType = api.STORAGE_CLOUD_ESSD
}
for {
parts, total, err := self.zone.region.GetDisks("", self.zone.GetId(), self.storageType, nil, len(disks), 50)
parts, total, err := self.zone.region.GetDisks("", self.zone.GetId(), storageType, nil, offset, 50)
if err != nil {
log.Errorf("GetDisks fail %s", err)
return nil, err
}
disks = append(disks, parts...)
if len(disks) >= total {
performanceLevel := ""
switch self.storageType {
case api.STORAGE_CLOUD_ESSD_PL2:
performanceLevel = "PL2"
case api.STORAGE_CLOUD_ESSD_PL3:
performanceLevel = "PL3"
}
for _, disk := range parts {
if disk.PerformanceLevel == performanceLevel {
disks = append(disks, disk)
}
}
offset += len(parts)
if offset >= total {
break
}
}
@@ -82,7 +100,7 @@ func (self *SStorage) GetStorageType() string {
}
func (self *SStorage) GetMediumType() string {
if strings.HasSuffix(self.storageType, "_ssd") {
if strings.Contains(self.storageType, "_ssd") {
return api.DISK_TYPE_SSD
} else {
return api.DISK_TYPE_ROTATE
+13 -3
View File
@@ -171,11 +171,17 @@ func (self *SZone) fetchStorages() error {
// if len(self.AvailableResources.ResourcesInfo) > 0 {
// categories = self.AvailableResources.ResourcesInfo[0].SystemDiskCategories.SupportedSystemDiskCategory
// }
self.istorages = make([]cloudprovider.ICloudStorage, len(categories))
self.istorages = []cloudprovider.ICloudStorage{}
for i, sc := range categories {
for _, sc := range categories {
storage := SStorage{zone: self, storageType: sc}
self.istorages[i] = &storage
self.istorages = append(self.istorages, &storage)
if sc == api.STORAGE_CLOUD_ESSD {
storage_l2 := SStorage{zone: self, storageType: api.STORAGE_CLOUD_ESSD_PL2}
self.istorages = append(self.istorages, &storage_l2)
storage_l3 := SStorage{zone: self, storageType: api.STORAGE_CLOUD_ESSD_PL3}
self.istorages = append(self.istorages, &storage_l3)
}
}
return nil
}
@@ -258,6 +264,10 @@ func (self *SZone) getNetworkById(vswitchId string) *SVSwitch {
func (self *SZone) getSysDiskCategories() []string {
if len(self.AvailableResources.ResourcesInfo) > 0 {
if utils.IsInStringArray(api.STORAGE_CLOUD_ESSD, self.AvailableResources.ResourcesInfo[0].SystemDiskCategories.SupportedSystemDiskCategory) {
self.AvailableResources.ResourcesInfo[0].SystemDiskCategories.SupportedSystemDiskCategory = append(self.AvailableResources.ResourcesInfo[0].SystemDiskCategories.SupportedSystemDiskCategory, api.STORAGE_CLOUD_ESSD_PL2)
self.AvailableResources.ResourcesInfo[0].SystemDiskCategories.SupportedSystemDiskCategory = append(self.AvailableResources.ResourcesInfo[0].SystemDiskCategories.SupportedSystemDiskCategory, api.STORAGE_CLOUD_ESSD_PL3)
}
return self.AvailableResources.ResourcesInfo[0].SystemDiskCategories.SupportedSystemDiskCategory
}
return nil