mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): support aliyun pl0 storage
This commit is contained in:
@@ -83,7 +83,7 @@ require (
|
||||
k8s.io/client-go v0.19.3
|
||||
k8s.io/cluster-bootstrap v0.19.3
|
||||
moul.io/http2curl/v2 v2.3.0
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230704115544-46184b6aad76
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230706122931-453a78feed4b
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32
|
||||
yunion.io/x/jsonutils v1.0.1-0.20230613121553-0f3b41e2ef19
|
||||
yunion.io/x/log v1.0.1-0.20230411060016-feb3f46ab361
|
||||
|
||||
@@ -1174,8 +1174,8 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
|
||||
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230704115544-46184b6aad76 h1:4SJeNFdCosLHI+KUVyY/Pnib4HB2NVDpiyj5TKK8Ixg=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230704115544-46184b6aad76/go.mod h1:crMeQeaNaZefTXfXbQkoj5SStggqkSNVABHtYBFjM3Y=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230706122931-453a78feed4b h1:UJ8NKzWuGj7CilY5qE098iRGmbTC0XRsGo+CYZpb8WA=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230706122931-453a78feed4b/go.mod h1:crMeQeaNaZefTXfXbQkoj5SStggqkSNVABHtYBFjM3Y=
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32 h1:v7POYkQwo1XzOxBoIoRVr/k0V9Y5JyjpshlIFa9raug=
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws=
|
||||
yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634=
|
||||
|
||||
@@ -38,9 +38,11 @@ const (
|
||||
STORAGE_PUBLIC_CLOUD = compute.STORAGE_PUBLIC_CLOUD
|
||||
STORAGE_CLOUD_EFFICIENCY = compute.STORAGE_CLOUD_EFFICIENCY
|
||||
STORAGE_CLOUD_SSD = compute.STORAGE_CLOUD_SSD
|
||||
STORAGE_CLOUD_ESSD_PL0 = compute.STORAGE_CLOUD_ESSD_PL0 // 增强型(Enhanced)SSD 云盘, 单盘最高随机读写IOPS 1万
|
||||
STORAGE_CLOUD_ESSD = compute.STORAGE_CLOUD_ESSD // 增强型(Enhanced)SSD 云盘, 单盘最高随机读写IOPS 5万
|
||||
STORAGE_CLOUD_ESSD_PL2 = compute.STORAGE_CLOUD_ESSD_PL2 // 单盘最高随机读写IOPS 10万
|
||||
STORAGE_CLOUD_ESSD_PL3 = compute.STORAGE_CLOUD_ESSD_PL3 // 单盘最高随机读写IOPS 100万
|
||||
STORAGE_CLOUD_AUTO = compute.STORAGE_CLOUD_AUTO // ESSD AutoPL
|
||||
STORAGE_EPHEMERAL_SSD = compute.STORAGE_EPHEMERAL_SSD // 单块本地SSD盘, 容量最大不能超过800 GiB
|
||||
STORAGE_LOCAL_HDD_PRO = compute.STORAGE_LOCAL_HDD_PRO // 实例规格族d1ne和d1搭载的SATA HDD本地盘
|
||||
STORAGE_LOCAL_SSD_PRO = compute.STORAGE_LOCAL_SSD_PRO // 实例规格族i2、i2g、i1、ga1和gn5等搭载的NVMe
|
||||
|
||||
@@ -72,9 +72,11 @@ func (self *SAliyunGuestDriver) GetStorageTypes() []string {
|
||||
return []string{
|
||||
api.STORAGE_CLOUD_EFFICIENCY,
|
||||
api.STORAGE_CLOUD_SSD,
|
||||
api.STORAGE_CLOUD_ESSD_PL0,
|
||||
api.STORAGE_CLOUD_ESSD,
|
||||
api.STORAGE_CLOUD_ESSD_PL2,
|
||||
api.STORAGE_CLOUD_ESSD_PL3,
|
||||
api.STORAGE_CLOUD_AUTO,
|
||||
api.STORAGE_PUBLIC_CLOUD,
|
||||
api.STORAGE_EPHEMERAL_SSD,
|
||||
}
|
||||
@@ -148,10 +150,12 @@ func (self *SAliyunGuestDriver) ValidateCreateData(ctx context.Context, userCred
|
||||
case api.STORAGE_EPHEMERAL_SSD:
|
||||
minGB = 5
|
||||
maxGB = 800
|
||||
case api.STORAGE_CLOUD_AUTO, api.STORAGE_CLOUD_ESSD_PL0:
|
||||
minGB = 40
|
||||
maxGB = 32768
|
||||
}
|
||||
if i == 0 {
|
||||
minGB = 20
|
||||
maxGB = 500
|
||||
if i == 0 && (disk.SizeMb < 20*1024 || disk.SizeMb > 500*1024) {
|
||||
return nil, httperrors.NewInputParameterError("The system disk size must be in the range of 20GB ~ 500Gb")
|
||||
}
|
||||
if disk.SizeMb < minGB*1024 || disk.SizeMb > maxGB*1024 {
|
||||
return nil, httperrors.NewInputParameterError("The %s disk size must be in the range of %dGB ~ %dGB", disk.Backend, minGB, maxGB)
|
||||
@@ -187,18 +191,24 @@ func (self *SAliyunGuestDriver) GetInstanceCapability() cloudprovider.SInstanceC
|
||||
},
|
||||
Storages: cloudprovider.Storage{
|
||||
DataDisk: []cloudprovider.StorageInfo{
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_EFFICIENCY, MaxSizeGb: 32768, MinSizeGb: 20, StepSizeGb: 1, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_SSD, MaxSizeGb: 32768, MinSizeGb: 20, StepSizeGb: 1, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_ESSD, MaxSizeGb: 32768, MinSizeGb: 20, StepSizeGb: 1, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_ESSD_PL2, MaxSizeGb: 32768, MinSizeGb: 461, StepSizeGb: 1, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_ESSD_PL3, MaxSizeGb: 32768, MinSizeGb: 1261, StepSizeGb: 1, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_PUBLIC_CLOUD, MaxSizeGb: 2000, MinSizeGb: 5, StepSizeGb: 1, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_EPHEMERAL_SSD, MaxSizeGb: 800, MinSizeGb: 5, StepSizeGb: 1, Resizable: true},
|
||||
{StorageType: api.STORAGE_CLOUD_EFFICIENCY, MaxSizeGb: 32768, MinSizeGb: 20, StepSizeGb: 1, Resizable: true},
|
||||
{StorageType: api.STORAGE_CLOUD_SSD, MaxSizeGb: 32768, MinSizeGb: 20, StepSizeGb: 1, Resizable: true},
|
||||
{StorageType: api.STORAGE_CLOUD_ESSD_PL0, MaxSizeGb: 32768, MinSizeGb: 40, StepSizeGb: 1, Resizable: true},
|
||||
{StorageType: api.STORAGE_CLOUD_ESSD, MaxSizeGb: 32768, MinSizeGb: 20, StepSizeGb: 1, Resizable: true},
|
||||
{StorageType: api.STORAGE_CLOUD_ESSD_PL2, MaxSizeGb: 32768, MinSizeGb: 461, StepSizeGb: 1, Resizable: true},
|
||||
{StorageType: api.STORAGE_CLOUD_ESSD_PL3, MaxSizeGb: 32768, MinSizeGb: 1261, StepSizeGb: 1, Resizable: true},
|
||||
{StorageType: api.STORAGE_CLOUD_AUTO, MaxSizeGb: 32768, MinSizeGb: 40, StepSizeGb: 1, Resizable: true},
|
||||
{StorageType: api.STORAGE_PUBLIC_CLOUD, MaxSizeGb: 2000, MinSizeGb: 5, StepSizeGb: 1, Resizable: true},
|
||||
{StorageType: api.STORAGE_EPHEMERAL_SSD, MaxSizeGb: 800, MinSizeGb: 5, StepSizeGb: 1, Resizable: true},
|
||||
},
|
||||
SysDisk: []cloudprovider.StorageInfo{
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_EFFICIENCY, MaxSizeGb: 500, MinSizeGb: 20, StepSizeGb: 1, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_SSD, MaxSizeGb: 500, MinSizeGb: 20, StepSizeGb: 1, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_ESSD, MaxSizeGb: 500, MinSizeGb: 20, StepSizeGb: 1, Resizable: true},
|
||||
{StorageType: api.STORAGE_CLOUD_EFFICIENCY, MaxSizeGb: 500, MinSizeGb: 20, StepSizeGb: 1, Resizable: true},
|
||||
{StorageType: api.STORAGE_CLOUD_SSD, MaxSizeGb: 500, MinSizeGb: 20, StepSizeGb: 1, Resizable: true},
|
||||
{StorageType: api.STORAGE_CLOUD_ESSD_PL0, MaxSizeGb: 32768, MinSizeGb: 40, StepSizeGb: 1, Resizable: true},
|
||||
{StorageType: api.STORAGE_CLOUD_ESSD, MaxSizeGb: 500, MinSizeGb: 20, StepSizeGb: 1, Resizable: true},
|
||||
{StorageType: api.STORAGE_CLOUD_ESSD_PL2, MaxSizeGb: 32768, MinSizeGb: 461, StepSizeGb: 1, Resizable: true},
|
||||
{StorageType: api.STORAGE_CLOUD_ESSD_PL3, MaxSizeGb: 32768, MinSizeGb: 1261, StepSizeGb: 1, Resizable: true},
|
||||
{StorageType: api.STORAGE_CLOUD_AUTO, MaxSizeGb: 32768, MinSizeGb: 40, StepSizeGb: 1, Resizable: true},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1396,6 +1396,53 @@ func (manager *SServerSkuManager) initializeSkuStatus() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (manager *SServerSkuManager) fixAliyunSkus() error {
|
||||
q := manager.Query().Equals("provider", api.CLOUD_PROVIDER_ALIYUN)
|
||||
q = q.Filter(sqlchemy.OR(
|
||||
sqlchemy.AND(
|
||||
sqlchemy.Contains(q.Field("sys_disk_type"), api.STORAGE_CLOUD_ESSD),
|
||||
sqlchemy.NOT(sqlchemy.Contains(q.Field("sys_disk_type"), api.STORAGE_CLOUD_ESSD_PL0)),
|
||||
),
|
||||
sqlchemy.AND(
|
||||
sqlchemy.Contains(q.Field("data_disk_types"), api.STORAGE_CLOUD_ESSD),
|
||||
sqlchemy.NOT(sqlchemy.Contains(q.Field("data_disk_types"), api.STORAGE_CLOUD_ESSD_PL0)),
|
||||
),
|
||||
))
|
||||
skus := []SServerSku{}
|
||||
err := db.FetchModelObjects(manager, q, &skus)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "db.FetchModelObjects")
|
||||
}
|
||||
storages := []string{api.STORAGE_CLOUD_ESSD_PL0, api.STORAGE_CLOUD_ESSD_PL2, api.STORAGE_CLOUD_ESSD_PL3}
|
||||
for i := range skus {
|
||||
_, err := db.Update(&skus[i], func() error {
|
||||
sys := strings.Split(skus[i].SysDiskType, ",")
|
||||
if utils.IsInStringArray(api.STORAGE_CLOUD_ESSD, sys) {
|
||||
for _, storage := range storages {
|
||||
if !utils.IsInStringArray(storage, sys) {
|
||||
sys = append(sys, storage)
|
||||
}
|
||||
}
|
||||
skus[i].SysDiskType = strings.Join(sys, ",")
|
||||
}
|
||||
data := strings.Split(skus[i].DataDiskTypes, ",")
|
||||
if utils.IsInStringArray(api.STORAGE_CLOUD_ESSD, data) {
|
||||
for _, storage := range storages {
|
||||
if !utils.IsInStringArray(storage, data) {
|
||||
data = append(data, storage)
|
||||
}
|
||||
}
|
||||
skus[i].DataDiskTypes = strings.Join(data, ",")
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "db.Update")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (manager *SServerSkuManager) InitializeData() error {
|
||||
count, err := manager.Query().Equals("cloudregion_id", api.DEFAULT_REGION_ID).IsNullOrEmpty("zone_id").CountWithError()
|
||||
if err != nil {
|
||||
@@ -1457,6 +1504,11 @@ func (manager *SServerSkuManager) InitializeData() error {
|
||||
}
|
||||
}
|
||||
|
||||
err = manager.fixAliyunSkus()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "fixAliyunSkus")
|
||||
}
|
||||
|
||||
return manager.initializeSkuStatus()
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1440,7 +1440,7 @@ sigs.k8s.io/structured-merge-diff/v4/value
|
||||
# sigs.k8s.io/yaml v1.2.0
|
||||
## explicit; go 1.12
|
||||
sigs.k8s.io/yaml
|
||||
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230704115544-46184b6aad76
|
||||
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230706122931-453a78feed4b
|
||||
## explicit; go 1.18
|
||||
yunion.io/x/cloudmux/pkg/apis
|
||||
yunion.io/x/cloudmux/pkg/apis/billing
|
||||
|
||||
+2
@@ -25,9 +25,11 @@ const (
|
||||
STORAGE_PUBLIC_CLOUD = "cloud"
|
||||
STORAGE_CLOUD_EFFICIENCY = "cloud_efficiency"
|
||||
STORAGE_CLOUD_SSD = "cloud_ssd"
|
||||
STORAGE_CLOUD_ESSD_PL0 = "cloud_essd_pl0" // 增强型(Enhanced)SSD 云盘, 单盘最高随机读写IOPS 1万
|
||||
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_CLOUD_AUTO = "cloud_auto" // ESSD AutoPL
|
||||
STORAGE_EPHEMERAL_SSD = "ephemeral_ssd" // 单块本地SSD盘, 容量最大不能超过800 GiB
|
||||
STORAGE_LOCAL_HDD_PRO = "local_hdd_pro" // 实例规格族d1ne和d1搭载的SATA HDD本地盘
|
||||
STORAGE_LOCAL_SSD_PRO = "local_ssd_pro" // 实例规格族i2、i2g、i1、ga1和gn5等搭载的NVMe
|
||||
|
||||
+4
@@ -248,6 +248,10 @@ func (self *SRegion) CreateDisk(zoneId string, category string, name string, siz
|
||||
}
|
||||
params["Encrypted"] = "false"
|
||||
params["DiskCategory"] = category
|
||||
if category == api.STORAGE_CLOUD_ESSD_PL0 {
|
||||
params["DiskCategory"] = api.STORAGE_CLOUD_ESSD
|
||||
params["PerformanceLevel"] = "PL0"
|
||||
}
|
||||
if category == api.STORAGE_CLOUD_ESSD_PL2 {
|
||||
params["DiskCategory"] = api.STORAGE_CLOUD_ESSD
|
||||
params["PerformanceLevel"] = "PL2"
|
||||
|
||||
+8
@@ -596,6 +596,10 @@ func (self *SRegion) CreateInstance(name, hostname string, imageId string, insta
|
||||
for i, d := range disks {
|
||||
if i == 0 {
|
||||
params["SystemDisk.Category"] = d.Category
|
||||
if d.Category == api.STORAGE_CLOUD_ESSD_PL0 {
|
||||
params["SystemDisk.Category"] = api.STORAGE_CLOUD_ESSD
|
||||
params["SystemDisk.PerformanceLevel"] = "PL0"
|
||||
}
|
||||
if d.Category == api.STORAGE_CLOUD_ESSD_PL2 {
|
||||
params["SystemDisk.Category"] = api.STORAGE_CLOUD_ESSD
|
||||
params["SystemDisk.PerformanceLevel"] = "PL2"
|
||||
@@ -610,6 +614,10 @@ func (self *SRegion) CreateInstance(name, hostname string, imageId string, insta
|
||||
} 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_PL0 {
|
||||
params[fmt.Sprintf("DataDisk.%d.Category", i)] = api.STORAGE_CLOUD_ESSD
|
||||
params[fmt.Sprintf("DataDisk.%d..PerformanceLevel", i)] = "PL0"
|
||||
}
|
||||
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"
|
||||
|
||||
+3
-1
@@ -72,7 +72,7 @@ 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 {
|
||||
if self.storageType == api.STORAGE_CLOUD_ESSD_PL2 || self.storageType == api.STORAGE_CLOUD_ESSD_PL3 || self.storageType == api.STORAGE_CLOUD_ESSD_PL0 {
|
||||
storageType = api.STORAGE_CLOUD_ESSD
|
||||
}
|
||||
for {
|
||||
@@ -82,6 +82,8 @@ func (self *SStorage) GetIDisks() ([]cloudprovider.ICloudDisk, error) {
|
||||
}
|
||||
performanceLevel := ""
|
||||
switch self.storageType {
|
||||
case api.STORAGE_CLOUD_ESSD_PL0:
|
||||
performanceLevel = "PL0"
|
||||
case api.STORAGE_CLOUD_ESSD:
|
||||
performanceLevel = "PL1"
|
||||
case api.STORAGE_CLOUD_ESSD_PL2:
|
||||
|
||||
+3
-1
@@ -197,6 +197,8 @@ func (self *SZone) fetchStorages() error {
|
||||
storage := SStorage{zone: self, storageType: sc}
|
||||
self.istorages = append(self.istorages, &storage)
|
||||
if sc == api.STORAGE_CLOUD_ESSD {
|
||||
storage_l0 := SStorage{zone: self, storageType: api.STORAGE_CLOUD_ESSD_PL0}
|
||||
self.istorages = append(self.istorages, &storage_l0)
|
||||
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}
|
||||
@@ -302,7 +304,7 @@ func (self *SZone) getSysDiskCategories() []string {
|
||||
}
|
||||
}
|
||||
if utils.IsInStringArray(api.STORAGE_CLOUD_ESSD, ret) {
|
||||
ret = append(ret, []string{api.STORAGE_CLOUD_ESSD_PL2, api.STORAGE_CLOUD_ESSD_PL3}...)
|
||||
ret = append(ret, []string{api.STORAGE_CLOUD_ESSD_PL2, api.STORAGE_CLOUD_ESSD_PL3, api.STORAGE_CLOUD_ESSD_PL0}...)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
+7
-2
@@ -1339,9 +1339,14 @@ func (self *SVirtualMachine) DoCustomize(ctx context.Context, params jsonutils.J
|
||||
if params.Contains("name") {
|
||||
name, _ = params.GetString("name")
|
||||
}
|
||||
// avoid spec.identity.hostName error
|
||||
hostname := strings.ReplaceAll(name, "_", "")
|
||||
if len(hostname) > 15 {
|
||||
hostname = hostname[:15]
|
||||
}
|
||||
if osName == "Linux" {
|
||||
linuxPrep := types.CustomizationLinuxPrep{
|
||||
HostName: &types.CustomizationFixedName{Name: name},
|
||||
HostName: &types.CustomizationFixedName{Name: hostname},
|
||||
Domain: domain,
|
||||
TimeZone: "Asia/Shanghai",
|
||||
}
|
||||
@@ -1357,7 +1362,7 @@ func (self *SVirtualMachine) DoCustomize(ctx context.Context, params jsonutils.J
|
||||
OrgName: "Yunion",
|
||||
ProductId: "",
|
||||
ComputerName: &types.CustomizationFixedName{
|
||||
Name: name,
|
||||
Name: hostname,
|
||||
},
|
||||
},
|
||||
Identification: types.CustomizationIdentification{},
|
||||
|
||||
Reference in New Issue
Block a user