fix(region): cloudpods ipmi info sync (#23261)

This commit is contained in:
屈轩
2025-09-09 19:27:44 +08:00
committed by GitHub
parent 9dfa4ee355
commit f3337ed552
182 changed files with 359 additions and 294 deletions
+1 -1
View File
@@ -96,7 +96,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.20250904062553-2e7d040a1d28
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250909094125-d6c9c20a9d38
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
@@ -1409,8 +1409,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.20250904062553-2e7d040a1d28 h1:4PDFt1V4ti4pbWfh7VEhX/5tfhA+1jcn9qTIE6je3Fs=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250904062553-2e7d040a1d28/go.mod h1:FXxAEbdNfWXX9gjME3K2nJhkydHY5EKEUZb+RLEzVwQ=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250909094125-d6c9c20a9d38 h1:V54cxF3E3kSZDYMivoULheOgfZwUt8daMoWiSd2iWpw=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250909094125-d6c9c20a9d38/go.mod h1:7P/TJZk8o4JjhFnF1nGZcsPg+sIpMoV0dWPPuG6yGLg=
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=
+19
View File
@@ -36,6 +36,7 @@ import (
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/gotypes"
"yunion.io/x/pkg/tristate"
"yunion.io/x/pkg/util/compare"
"yunion.io/x/pkg/util/fileutils"
@@ -2318,6 +2319,15 @@ func (hh *SHost) SyncWithCloudHost(ctx context.Context, userCred mcclient.TokenC
hh.StorageDriver = storageDriver
}
hh.OvnVersion = extHost.GetOvnVersion()
if ipmiInfo := extHost.GetIpmiInfo(); !gotypes.IsNil(ipmiInfo) {
info := jsonutils.Marshal(ipmiInfo).(*jsonutils.JSONDict)
passwd, _ := info.GetString("password")
if len(passwd) > 0 {
passwd, _ = utils.EncryptAESBase64(hh.Id, passwd)
info.Set("password", jsonutils.NewString(passwd))
}
hh.IpmiInfo = info
}
if provider != nil && !utils.IsInStringArray(provider.Provider, strings.Split(options.Options.SkipSyncHostConfigInfoProviders, ",")) {
hh.CpuCount = extHost.GetCpuCount()
@@ -2565,6 +2575,15 @@ func (manager *SHostManager) NewFromCloudHost(ctx context.Context, userCred mccl
host.StorageInfo = extHost.GetStorageInfo()
host.OvnVersion = extHost.GetOvnVersion()
if ipmiInfo := extHost.GetIpmiInfo(); !gotypes.IsNil(ipmiInfo) {
info := jsonutils.Marshal(ipmiInfo).(*jsonutils.JSONDict)
passwd, _ := info.GetString("password")
if len(passwd) > 0 {
passwd, _ = utils.EncryptAESBase64(host.Id, passwd)
info.Set("password", jsonutils.NewString(passwd))
}
host.IpmiInfo = info
}
host.Status = extHost.GetStatus()
host.HostStatus = extHost.GetHostStatus()
+9
View File
@@ -196,6 +196,10 @@ func (host *SHost) GetSchedtags() ([]string, error) {
return ret, nil
}
func (host *SHost) GetIpmiInfo() jsonutils.JSONObject {
return host.zone.region.GetIpmiInfo(host.Id)
}
type SHostNic struct {
host *SHost
@@ -318,6 +322,11 @@ func (region *SRegion) GetHost(id string) (*SHost, error) {
return host, nil
}
func (region *SRegion) GetIpmiInfo(hostId string) jsonutils.JSONObject {
resp, _ := modules.Hosts.GetIpmiInfo(region.cli.s, hostId, nil)
return resp
}
func (zone *SZone) GetIHostById(id string) (cloudprovider.ICloudHost, error) {
host, err := zone.region.GetHost(id)
if err != nil {
+2 -2
View File
@@ -1852,8 +1852,8 @@ 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.20250904062553-2e7d040a1d28
## explicit; go 1.21
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250909094125-d6c9c20a9d38
## explicit; go 1.24
yunion.io/x/cloudmux/pkg/apis
yunion.io/x/cloudmux/pkg/apis/billing
yunion.io/x/cloudmux/pkg/apis/cloudid
+1 -1
View File
@@ -27,7 +27,7 @@
|---------|-----|--------|--------|------|-------|--------|--------|--------|-----|--------|--------|---------|--------|----------|--------|--------|--------|------------|
| CPU使用率(vm_cpu.usage_active) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| 内存使用率(vm_mem.used_percent) | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| 磁盘使用率(vm_disk.used_percent) | ❌ | ❌ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ✅ |
| 磁盘使用率(vm_disk.used_percent) | ❌ | ❌ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ✅ | ❌ | ✅ | ✅ | ❌ | ✅ |
| 磁盘读速率(vm_diskio.read_bps) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ |
| 磁盘写速率(vm_diskio.write_bps) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ |
| 磁盘读IOPS(vm_diskio.read_iops) | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ |
+1 -1
View File
@@ -127,7 +127,7 @@ const (
// 支持平台: kvm, aliyun, apsara, azure, esxi, bingocloud, jdcloud, ecloud, qcloud, volcengine, baidu, ctyun, oracle
VM_METRIC_TYPE_MEM_USAGE TMetricType = "vm_mem.used_percent"
// 虚拟机磁盘使用率
// 支持平台: aliyun, apsara, jdcloud, azure, baidu, ctyun, huawei, hcso, volcengine
// 支持平台: aliyun, apsara, jdcloud, azure, baidu, ctyun, huawei, hcso, volcengine, qcloud
// 支持按盘符(group_by=device)平台: aliyun, apsara
VM_METRIC_TYPE_DISK_USAGE TMetricType = "vm_disk.used_percent"
+1
View File
@@ -324,6 +324,7 @@ type ICloudHost interface {
GetOvnVersion() string // just for cloudpods host
GetIsolateDevices() ([]IsolateDevice, error)
GetIpmiInfo() jsonutils.JSONObject
}
type IsolateDevice interface {
+1 -1
View File
@@ -278,5 +278,5 @@ func (self *SAccessGroup) CreateRule(opts *cloudprovider.AccessGroupRule) (cloud
return &rules[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, ruleId)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", ruleId)
}
+4 -4
View File
@@ -241,9 +241,9 @@ func doRequest(client *sdk.Client, domain, apiVersion, apiName string, params ma
"InvalidAccessKeyId.Inactive",
"Forbidden.AccessKeyDisabled",
"Forbidden.AccessKey":
return nil, errors.Wrapf(cloudprovider.ErrInvalidAccessKey, err.Error())
return nil, errors.Wrapf(cloudprovider.ErrInvalidAccessKey, "%s", err.Error())
case "Forbidden.RAM":
return nil, errors.Wrapf(cloudprovider.ErrForbidden, err.Error())
return nil, errors.Wrapf(cloudprovider.ErrForbidden, "%s", err.Error())
case "404 Not Found", "InstanceNotFound":
return nil, errors.Wrap(cloudprovider.ErrNotFound, err.Error())
case "OperationDenied.NoStock":
@@ -393,7 +393,7 @@ func _jsonRequest(client *sdk.Client, domain string, version string, apiName str
if respBody.Contains("Code") {
code, _ := respBody.GetString("Code")
if len(code) > 0 && !utils.IsInStringArray(code, []string{"200", "Success"}) {
return nil, fmt.Errorf(respBody.String())
return nil, fmt.Errorf("%s", respBody.String())
}
}
return respBody, nil
@@ -513,7 +513,7 @@ func (self *SAliyunClient) _getSdkClient(regionId string) (*sdk.Client, error) {
}
}
if self.cpcfg.ReadOnly {
return respCheck, errors.Wrapf(cloudprovider.ErrAccountReadOnly, action)
return respCheck, errors.Wrapf(cloudprovider.ErrAccountReadOnly, "%s", action)
}
return respCheck, nil
})
+2 -2
View File
@@ -234,9 +234,9 @@ func (self *SAliyunClient) GetCDNDomainByName(name string) (*SCdnDomain, error)
return &domains[0], nil
}
if total == 0 {
return nil, errors.Wrapf(cloudprovider.ErrNotFound, name)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", name)
}
return nil, errors.Wrapf(cloudprovider.ErrDuplicateId, name)
return nil, errors.Wrapf(cloudprovider.ErrDuplicateId, "%s", name)
}
func (client *SAliyunClient) DescribeDomainsBySource(origin string) (SCdnDomainsList, error) {
+1 -1
View File
@@ -331,7 +331,7 @@ func (self *SRegion) getDisk(diskId string) (*SDisk, error) {
return &disks[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, diskId)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", diskId)
}
func (self *SRegion) DeleteDisk(diskId string) error {
+1 -1
View File
@@ -303,7 +303,7 @@ func (region *SRegion) GetEip(eipId string) (*SEipAddress, error) {
return &eips[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, eipId)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", eipId)
}
func (region *SRegion) AllocateEIP(opts *cloudprovider.SEip) (*SEipAddress, error) {
@@ -457,7 +457,7 @@ func (self *SElasticcache) GetAttribute() (*SElasticcacheAttribute, error) {
for i := range ret {
return &ret[i], nil
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, self.GetId())
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", self.GetId())
}
func (self *SElasticcache) GetNetInfo() ([]SNetInfo, error) {
@@ -582,7 +582,7 @@ func (self *SRegion) GetElasticCacheAccountByName(instanceId string, accountName
for i := range ret {
return &ret[i], nil
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, accountName)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", accountName)
}
// https://help.aliyun.com/document_detail/63889.html?spm=a2c4g.11186623.6.764.3cb43852R7lnoS
+2 -2
View File
@@ -235,9 +235,9 @@ func (self *SRegion) GetFileSystem(id string) (*SFileSystem, error) {
return &nas[0], nil
}
if total == 0 {
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
return nil, errors.Wrapf(cloudprovider.ErrDuplicateId, id)
return nil, errors.Wrapf(cloudprovider.ErrDuplicateId, "%s", id)
}
func (self *SRegion) GetICloudFileSystemById(id string) (cloudprovider.ICloudFileSystem, error) {
+1 -1
View File
@@ -64,7 +64,7 @@ func (self *SHost) GetIVMById(id string) (cloudprovider.ICloudVM, error) {
return &vms[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SHost) GetId() string {
+1 -1
View File
@@ -555,7 +555,7 @@ func (self *SRegion) GetInstance(instanceId string) (*SInstance, error) {
return &instances[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, instanceId)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", instanceId)
}
func (self *SRegion) CreateInstance(name, hostname string, imageId string, instanceType string, securityGroupIds []string,
+1 -1
View File
@@ -207,7 +207,7 @@ func (self *SRegion) GetKafka(id string) (*SKafka, error) {
return &kafkas[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SRegion) GetKafkas(ids []string) ([]SKafka, error) {
+20 -4
View File
@@ -87,6 +87,7 @@ type SMongoDB struct {
VSwitchId string `json:"VSwitchId"`
VpcAuthMode string `json:"VpcAuthMode"`
ReplicationFactor string `json:"ReplicationFactor"`
KindCode string `json:"KindCode"`
}
var mongoSpec = map[string]struct {
@@ -128,6 +129,16 @@ func (self *SMongoDB) GetStatus() string {
}
}
func (self *SMongoDB) GetSysTags() map[string]string {
ret := self.AliyunTags.GetSysTags()
if len(self.KindCode) == 0 {
self.Refresh()
}
// 用户需要通过KindCode区分是否是快照备份
ret["KindCode"] = self.KindCode
return ret
}
func (self *SMongoDB) GetProjectId() string {
return self.ResourceGroupId
}
@@ -233,6 +244,9 @@ func (self *SMongoDB) GetPort() int {
}
func (self *SMongoDB) GetReplicationNum() int {
if self.DBInstanceType == "sharding" {
return len(self.ShardList.ShardAttribute)
}
if len(self.ReplicationFactor) == 0 {
self.Refresh()
}
@@ -410,11 +424,13 @@ func (self *SRegion) GetMongoDB(id string) (*SMongoDB, error) {
if err != nil {
return nil, errors.Wrapf(err, "resp.Unmarshal")
}
if len(ret) == 1 {
ret[0].region = self
return &ret[0], nil
for i := range ret {
ret[i].region = self
if ret[i].DBInstanceId == id {
return &ret[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SRegion) DeleteMongoDB(id string) error {
+1 -1
View File
@@ -141,7 +141,7 @@ func (self *SNatGateway) Refresh() error {
return errors.Wrapf(cloudprovider.ErrDuplicateId, "get %d natgateways by id %s", total, self.NatGatewayId)
}
if total == 0 {
return errors.Wrapf(cloudprovider.ErrNotFound, self.NatGatewayId)
return errors.Wrapf(cloudprovider.ErrNotFound, "%s", self.NatGatewayId)
}
return jsonutils.Update(self, nat[0])
}
+1 -1
View File
@@ -209,7 +209,7 @@ func (self *SRegion) GetSecurityGroup(id string) (*SSecurityGroup, error) {
return &groups[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SRegion) CreateSecurityGroup(opts *cloudprovider.SecurityGroupCreateInput) (string, error) {
+2 -2
View File
@@ -77,7 +77,7 @@ func (self *SSnapshotPolicy) Refresh() error {
return jsonutils.Update(self, policies[i])
}
}
return errors.Wrapf(cloudprovider.ErrNotFound, self.AutoSnapshotPolicyId)
return errors.Wrapf(cloudprovider.ErrNotFound, "%s", self.AutoSnapshotPolicyId)
}
func (self *SSnapshotPolicy) IsEmulated() bool {
@@ -215,7 +215,7 @@ func (self *SRegion) GetISnapshotPolicyById(id string) (cloudprovider.ICloudSnap
return &policies[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SRegion) CreateSnapshotPolicy(input *cloudprovider.SnapshotPolicyInput) (string, error) {
+1 -1
View File
@@ -227,7 +227,7 @@ func (self *SVpc) GetIRouteTableById(routeTableId string) (cloudprovider.ICloudR
return tables[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, routeTableId)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", routeTableId)
}
func (self *SVpc) Delete() error {
+4 -4
View File
@@ -159,7 +159,7 @@ func jsonRequest(client *sdk.Client, domain, apiVersion, apiName string, params
}
for _, code := range []string{"404 Not Found", "EntityNotExist.Role", "EntityNotExist.Group"} {
if strings.Contains(err.Error(), code) {
return nil, errors.Wrapf(cloudprovider.ErrNotFound, err.Error())
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", err.Error())
}
}
for _, code := range []string{
@@ -236,11 +236,11 @@ func _jsonRequest(client *sdk.Client, domain string, version string, apiName str
if body.Contains("Code") {
code, _ := body.GetString("Code")
if len(code) > 0 && !utils.IsInStringArray(code, []string{"200"}) {
return nil, fmt.Errorf(body.String())
return nil, fmt.Errorf("%s", body.String())
}
}
if body.Contains("errorKey") {
return nil, errors.Errorf(body.String())
return nil, errors.Errorf("%s", body.String())
}
return body, nil
}
@@ -297,7 +297,7 @@ func (self *SApsaraClient) getDefaultClient(regionId string) (*sdk.Client, error
return respCheck, nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrAccountReadOnly, action)
return nil, errors.Wrapf(cloudprovider.ErrAccountReadOnly, "%s", action)
}
return respCheck, nil
}),
+1 -1
View File
@@ -288,7 +288,7 @@ func (self *SRegion) getDisk(diskId string) (*SDisk, error) {
return &disks[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, diskId)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", diskId)
}
func (self *SRegion) DeleteDisk(diskId string) error {
@@ -443,7 +443,7 @@ func (self *SElasticcache) GetAttribute() (*SElasticcacheAttribute, error) {
for i := range ret {
return &ret[i], nil
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, self.GetId())
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", self.GetId())
}
func (self *SElasticcache) GetNetInfo() ([]SNetInfo, error) {
@@ -568,7 +568,7 @@ func (self *SRegion) GetElasticCacheAccountByName(instanceId string, accountName
for i := range ret {
return &ret[i], nil
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, accountName)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", accountName)
}
// https://help.aliyun.com/document_detail/63889.html?spm=a2c4g.11186623.6.764.3cb43852R7lnoS
+2 -2
View File
@@ -158,7 +158,7 @@ func (self *SRegion) lbRequest(apiName string, params map[string]string) (jsonut
return self.productRequest(client, APSARA_PRODUCT_SLB, domain, APSARA_API_VERSION_LB, apiName, params, self.client.debug)
}
/////////////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////////////
func (self *SRegion) GetId() string {
return self.RegionId
}
@@ -1058,7 +1058,7 @@ func (self *SRegion) GetIBucketById(name string) (cloudprovider.ICloudBucket, er
return &buckets[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, name)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", name)
}
func (region *SRegion) GetIBucketByName(name string) (cloudprovider.ICloudBucket, error) {
+1 -1
View File
@@ -144,7 +144,7 @@ func (self *SRegion) GetSecurityGroup(id string) (*SSecurityGroup, error) {
return &groups[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SRegion) GetSecurityGroups(vpcId, name string, securityGroupIds []string, offset int, limit int) ([]SSecurityGroup, int, error) {
+2 -2
View File
@@ -222,7 +222,7 @@ func (client *SAwsClient) getAwsSession(regionId string, assumeRole bool) (*sess
return respCheck, nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrAccountReadOnly, action)
return nil, errors.Wrapf(cloudprovider.ErrAccountReadOnly, "%s", action)
}
// organization
if service == "organizations" {
@@ -301,7 +301,7 @@ func (client *SAwsClient) fetchBuckets() error {
output, err := s3cli.ListBuckets(&s3.ListBucketsInput{})
if err != nil {
if e, ok := err.(awserr.Error); ok && e.Code() == "AccessDenied" {
return errors.Wrapf(cloudprovider.ErrForbidden, e.Message())
return errors.Wrapf(cloudprovider.ErrForbidden, "%s", e.Message())
}
return errors.Wrap(err, "ListBuckets")
}
+2 -2
View File
@@ -228,7 +228,7 @@ func UnmarshalJsonError(r *request.Request) {
}
if r.HTTPResponse.StatusCode == 404 {
r.Error = errors.Wrapf(cloudprovider.ErrNotFound, string(result))
r.Error = errors.Wrapf(cloudprovider.ErrNotFound, "%s", string(result))
return
}
@@ -245,7 +245,7 @@ func UnmarshalJsonError(r *request.Request) {
respErr := &sAwsInvokeError{}
err = obj.Unmarshal(respErr)
if err != nil {
r.Error = errors.Wrapf(err, obj.String())
r.Error = errors.Wrapf(err, "%s", obj.String())
return
}
+1 -1
View File
@@ -226,7 +226,7 @@ func UnmarshalError(r *request.Request) {
}
if strings.Contains(respErr.Errors.Code, "NotFound") || strings.HasPrefix(respErr.Errors.Code, "NoSuch") {
r.Error = errors.Wrapf(cloudprovider.ErrNotFound, jsonutils.Marshal(respErr).String())
r.Error = errors.Wrapf(cloudprovider.ErrNotFound, "%s", jsonutils.Marshal(respErr).String())
return
}
+1 -1
View File
@@ -216,7 +216,7 @@ func (ac *SAwsClient) GetCDNDomainByName(name string) (*SCdnDomain, error) {
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, name)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", name)
}
func (ac *SAwsClient) GetCdnDomains() ([]SCdnDomain, error) {
+1 -1
View File
@@ -321,7 +321,7 @@ func (region *SRegion) GetDBInstance(instanceId string) (*SDBInstance, error) {
return &instances[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, instanceId)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", instanceId)
}
func (rds *SDBInstance) GetZone1Id() string {
+1 -1
View File
@@ -306,5 +306,5 @@ func (region *SRegion) GetDBInstanceCluster(id string) (*SDBInstanceCluster, err
return &clusters[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
@@ -66,5 +66,5 @@ func (region *SRegion) GetDBInstanceGlobalCluster(id string) (*SDBInstanceGlobal
return &clusters[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
+1 -1
View File
@@ -323,7 +323,7 @@ func (self *SRegion) GetDisk(diskId string) (*SDisk, error) {
return &disks[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, diskId)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", diskId)
}
func (self *SRegion) DeleteDisk(diskId string) error {
+2 -2
View File
@@ -231,7 +231,7 @@ func (self *SRegion) GetEip(id string) (*SEipAddress, error) {
return &eips[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SRegion) GetEipByIpAddress(eipAddress string) (*SEipAddress, error) {
@@ -245,7 +245,7 @@ func (self *SRegion) GetEipByIpAddress(eipAddress string) (*SEipAddress, error)
return &eips[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, eipAddress)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", eipAddress)
}
func (self *SRegion) AllocateEIP(opts *cloudprovider.SEip) (*SEipAddress, error) {
+2 -2
View File
@@ -178,7 +178,7 @@ func (self *SReplicationGroup) Refresh() error {
return jsonutils.Update(&self, caches[i])
}
}
return errors.Wrapf(cloudprovider.ErrNotFound, self.GetGlobalId())
return errors.Wrapf(cloudprovider.ErrNotFound, "%s", self.GetGlobalId())
}
func (self *SReplicationGroup) GetBillingType() string {
@@ -650,7 +650,7 @@ func (region *SRegion) GetIElasticcacheById(id string) (cloudprovider.ICloudElas
return &memcaches[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
type SubnetOutpost struct {
+1 -1
View File
@@ -110,7 +110,7 @@ func (self *SElasticache) Refresh() error {
return jsonutils.Update(&self, caches[i])
}
}
return errors.Wrapf(cloudprovider.ErrNotFound, self.GetGlobalId())
return errors.Wrapf(cloudprovider.ErrNotFound, "%s", self.GetGlobalId())
}
func (self *SElasticache) GetBillingType() string {
+2 -3
View File
@@ -110,7 +110,7 @@ func (self *SElasticacheSnapshop) Refresh() error {
return jsonutils.Update(self, snapshots[i])
}
}
return errors.Wrapf(cloudprovider.ErrNotFound, self.GetName())
return errors.Wrapf(cloudprovider.ErrNotFound, "%s", self.GetName())
}
func (self *SElasticacheSnapshop) GetBackupSizeMb() int {
@@ -151,7 +151,6 @@ func (self *SElasticacheSnapshop) GetBackupMode() string {
default:
return self.SnapshotSource
}
return ""
}
func (self *SElasticacheSnapshop) GetDownloadURL() string {
@@ -197,7 +196,7 @@ func (region *SRegion) GetCacheSnapshots(replicaGroupId string, snapshotName str
}
ret = append(ret, part.Snapshots...)
if len(part.Snapshots) == 0 || len(part.Marker) == 0 {
return nil, err
break
}
params["Marker"] = part.Marker
}
+1 -1
View File
@@ -79,7 +79,7 @@ func (self *SElasticacheUser) Refresh() error {
return jsonutils.Update(self, users[i])
}
}
return errors.Wrapf(cloudprovider.ErrNotFound, self.UserId)
return errors.Wrapf(cloudprovider.ErrNotFound, "%s", self.UserId)
}
func (self *SElasticacheUser) GetAccountType() string {
+1 -1
View File
@@ -80,7 +80,7 @@ func (self *SHost) GetIVMById(id string) (cloudprovider.ICloudVM, error) {
return &vms[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SHost) GetIStorages() ([]cloudprovider.ICloudStorage, error) {
+1 -1
View File
@@ -158,7 +158,7 @@ func (self *SRegion) GetImportImageTask(id string) (*ImageImportTask, error) {
return &tasks[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *ImageImportTask) IsEmulated() bool {
+2 -2
View File
@@ -750,7 +750,7 @@ func (self *SRegion) GetInstance(instanceId string) (*SInstance, error) {
return &instances[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, instanceId)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", instanceId)
}
func (self *SRegion) GetInstanceIdByImageId(imageId string) (string, error) {
@@ -1120,7 +1120,7 @@ func (self *SInstance) SetTags(tags map[string]string, replace bool) error {
func (self *SInstance) GetAccountId() string {
identity, err := self.host.zone.region.client.GetCallerIdentity()
if err != nil {
log.Errorf(err.Error() + "self.region.client.GetCallerIdentity()")
log.Errorf("GetCallerIdentity %v", err)
return ""
}
return identity.Account
+1 -1
View File
@@ -132,7 +132,7 @@ func (self *SRegion) lookUpAwsKeypair(publicKey string) (string, error) {
if len(keyparis) > 0 {
return keyparis[0].KeyName, nil
}
return "", errors.Wrapf(cloudprovider.ErrNotFound, publicKey)
return "", errors.Wrapf(cloudprovider.ErrNotFound, "%s", publicKey)
}
func (self *SRegion) importAwsKeypair(publicKey string) (string, error) {
+1 -1
View File
@@ -343,7 +343,7 @@ func (self *SRegion) GetElbBackendgroup(id string) (*SElbBackendGroup, error) {
return &groups[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func ToAwsHealthCode(s string) string {
@@ -233,7 +233,7 @@ func (self *SRegion) GetELbBackend(backendId string) (*SElbBackend, error) {
return &ret.TargetHealthDescriptions[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, backendId)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", backendId)
}
func parseElbBackendId(id string) (string, string, int, error) {
+2 -2
View File
@@ -563,7 +563,7 @@ func (self *SRegion) GetElbListener(listenerId string) (*SElbListener, error) {
return &ret[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, listenerId)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", listenerId)
}
func (self *SRegion) CreateElbListener(lbId string, opts *cloudprovider.SLoadbalancerListenerCreateOptions) (*SElbListener, error) {
@@ -635,7 +635,7 @@ func (self *SRegion) GetElbListenerRule(lisId, ruleId string) (*SElbListenerRule
return &rules[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, ruleId)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", ruleId)
}
func (self *SRegion) DeleteElbListener(id string) error {
+3 -3
View File
@@ -135,11 +135,11 @@ func (self *SNatGateway) GetINatSTable() ([]cloudprovider.ICloudNatSEntry, error
}
func (self *SNatGateway) GetINatDEntryById(id string) (cloudprovider.ICloudNatDEntry, error) {
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SNatGateway) GetINatSEntryById(id string) (cloudprovider.ICloudNatSEntry, error) {
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SNatGateway) CreateINatDEntry(rule cloudprovider.SNatDRule) (cloudprovider.ICloudNatDEntry, error) {
@@ -235,7 +235,7 @@ func (self *SRegion) GetNatGateway(id string) (*SNatGateway, error) {
return &nats[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SVpc) GetINatGateways() ([]cloudprovider.ICloudNatGateway, error) {
+1 -1
View File
@@ -271,7 +271,7 @@ func (self *SRegion) getNetwork(networkId string) (*SNetwork, error) {
return &networks[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, networkId)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", networkId)
}
func (self *SRegion) DeleteNetwork(id string) error {
+1 -1
View File
@@ -82,7 +82,7 @@ func (self *SRegion) GetNetworkInterface(id string) (*SNetworkInterface, error)
return &nets[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SRegion) GetNetworkInterfaces(id string) ([]SNetworkInterface, error) {
+1 -1
View File
@@ -380,7 +380,7 @@ func (self *SAwsProvider) GetICloudroleById(id string) (cloudprovider.ICloudrole
return roles[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SAwsProvider) GetICloudroleByName(name string) (cloudprovider.ICloudrole, error) {
+1 -1
View File
@@ -281,7 +281,7 @@ func (self *SRegion) GetRouteTable(id string) (*SRouteTable, error) {
return &tables[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SRegion) DeleteRouteTable(rid string) error {
+1 -1
View File
@@ -159,7 +159,7 @@ func (self *SRegion) CreateSecurityGroupRule(secGrpId string, opts *cloudprovide
err := self.ec2Request(action, params, &ret)
if err != nil {
return nil, errors.Wrapf(err, action)
return nil, errors.Wrapf(err, "%s", action)
}
for i := range ret.SecurityGroupRuleSet {
return &ret.SecurityGroupRuleSet[i], nil
+1 -1
View File
@@ -134,7 +134,7 @@ func (self *SRegion) GetInstanceType(name string) (*InstanceType, error) {
return &ret.InstanceTypeSet[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, name)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", name)
}
func (self *SRegion) GetInstanceTypes() ([]SInstanceType, error) {
+1 -1
View File
@@ -113,7 +113,7 @@ func (self *SRegion) GetSnapshot(id string) (*SSnapshot, error) {
return &snapshots[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SRegion) GetSnapshots(diskId string, name string, ids []string) ([]SSnapshot, error) {
+1 -1
View File
@@ -249,7 +249,7 @@ func (self *SRegion) DescribeExportTasks(id string) (*SExportTask, error) {
return &ret.ExportTaskSet[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SRegion) CheckBucket(bucketName string) error {
+3 -3
View File
@@ -213,7 +213,7 @@ func (self *SVpc) GetIWireById(wireId string) (cloudprovider.ICloudWire, error)
return wires[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, wireId)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", wireId)
}
func (self *SVpc) GetICloudVpcPeeringConnections() ([]cloudprovider.ICloudVpcPeeringConnection, error) {
@@ -268,7 +268,7 @@ func (self *SVpc) AcceptICloudVpcPeeringConnection(id string) error {
func (self *SVpc) GetAuthorityOwnerId() string {
identity, err := self.region.client.GetCallerIdentity()
if err != nil {
log.Errorf(err.Error() + "self.region.client.GetCallerIdentity()")
log.Errorf("GetCallerIdentity error: %v", err)
return ""
}
return identity.Account
@@ -393,7 +393,7 @@ func (self *SRegion) getVpc(vpcId string) (*SVpc, error) {
return &vpcs[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, vpcId)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", vpcId)
}
func (self *SRegion) assignSecurityGroups(secgroupIds []string, instanceId string) error {
+1 -1
View File
@@ -73,7 +73,7 @@ func (self *SRegion) GetVpcPeeringConnectionById(id string) (*SVpcPeeringConnect
return &peers[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SRegion) CreateVpcPeeringConnection(vpcId string, opts *cloudprovider.VpcPeeringConnectionCreateOptions) (*SVpcPeeringConnection, error) {
+1 -1
View File
@@ -147,7 +147,7 @@ func (self *SRegion) GetWebAcl(id, name, scope string) (*SWebAcl, error) {
resp, err := client.GetWebACL(&input)
if err != nil {
if _, ok := err.(*wafv2.WAFNonexistentItemException); ok {
return nil, errors.Wrapf(cloudprovider.ErrNotFound, err.Error())
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", err.Error())
}
return nil, errors.Wrapf(err, "GetWebAcl")
}
+1 -1
View File
@@ -143,7 +143,7 @@ func (self *SZone) getStorageByCategory(category string) (*SStorage, error) {
return storage, nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, category)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", category)
}
func (self *SZone) GetDescription() string {
+3 -3
View File
@@ -706,10 +706,10 @@ func (ae *AzureResponseError) ParseErrorFromJsonResponse(statusCode int, status
return errors.Wrap(cloudprovider.ErrNotFound, msg)
}
if ae.AzureError.Code == "AuthorizationFailed" {
return errors.Wrapf(cloudprovider.ErrForbidden, jsonutils.Marshal(ae).String())
return errors.Wrapf(cloudprovider.ErrForbidden, "%s", jsonutils.Marshal(ae).String())
}
if ae.AzureError.Code == "ResourceCollectionRequestsThrottled" {
return errors.Wrapf(cloudprovider.ErrTooManyRequests, jsonutils.Marshal(ae).String())
return errors.Wrapf(cloudprovider.ErrTooManyRequests, "%s", jsonutils.Marshal(ae).String())
}
if len(ae.OdataError.Code) > 0 || len(ae.AzureError.Code) > 0 || (len(ae.Code) > 0 && len(ae.Message) > 0) {
return ae
@@ -725,7 +725,7 @@ func _jsonRequest(client *autorest.Client, method, domain, path string, body jso
header, body, err := cli.Send(context.TODO(), req, &ae, debug)
if err != nil {
if strings.Contains(err.Error(), "azure.BearerAuthorizer#WithAuthorization") {
return nil, errors.Wrapf(cloudprovider.ErrInvalidAccessKey, err.Error())
return nil, errors.Wrapf(cloudprovider.ErrInvalidAccessKey, "%s", err.Error())
}
return nil, err
}
+1 -1
View File
@@ -108,7 +108,7 @@ func (self *SAzureClient) auth(resource string) (string, error) {
return "", errors.Wrapf(err, "parse body %s", string(body))
}
if obj.Contains("error") {
return "", errors.Errorf(string(body))
return "", errors.Errorf("%s", string(body))
}
token := &Token{}
err = obj.Unmarshal(token)
+2 -2
View File
@@ -273,7 +273,7 @@ func (self *SLoadbalancer) GetILoadBalancerListenerById(id string) (cloudprovide
return lblis[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SLoadbalancer) GetILoadBalancerCertificates() ([]cloudprovider.ICloudLoadbalancerCertificate, error) {
@@ -323,7 +323,7 @@ func (self *SLoadbalancer) GetILoadBalancerBackendGroupById(groupId string) (clo
return lbbgs[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, groupId)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", groupId)
}
func (self *SRegion) GetLoadbalancers() ([]SLoadbalancer, error) {
@@ -133,7 +133,7 @@ func (self *SLoadbalancerBackendGroup) GetILoadbalancerBackendById(backendId str
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, backendId)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", backendId)
}
func (self *SLoadbalancerBackendGroup) GetProtocolType() string {
+1 -1
View File
@@ -352,7 +352,7 @@ func (self *SAzureClient) GetRdsMetrics(opts *cloudprovider.MetricListOptions) (
metricnamespace = fmt.Sprintf("Microsoft.DBforPostgreSQL/%s", rdsType)
metricnames = "cpu_percent,memory_percent,storage_percent,network_bytes_ingress,network_bytes_egress,io_consumption_percent,connections_failed,active_connections"
default:
return nil, errors.Wrapf(cloudprovider.ErrNotSupported, opts.Engine)
return nil, errors.Wrapf(cloudprovider.ErrNotSupported, "%s", opts.Engine)
}
return self.getMetricValues(opts.ResourceId, metricnamespace, metricnames, nil, "", opts.StartTime, opts.EndTime)
}
+1 -1
View File
@@ -397,6 +397,6 @@ func (self *SRegion) GetIElasticcacheById(id string) (cloudprovider.ICloudElasti
} else if strings.Index(id, "Microsoft.Cache/redisEnterprise") > 0 {
return self.GetEnterpriseRedisCache(id)
} else {
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
}
+1 -1
View File
@@ -93,7 +93,7 @@ func (self *SRegion) getVMSize(name string) (*SVMSize, error) {
return &vmSizes[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, name)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", name)
}
func (self *SRegion) GetId() string {
+1 -1
View File
@@ -105,7 +105,7 @@ func (self *SVpc) GetIRouteTableById(routeTableId string) (cloudprovider.ICloudR
func (self *SVpc) GetIWireById(wireId string) (cloudprovider.ICloudWire, error) {
wire := self.getWire()
if wire.GetGlobalId() != wireId {
return nil, errors.Wrapf(cloudprovider.ErrNotFound, wireId)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", wireId)
}
return wire, nil
}
+1 -1
View File
@@ -629,7 +629,7 @@ func (self *SRegion) GetICloudWafInstanceById(id string) (cloudprovider.ICloudWa
if strings.Contains(id, "microsoft.network/applicationgatewaywebapplicationfirewallpolicies") {
return self.GetAppGatewayWaf(id)
}
return nil, errors.Wrapf(cloudprovider.ErrNotSupported, id)
return nil, errors.Wrapf(cloudprovider.ErrNotSupported, "%s", id)
}
func (self *SRegion) CreateAppWafInstance(name string, action *cloudprovider.DefaultAction) (*SAppGatewayWaf, error) {
+1 -1
View File
@@ -98,7 +98,7 @@ func (self *SWire) GetINetworkById(netid string) (cloudprovider.ICloudNetwork, e
return networks[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, netid)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", netid)
}
func (self *SWire) GetINetworks() ([]cloudprovider.ICloudNetwork, error) {
+2 -2
View File
@@ -100,7 +100,7 @@ func (self *SZone) GetIStorageById(id string) (cloudprovider.ICloudStorage, erro
return storages[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SZone) GetIHostById(id string) (cloudprovider.ICloudHost, error) {
@@ -113,7 +113,7 @@ func (self *SZone) GetIHostById(id string) (cloudprovider.ICloudHost, error) {
return hosts[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SZone) GetIHosts() ([]cloudprovider.ICloudHost, error) {
+3 -3
View File
@@ -120,7 +120,7 @@ func (cli *SBaiduClient) GetRegion(id string) (*SRegion, error) {
return &regions[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (cli *SBaiduClient) getUrl(service, regionId, resource string) (string, error) {
@@ -143,7 +143,7 @@ func (cli *SBaiduClient) getUrl(service, regionId, resource string) (string, err
case SERVICE_BCM:
return fmt.Sprintf("http://bcm.%s.baidubce.com/%s", regionId, strings.TrimPrefix(resource, "/")), nil
default:
return "", errors.Wrapf(cloudprovider.ErrNotSupported, service)
return "", errors.Wrapf(cloudprovider.ErrNotSupported, "%s", service)
}
}
@@ -190,7 +190,7 @@ func (e *sBaiduError) ParseErrorFromJsonResponse(statusCode int, status string,
e.StatusCode = statusCode
log.Infof("%s %s body: %s error: %v", e.method, e.url, e.body, e.Error())
if e.StatusCode == 404 {
return errors.Wrapf(cloudprovider.ErrNotFound, e.Error())
return errors.Wrapf(cloudprovider.ErrNotFound, "%s", e.Error())
}
return e
}
+1 -1
View File
@@ -309,7 +309,7 @@ func (region *SRegion) CreateDisk(storageType, zoneName string, opts *cloudprovi
for _, id := range ret.VolumeIds {
return region.GetDisk(id)
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, resp.String())
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", resp.String())
}
func (region *SRegion) ResizeDisk(diskId string, sizeGb int64) error {
+1 -1
View File
@@ -203,7 +203,7 @@ func (region *SRegion) GetIZoneById(id string) (cloudprovider.ICloudZone, error)
return zones[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (region *SRegion) getStoragecache() *SStoragecache {
+1 -1
View File
@@ -103,7 +103,7 @@ func (zone *SZone) GetIStorageById(id string) (cloudprovider.ICloudStorage, erro
return storages[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (zone *SZone) getHost() *SHost {
+2 -2
View File
@@ -214,7 +214,7 @@ func (self *SBingoCloudClient) invoke(action string, params map[string]string) (
if self.cpcfg.ReadOnly {
for _, prefix := range []string{"Get", "List", "Describe"} {
if strings.HasPrefix(action, prefix) {
return nil, errors.Wrapf(cloudprovider.ErrAccountReadOnly, action)
return nil, errors.Wrapf(cloudprovider.ErrAccountReadOnly, "%s", action)
}
}
}
@@ -379,7 +379,7 @@ func (self *SBingoCloudClient) GetIRegionById(id string) (cloudprovider.ICloudRe
return iregions[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SBingoCloudClient) GetCapabilities() []string {
+1 -1
View File
@@ -92,7 +92,7 @@ func (self *SRegion) GetIZoneById(id string) (cloudprovider.ICloudZone, error) {
return zones[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SRegion) GetClusters() ([]SCluster, error) {
+1 -1
View File
@@ -267,7 +267,7 @@ func (self *SRegion) GetDisk(id string) (*SDisk, error) {
return &disks[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SStorage) CreateIDisk(conf *cloudprovider.DiskCreateConfig) (cloudprovider.ICloudDisk, error) {
+1 -1
View File
@@ -180,5 +180,5 @@ func (self *SRegion) GetIEipById(id string) (cloudprovider.ICloudEIP, error) {
return &eips[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
+2 -2
View File
@@ -215,7 +215,7 @@ func (self *SRegion) GetImageById(id string) (*SImage, error) {
return nil, err
}
if len(imgs) == 0 {
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
return &imgs[0], nil
}
@@ -255,5 +255,5 @@ func (self *SStoragecache) GetIImageById(id string) (cloudprovider.ICloudImage,
return &images[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
+1 -1
View File
@@ -171,7 +171,7 @@ func (self *SWire) GetINetworkById(id string) (cloudprovider.ICloudNetwork, erro
return networks[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SRegion) GetNetworks(id, clusterId, vpcId string) ([]SNetwork, error) {
+1 -1
View File
@@ -268,7 +268,7 @@ func (self *SCluster) GetIHostById(id string) (cloudprovider.ICloudHost, error)
return &nodes[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SCluster) GetIHosts() ([]cloudprovider.ICloudHost, error) {
+3 -3
View File
@@ -119,7 +119,7 @@ func (self *SRegion) GetIStorageById(id string) (cloudprovider.ICloudStorage, er
return &storages[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SRegion) GetIStoragecaches() ([]cloudprovider.ICloudStoragecache, error) {
@@ -158,7 +158,7 @@ func (self *SRegion) GetIStoragecacheById(id string) (cloudprovider.ICloudStorag
return caches[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SRegion) GetIHosts() ([]cloudprovider.ICloudHost, error) {
@@ -193,7 +193,7 @@ func (self *SRegion) GetIHostById(id string) (cloudprovider.ICloudHost, error) {
}
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SRegion) GetISnapshots() ([]cloudprovider.ICloudSnapshot, error) {
+1 -1
View File
@@ -188,7 +188,7 @@ func (self *SRegion) GetISecurityGroupById(id string) (cloudprovider.ICloudSecur
return &groups[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SRegion) deleteSecurityGroup(id string) error {
+1 -1
View File
@@ -137,7 +137,7 @@ func (self *SCluster) GetIStorageById(id string) (cloudprovider.ICloudStorage, e
return storages[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SCluster) GetIStorages() ([]cloudprovider.ICloudStorage, error) {
+1 -1
View File
@@ -74,7 +74,7 @@ func (self *SVpc) GetIWireById(id string) (cloudprovider.ICloudWire, error) {
return wires[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SVpc) GetIWires() ([]cloudprovider.ICloudWire, error) {
+2 -2
View File
@@ -106,7 +106,7 @@ func (dir *SCephFsDir) Refresh() error {
return jsonutils.Update(dir, &dirs[i])
}
}
return errors.Wrapf(cloudprovider.ErrNotFound, dir.Path)
return errors.Wrapf(cloudprovider.ErrNotFound, "%s", dir.Path)
}
func (dir *SCephFsDir) SetQuota(input *cloudprovider.SFileSystemSetQuotaInput) error {
@@ -167,7 +167,7 @@ func (cli *SCephFSClient) GetICloudFileSystemById(id string) (cloudprovider.IClo
return &dirs[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (cli *SCephFSClient) CreateDir(fsId, path string) error {
+4 -4
View File
@@ -136,7 +136,7 @@ func (self *sCtyunError) ParseErrorFromJsonResponse(statusCode int, status strin
body.Unmarshal(self)
}
if strings.Contains(self.Message, "signature verification failed") {
return errors.Wrapf(cloudprovider.ErrInvalidAccessKey, jsonutils.Marshal(self).String())
return errors.Wrapf(cloudprovider.ErrInvalidAccessKey, "%s", jsonutils.Marshal(self).String())
}
return self
}
@@ -314,10 +314,10 @@ func (self *SCtyunClient) request(method httputils.THttpMethod, service, resourc
return resp, nil
}
if strings.HasSuffix(ret.ErrorCode, "NotFound") || ret.ErrorCode == "ebs.ebsInfo.get volume resourceId failed" {
return nil, errors.Wrapf(cloudprovider.ErrNotFound, resp.String())
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", resp.String())
}
log.Errorf("request %s with params %s error: %s", uri, jsonutils.Marshal(body).String(), resp.String())
return nil, fmt.Errorf(resp.String())
return nil, fmt.Errorf("%s", resp.String())
}
func (self *SCtyunClient) GetIRegions() ([]cloudprovider.ICloudRegion, error) {
@@ -370,7 +370,7 @@ func (self *SCtyunClient) GetRegion(id string) (*SRegion, error) {
return &self.regions[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SCtyunClient) GetCloudRegionExternalIdPrefix() string {
+1 -1
View File
@@ -75,7 +75,7 @@ func (self *SHost) GetIVMById(id string) (cloudprovider.ICloudVM, error) {
return &vms[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SHost) GetIStorages() ([]cloudprovider.ICloudStorage, error) {
+1 -1
View File
@@ -262,5 +262,5 @@ func (self *SRegion) GetImage(imageId string) (*SImage, error) {
return &ret[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, imageId)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", imageId)
}
+1 -1
View File
@@ -212,7 +212,7 @@ func (self *SInstance) GetIEIP() (cloudprovider.ICloudEIP, error) {
return &eips[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, self.FloatingIP)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", self.FloatingIP)
}
func (self *SInstance) GetVcpuCount() int {
+2 -2
View File
@@ -218,7 +218,7 @@ func (self *SRegion) GetIVpcById(id string) (cloudprovider.ICloudVpc, error) {
return ivpcs[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SRegion) GetIZoneById(id string) (cloudprovider.ICloudZone, error) {
@@ -375,7 +375,7 @@ func (self *SRegion) GetInstance(id string) (*SInstance, error) {
return &vms[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SRegion) GetInstances(zoneId string, ids []string) ([]SInstance, error) {
+1 -1
View File
@@ -112,7 +112,7 @@ func (self *SVpc) GetIWireById(id string) (cloudprovider.ICloudWire, error) {
return wires[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SRegion) GetVpc(vpcId string) (*SVpc, error) {
+1 -1
View File
@@ -315,7 +315,7 @@ func (self *SChinaUnionClient) request(method httputils.THttpMethod, resource st
}
code, _ := resp.GetString("code")
if code != "200" {
return nil, errors.Errorf(resp.String())
return nil, errors.Errorf("%s", resp.String())
}
return resp, nil
}
+2 -2
View File
@@ -176,7 +176,7 @@ func (self *SRegion) GetIZoneById(id string) (cloudprovider.ICloudZone, error) {
return zones[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (region *SRegion) GetIHostById(id string) (cloudprovider.ICloudHost, error) {
@@ -195,7 +195,7 @@ func (region *SRegion) GetIHostById(id string) (cloudprovider.ICloudHost, error)
}
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (region *SRegion) GetIHosts() ([]cloudprovider.ICloudHost, error) {
+1 -1
View File
@@ -254,7 +254,7 @@ func (br *SBaseRequest) ForMateResponseBody(jrbody jsonutils.JSONObject) (jsonut
if jrbody.Contains("errorMessage") {
msg, _ := jrbody.GetString("errorMessage")
if strings.Contains(msg, "Invalid parameter AccessKey") {
return nil, errors.Wrapf(cloudprovider.ErrInvalidAccessKey, msg)
return nil, errors.Wrapf(cloudprovider.ErrInvalidAccessKey, "%s", msg)
}
return nil, &httputils.JSONClientError{Code: 400, Details: msg}
}
+1 -1
View File
@@ -1600,7 +1600,7 @@ func (host *SHost) newLocalStorageCache() (*SDatastoreImageCache, error) {
}
if cacheDs == nil {
return nil, fmt.Errorf(errmsg)
return nil, fmt.Errorf("%s", errmsg)
}
return &SDatastoreImageCache{
+1 -1
View File
@@ -290,7 +290,7 @@ func (self *SDatastoreImageCache) GetIImageInTemplateVMsById(id string) (cloudpr
return NewVMTemplate(vm, self), nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "%s", id)
}
func (self *SDatastoreImageCache) GetICustomizedCloudImages() ([]cloudprovider.ICloudImage, error) {
+23 -20
View File
@@ -1201,28 +1201,31 @@ func (svm *SVirtualMachine) getDatastoreAndRootImagePath() (string, *SDatastore,
if layoutEx == nil || len(layoutEx.File) == 0 {
return "", nil, fmt.Errorf("invalid LayoutEx")
}
file := layoutEx.File[0].Name
// find stroage
host := svm.GetIHost()
storages, err := host.GetIStorages()
if err != nil {
return "", nil, errors.Wrap(err, "host.GetIStorages")
}
var datastore *SDatastore
for i := range storages {
ds := storages[i].(*SDatastore)
if ds.HasFile(file) {
datastore = ds
break
for _, f := range layoutEx.File {
if !strings.HasSuffix(f.Name, ".vmdk") {
continue
}
file := f.Name
// find stroage
host := svm.GetIHost()
storages, err := host.GetIStorages()
if err != nil {
return "", nil, errors.Wrap(err, "host.GetIStorages")
}
var datastore *SDatastore
for i := range storages {
ds := storages[i].(*SDatastore)
if ds.HasFile(file) {
datastore = ds
break
}
}
if datastore == nil {
return "", nil, fmt.Errorf("can't find storage associated with vm %q", svm.GetName())
}
return datastore.getPathString(datastore.cleanPath(file)), datastore, nil
}
if datastore == nil {
return "", nil, fmt.Errorf("can't find storage associated with vm %q", svm.GetName())
}
path := datastore.cleanPath(file)
vmDir := strings.Split(path, "/")[0]
// TODO find a non-conflicting path
return datastore.getPathString(fmt.Sprintf("%s/%s.vmdk", vmDir, vmDir)), datastore, nil
return "", nil, fmt.Errorf("can't find root image path")
}
func (svm *SVirtualMachine) GetRootImagePath() (string, error) {

Some files were not shown because too many files have changed in this diff Show More