fix(region): update qcloud storage type (#22615)

This commit is contained in:
屈轩
2025-05-27 12:44:12 +08:00
committed by GitHub
parent 3d36c293e5
commit 892431d5b9
9 changed files with 53 additions and 11 deletions
+1 -1
View File
@@ -93,7 +93,7 @@ require (
k8s.io/cri-api v0.22.17
k8s.io/klog/v2 v2.20.0
moul.io/http2curl/v2 v2.3.0
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250519035927-2b74cec67090
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250527041552-273b3e8cd1c4
yunion.io/x/executor v0.0.0-20250518005516-5402e9e0bed0
yunion.io/x/jsonutils v1.0.1-0.20250507052344-1abcf4f443b1
yunion.io/x/log v1.0.1-0.20240305175729-7cf2d6cd5a91
+2 -2
View File
@@ -1376,8 +1376,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.20250519035927-2b74cec67090 h1:E/I9CkZumtHaEBweSYc9bq5rFZ25i+s17bAZskXLGDc=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250519035927-2b74cec67090/go.mod h1:FXxAEbdNfWXX9gjME3K2nJhkydHY5EKEUZb+RLEzVwQ=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250527041552-273b3e8cd1c4 h1:JQr0tiRyNlVupznmiWwxchCW4Qtv7IjFkDyAnF9rsAk=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250527041552-273b3e8cd1c4/go.mod h1:FXxAEbdNfWXX9gjME3K2nJhkydHY5EKEUZb+RLEzVwQ=
yunion.io/x/executor v0.0.0-20250518005516-5402e9e0bed0 h1:msG4SiDSVU7CrXH06WuHlNEZXIooTcmNbfrIGHuIHBU=
yunion.io/x/executor v0.0.0-20250518005516-5402e9e0bed0/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws=
yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634=
+2
View File
@@ -74,6 +74,8 @@ const (
STORAGE_CLOUD_BASIC = compute.STORAGE_CLOUD_BASIC
STORAGE_CLOUD_PREMIUM = compute.STORAGE_CLOUD_PREMIUM //高性能云硬盘
STORAGE_CLOUD_HSSD = compute.STORAGE_CLOUD_HSSD //增强型SSD云硬盘
STORAGE_CLOUD_BSSD = compute.STORAGE_CLOUD_BSSD //增强型SSD云硬盘
STORAGE_CLOUD_TSSD = compute.STORAGE_CLOUD_TSSD //极速型SSD云硬盘
// huawei storage type
STORAGE_HUAWEI_SSD = compute.STORAGE_HUAWEI_SSD // 超高IO云硬盘
+11 -5
View File
@@ -76,6 +76,8 @@ func (self *SQcloudGuestDriver) GetStorageTypes() []string {
api.STORAGE_LOCAL_BASIC,
api.STORAGE_LOCAL_SSD,
api.STORAGE_CLOUD_HSSD,
api.STORAGE_CLOUD_BSSD,
api.STORAGE_CLOUD_TSSD,
}
}
@@ -139,7 +141,7 @@ func (self *SQcloudGuestDriver) ValidateCreateData(ctx context.Context, userCred
if sysDisk.SizeMb > 1024*1024 {
return nil, fmt.Errorf("The %s system disk size must be less than 1024GB", sysDisk.Backend)
}
case api.STORAGE_LOCAL_PRO, api.STORAGE_CLOUD_HSSD: //https://cloud.tencent.com/document/product/362/2353
case api.STORAGE_LOCAL_PRO: //https://cloud.tencent.com/document/product/362/2353
return nil, fmt.Errorf("storage %s can not be system disk", sysDisk.Backend)
}
@@ -154,7 +156,7 @@ func (self *SQcloudGuestDriver) ValidateCreateData(ctx context.Context, userCred
if disk.SizeMb < 10*1024 || disk.SizeMb > 32000*1024 {
return nil, httperrors.NewInputParameterError("The %s disk size must be in the range of 10GB ~ 32000GB", disk.Backend)
}
case api.STORAGE_CLOUD_SSD, api.STORAGE_CLOUD_HSSD:
case api.STORAGE_CLOUD_SSD, api.STORAGE_CLOUD_HSSD, api.STORAGE_CLOUD_BSSD, api.STORAGE_CLOUD_TSSD:
if disk.SizeMb < 20*1024 || disk.SizeMb > 32000*1024 {
return nil, httperrors.NewInputParameterError("The %s disk size must be in the range of 20GB ~ 32000GB", disk.Backend)
}
@@ -199,7 +201,7 @@ func (qcloud *SQcloudGuestDriver) ValidateGuestChangeConfigInput(ctx context.Con
if newDisk.SizeMb < 10*1024 || newDisk.SizeMb > 32000*1024 {
return nil, httperrors.NewInputParameterError("The %s disk size must be in the range of 10GB ~ 32000GB", newDisk.Backend)
}
case api.STORAGE_CLOUD_SSD, api.STORAGE_CLOUD_HSSD:
case api.STORAGE_CLOUD_SSD, api.STORAGE_CLOUD_HSSD, api.STORAGE_CLOUD_BSSD, api.STORAGE_CLOUD_TSSD:
if newDisk.SizeMb < 20*1024 || newDisk.SizeMb > 32000*1024 {
return nil, httperrors.NewInputParameterError("The %s disk size must be in the range of 20GB ~ 32000GB", newDisk.Backend)
}
@@ -273,12 +275,16 @@ func (self *SQcloudGuestDriver) GetInstanceCapability() cloudprovider.SInstanceC
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_BASIC, MaxSizeGb: 16000, MinSizeGb: 10, StepSizeGb: 10, Resizable: true},
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_PREMIUM, MaxSizeGb: 16000, MinSizeGb: 50, StepSizeGb: 10, Resizable: true},
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_SSD, MaxSizeGb: 16000, MinSizeGb: 100, StepSizeGb: 10, Resizable: true},
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_HSSD, MaxSizeGb: 32000, MinSizeGb: 20, StepSizeGb: 10, Resizable: true},
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_HSSD, MaxSizeGb: 32000, MinSizeGb: 20, StepSizeGb: 1, Resizable: true},
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_BSSD, MaxSizeGb: 32000, MinSizeGb: 20, StepSizeGb: 1, Resizable: true},
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_TSSD, MaxSizeGb: 32000, MinSizeGb: 20, StepSizeGb: 1, Resizable: true},
},
SysDisk: []cloudprovider.StorageInfo{
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_BASIC, MaxSizeGb: 500, MinSizeGb: 50, StepSizeGb: 10, Resizable: false},
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_PREMIUM, MaxSizeGb: 1024, MinSizeGb: 50, StepSizeGb: 10, Resizable: false},
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_SSD, MaxSizeGb: 500, MinSizeGb: 50, StepSizeGb: 10, Resizable: false},
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_SSD, MaxSizeGb: 500, MinSizeGb: 50, StepSizeGb: 1, Resizable: false},
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_BSSD, MaxSizeGb: 32000, MinSizeGb: 20, StepSizeGb: 1, Resizable: true},
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_TSSD, MaxSizeGb: 32000, MinSizeGb: 20, StepSizeGb: 1, Resizable: true},
},
},
}
+1 -1
View File
@@ -60,7 +60,7 @@ func (self *SQcloudHostDriver) ValidateDiskSize(storage *models.SStorage, sizeGb
min, max = 50, 16000
case api.STORAGE_CLOUD_SSD:
min, max = 100, 16000
case api.STORAGE_CLOUD_HSSD:
case api.STORAGE_CLOUD_HSSD, api.STORAGE_CLOUD_BSSD, api.STORAGE_CLOUD_TSSD:
min, max = 20, 320000
default:
return fmt.Errorf("Not support create or resize %s disk", storage.StorageType)
+1 -1
View File
@@ -1785,7 +1785,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.20250519035927-2b74cec67090
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250527041552-273b3e8cd1c4
## explicit; go 1.21
yunion.io/x/cloudmux/pkg/apis
yunion.io/x/cloudmux/pkg/apis/billing
+2
View File
@@ -58,6 +58,8 @@ const (
STORAGE_CLOUD_BASIC = "cloud_basic"
STORAGE_CLOUD_PREMIUM = "cloud_premium" //高性能云硬盘
STORAGE_CLOUD_HSSD = "cloud_hssd" //增强型SSD云硬盘
STORAGE_CLOUD_TSSD = "cloud_tssd" //极速型SSD云硬盘
STORAGE_CLOUD_BSSD = "cloud_bssd" //通用型SSD云硬盘
// huawei storage type
STORAGE_HUAWEI_SSD = "SSD" // 超高IO云硬盘
+32
View File
@@ -785,3 +785,35 @@ func (self *SHuaweiClient) put(service, regionId, resource string, params map[st
}
return self.request(httputils.PUT, regionId, service, url, nil, params)
}
type SMonthBill struct {
Currency string
ConsumeAmount float64
BillSums []struct {
CustomerId string
ConsumeAmount float64
}
}
// https://console.huaweicloud.com/apiexplorer/#/openapi/BSS/doc?api=ShowCustomerMonthlySum
func (self *SHuaweiClient) QueryAccountMonthBill(month int) (*SMonthBill, error) {
ret := SMonthBill{}
query := url.Values{}
query.Set("bill_cycle", fmt.Sprintf("%d-%d", month/10, month%10))
for _, service := range []string{SERVICE_BSS, SERVICE_BSS_INTL} {
resp, err := self.list(service, "", "bills/customer-bills/monthly-sum", query)
if err != nil {
// 国际区账号会报错: {"error_code":"CBC.0150","error_msg":"Access denied. The customer does not belong to the website you are now at."}
if e, ok := err.(*sHuaweiError); ok && (e.ErrorCode == "CBC.0150" || e.ErrorCode == "CBC.0156") {
continue
}
return nil, err
}
err = resp.Unmarshal(&ret)
if err != nil {
return nil, err
}
break
}
return &ret, nil
}
+1 -1
View File
@@ -152,5 +152,5 @@ func (self *SStorage) GetMountPoint() string {
}
func (self *SStorage) IsSysDiskStore() bool {
return strings.ToLower(self.storageType) != api.STORAGE_CLOUD_HSSD
return true
}