diff --git a/go.mod b/go.mod index 2d7bf6ca465..ff91debdcc5 100644 --- a/go.mod +++ b/go.mod @@ -93,12 +93,12 @@ 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.20241225022314-afb2521c4810 + yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20241231161311-2b925c2c0096 yunion.io/x/executor v0.0.0-20241205080005-48f5b1212256 yunion.io/x/jsonutils v1.0.1-0.20240930100528-1671a2d0d22f yunion.io/x/log v1.0.1-0.20240305175729-7cf2d6cd5a91 yunion.io/x/ovsdb v0.0.0-20230306173834-f164f413a900 - yunion.io/x/pkg v1.10.2 + yunion.io/x/pkg v1.10.3 yunion.io/x/s3cli v0.0.0-20241221171442-1c11599d28e1 yunion.io/x/sqlchemy v1.1.3-0.20240926163039-d41512b264e1 yunion.io/x/structarg v0.0.0-20231017124457-df4d5009457c diff --git a/go.sum b/go.sum index 0e5cb4d30c4..d96c585eedd 100644 --- a/go.sum +++ b/go.sum @@ -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.20241225022314-afb2521c4810 h1:Y5Q+aOgh6a/0fEi7JUI9QVcJ3qDhjjv+0MxZNbDhllk= -yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20241225022314-afb2521c4810/go.mod h1:KQ/jWx7bZlmjCE711KEWuvHW/dzpdr/UTlBjjutkj0Y= +yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20241231161311-2b925c2c0096 h1:gJIprJl5tg3An9eixiSVHw2H3rtP/7Pft0mN+dtUa00= +yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20241231161311-2b925c2c0096/go.mod h1:KQ/jWx7bZlmjCE711KEWuvHW/dzpdr/UTlBjjutkj0Y= yunion.io/x/executor v0.0.0-20241205080005-48f5b1212256 h1:kLKQ6zbgPDQflRwoHFAjxNChcbhXIFgsUVLkJwiXu/8= yunion.io/x/executor v0.0.0-20241205080005-48f5b1212256/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws= yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634= @@ -1391,8 +1391,8 @@ yunion.io/x/ovsdb v0.0.0-20230306173834-f164f413a900 h1:Hu/4ERvoWaN6aiFs4h4/yvVB yunion.io/x/ovsdb v0.0.0-20230306173834-f164f413a900/go.mod h1:0vLkNEhlmA64HViPBAnSTUMrx5QP1CLsxXmxDKQ80tc= yunion.io/x/pkg v0.0.0-20190620104149-945c25821dbf/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E= yunion.io/x/pkg v0.0.0-20190628082551-f4033ba2ea30/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E= -yunion.io/x/pkg v1.10.2 h1:oZhedvlvDsebIWcOvrOMJQ31SxzjxxqUXUBYseBjh7w= -yunion.io/x/pkg v1.10.2/go.mod h1:0Bwxqd9MA3ACi119/l02FprY/o9gHahmYC2bsSbnVpM= +yunion.io/x/pkg v1.10.3 h1:oaJAtMSIwASgF6jB/0W37iOQBLh6ICswfPL3ISnRZC4= +yunion.io/x/pkg v1.10.3/go.mod h1:0Bwxqd9MA3ACi119/l02FprY/o9gHahmYC2bsSbnVpM= yunion.io/x/s3cli v0.0.0-20241221171442-1c11599d28e1 h1:1KJ3YYinydPHpDEQRXdr/T8SYcKZ5Er+m489H+PnaQ4= yunion.io/x/s3cli v0.0.0-20241221171442-1c11599d28e1/go.mod h1:0iFKpOs1y4lbCxeOmq3Xx/0AcQoewVPwj62eRluioEo= yunion.io/x/sqlchemy v1.1.3-0.20240926163039-d41512b264e1 h1:HWPqY1I5JSmM6Sks6FyK9hnq/MjL7FDghM6M8DXHob0= diff --git a/pkg/apis/compute/backup.go b/pkg/apis/compute/backup.go index 4e6f5991c36..2098802a0b6 100644 --- a/pkg/apis/compute/backup.go +++ b/pkg/apis/compute/backup.go @@ -199,6 +199,8 @@ type SBackupStorageAccessInfo struct { ObjectAccessKey string `json:"object_access_key"` // description: secret of object storage ObjectSecret string `json:"object_secret"` + // description: signing version, can be v2/v4, default is v4 + ObjectSignVer string `json:"object_sign_ver"` } func (ba *SBackupStorageAccessInfo) String() string { diff --git a/pkg/compute/models/backup_storage.go b/pkg/compute/models/backup_storage.go index 9cc0c938646..f0506a0c878 100644 --- a/pkg/compute/models/backup_storage.go +++ b/pkg/compute/models/backup_storage.go @@ -171,6 +171,7 @@ func (bs *SBackupStorage) getMoreDetails(ctx context.Context, out api.BackupStor out.NfsSharedDir = bs.AccessInfo.NfsSharedDir out.ObjectBucketUrl = bs.AccessInfo.ObjectBucketUrl out.ObjectAccessKey = bs.AccessInfo.ObjectAccessKey + out.ObjectSignVer = bs.AccessInfo.ObjectSignVer // should not return secret out.ObjectSecret = "" // bs.AccessInfo.ObjectSecret return out @@ -318,6 +319,10 @@ func (bs *SBackupStorage) PostUpdate(ctx context.Context, userCred mcclient.Toke accessInfo.ObjectSecret = sec accessInfoChanged = true } + if input.ObjectSignVer != accessInfo.ObjectSignVer { + accessInfo.ObjectSignVer = input.ObjectSignVer + accessInfoChanged = true + } } if accessInfoChanged { _, err = db.Update(bs, func() error { diff --git a/pkg/compute/models/cloudaccounts.go b/pkg/compute/models/cloudaccounts.go index c1c8ecafc33..add46deb9e4 100644 --- a/pkg/compute/models/cloudaccounts.go +++ b/pkg/compute/models/cloudaccounts.go @@ -252,7 +252,7 @@ func (acnt *SCloudaccount) enableAccountOnly(ctx context.Context, userCred mccli } func (acnt *SCloudaccount) PerformEnable(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input apis.PerformEnableInput) (jsonutils.JSONObject, error) { - if strings.Index(acnt.Status, "delet") >= 0 { + if strings.Contains(acnt.Status, "delet") { return nil, httperrors.NewInvalidStatusError("Cannot enable deleting account") } _, err := acnt.enableAccountOnly(ctx, userCred, query, input) @@ -759,7 +759,12 @@ func (acnt *SCloudaccount) PerformTestConnectivity(ctx context.Context, userCred return nil, nil } -func (acnt *SCloudaccount) PerformUpdateCredential(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) { +func (acnt *SCloudaccount) PerformUpdateCredential( + ctx context.Context, + userCred mcclient.TokenCredential, + query jsonutils.JSONObject, + input cloudprovider.SCloudaccountCredential, +) (jsonutils.JSONObject, error) { if !acnt.GetEnabled() { return nil, httperrors.NewInvalidStatusError("Account disabled") } @@ -769,12 +774,6 @@ func (acnt *SCloudaccount) PerformUpdateCredential(ctx context.Context, userCred return nil, httperrors.NewBadRequestError("failed to found provider factory error: %v", err) } - input := cloudprovider.SCloudaccountCredential{} - err = data.Unmarshal(&input) - if err != nil { - return nil, httperrors.NewInputParameterError("failed to unmarshal input params: %v", err) - } - account, err := providerDriver.ValidateUpdateCloudaccountCredential(ctx, input, acnt.Account) if err != nil { return nil, err diff --git a/pkg/hostman/storageman/backupstorage/object/factory.go b/pkg/hostman/storageman/backupstorage/object/factory.go index 5c2c4b8f804..0eb0567ceb4 100644 --- a/pkg/hostman/storageman/backupstorage/object/factory.go +++ b/pkg/hostman/storageman/backupstorage/object/factory.go @@ -15,6 +15,7 @@ package object import ( + "yunion.io/x/cloudmux/pkg/multicloud/objectstore" "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" @@ -40,7 +41,7 @@ func (factory *sObjectBackupStorageFactory) NewBackupStore(backupStroageId strin if len(accessInfo.ObjectSecret) == 0 { return nil, errors.Wrap(httperrors.ErrInputParameter, "need object_secret in backup_storage_access_info") } - return newObjectBackupStorage(backupStroageId, accessInfo.ObjectBucketUrl, accessInfo.ObjectAccessKey, accessInfo.ObjectSecret) + return newObjectBackupStorage(backupStroageId, accessInfo.ObjectBucketUrl, accessInfo.ObjectAccessKey, accessInfo.ObjectSecret, objectstore.S3SignVersion(accessInfo.ObjectSignVer)) } func init() { diff --git a/pkg/hostman/storageman/backupstorage/object/object.go b/pkg/hostman/storageman/backupstorage/object/object.go index ef8fc22869e..2fc9413e29c 100644 --- a/pkg/hostman/storageman/backupstorage/object/object.go +++ b/pkg/hostman/storageman/backupstorage/object/object.go @@ -30,31 +30,29 @@ import ( type SObjectBackupStorage struct { BackupStorageId string - endpoint string - bucket string - accessKey string - secret string + bucket string store *objectstore.SObjectStoreClient } -func newObjectBackupStorage(backupStorageId, bucketUrl, accessKey, secret string) (*SObjectBackupStorage, error) { +func newObjectBackupStorage(backupStorageId, bucketUrl, accessKey, secret string, signVer objectstore.S3SignVersion) (*SObjectBackupStorage, error) { bucket, endpoint, err := parseBucketUrl(bucketUrl) if err != nil { return nil, errors.Wrapf(err, "parseBucketUrl %s", bucketUrl) } cfg := objectstore.NewObjectStoreClientConfig(endpoint, accessKey, secret) + if len(signVer) > 0 { + cfg = cfg.SignVersion(signVer) + } store, err := objectstore.NewObjectStoreClient(cfg) if err != nil { return nil, errors.Wrap(err, "NewObjectStoreClient") } + return &SObjectBackupStorage{ BackupStorageId: backupStorageId, - endpoint: endpoint, - bucket: bucket, - accessKey: accessKey, - secret: secret, + bucket: bucket, store: store, }, nil diff --git a/pkg/mcclient/options/compute/backup.go b/pkg/mcclient/options/compute/backup.go index 312874304e4..76bf609677d 100644 --- a/pkg/mcclient/options/compute/backup.go +++ b/pkg/mcclient/options/compute/backup.go @@ -145,6 +145,7 @@ type BackupStorageCreateOptions struct { ObjectBucketUrl string `help:"object bucket url, required when storage_type is object"` ObjectAccessKey string `help:"object storage access key, required when storage_type is object"` ObjectSecret string `help:"object storage secret, required when storage_type is object"` + ObjectSignVer string `help:"object storage signing alogirithm version, optional" choices:"v2|v4"` CapacityMb int `help:"capacity, unit mb"` } @@ -162,6 +163,7 @@ type BackupStorageUpdateOptions struct { ObjectBucketUrl string `help:"object bucket url, required when storage_type is object"` ObjectAccessKey string `help:"object storage access key, required when storage_type is object"` ObjectSecret string `help:"object storage secret, required when storage_type is object"` + ObjectSignVer string `help:"object storage signing alogirithm version, optional" choices:"v2|v4"` } func (opts *BackupStorageUpdateOptions) Params() (jsonutils.JSONObject, error) { diff --git a/pkg/mcclient/options/compute/cloudaccounts.go b/pkg/mcclient/options/compute/cloudaccounts.go index 08805a0d8ba..833dea05955 100644 --- a/pkg/mcclient/options/compute/cloudaccounts.go +++ b/pkg/mcclient/options/compute/cloudaccounts.go @@ -405,11 +405,17 @@ type SS3CloudAccountCreateOptions struct { SCloudAccountCreateBaseOptions SAccessKeyCredential Endpoint string `help:"S3 endpoint" required:"true" positional:"true" json:"endpoint"` + + OptionSignVer string `help:"signing algorithm version" choices:"v2|v4"` } func (opts *SS3CloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) { params := jsonutils.Marshal(opts) params.(*jsonutils.JSONDict).Add(jsonutils.NewString("S3"), "provider") + options := jsonutils.NewDict() + if len(opts.OptionSignVer) > 0 { + options.Add(jsonutils.NewString(opts.OptionSignVer), "sign_ver") + } return params, nil } diff --git a/vendor/modules.txt b/vendor/modules.txt index d8c743f8c5c..751892edd72 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -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.20241225022314-afb2521c4810 +# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20241231161311-2b925c2c0096 ## explicit; go 1.21 yunion.io/x/cloudmux/pkg/apis yunion.io/x/cloudmux/pkg/apis/billing @@ -1882,7 +1882,7 @@ yunion.io/x/log/hooks yunion.io/x/ovsdb/cli_util yunion.io/x/ovsdb/schema/ovn_nb yunion.io/x/ovsdb/types -# yunion.io/x/pkg v1.10.2 +# yunion.io/x/pkg v1.10.3 ## explicit; go 1.18 yunion.io/x/pkg/appctx yunion.io/x/pkg/errors diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/objectstore.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/objectstore.go index dc14741ec58..f93475cc53f 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/objectstore.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/objectstore.go @@ -34,6 +34,14 @@ import ( "yunion.io/x/cloudmux/pkg/multicloud" ) +type S3SignVersion string + +const ( + S3SignAlgDefault = S3SignVersion("") + S3SignAlgV4 = S3SignVersion("v4") + S3SignAlgV2 = S3SignVersion("v2") +) + type ObjectStoreClientConfig struct { cpcfg cloudprovider.ProviderConfig @@ -41,6 +49,8 @@ type ObjectStoreClientConfig struct { accessKey string accessSecret string + signVer S3SignVersion + debug bool } @@ -58,6 +68,11 @@ func (cfg *ObjectStoreClientConfig) CloudproviderConfig(cpcfg cloudprovider.Prov return cfg } +func (cfg *ObjectStoreClientConfig) SignVersion(signVer S3SignVersion) *ObjectStoreClientConfig { + cfg.signVer = signVer + return cfg +} + func (cfg *ObjectStoreClientConfig) Debug(debug bool) *ObjectStoreClientConfig { cfg.debug = debug return cfg @@ -115,7 +130,20 @@ func NewObjectStoreClientAndFetch(cfg *ObjectStoreClientConfig, doFetch bool) (* if parts.Scheme == "https" { useSsl = true } - cli, err := s3cli.New( + s3cliNewFunc := s3cli.New + + switch cfg.signVer { + case S3SignAlgV4: + log.Debugf("Use v4 signing algorithm") + s3cliNewFunc = s3cli.NewV4 + case S3SignAlgV2: + log.Debugf("Use v2 signing algorithm") + s3cliNewFunc = s3cli.NewV2 + default: + log.Debugf("s3 sign algirithm version not set, use default") + } + + cli, err := s3cliNewFunc( parts.Host, client.accessKey, client.accessSecret, diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/provider/provider.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/provider/provider.go index 5ac24b302c5..dbe0755dcf2 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/provider/provider.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/provider/provider.go @@ -29,15 +29,15 @@ type SObjectStoreProviderFactory struct { cloudprovider.SPremiseBaseProviderFactory } -func (self *SObjectStoreProviderFactory) GetId() string { +func (factory *SObjectStoreProviderFactory) GetId() string { return api.CLOUD_PROVIDER_GENERICS3 } -func (self *SObjectStoreProviderFactory) GetName() string { +func (factory *SObjectStoreProviderFactory) GetName() string { return api.CLOUD_PROVIDER_GENERICS3 } -func (self *SObjectStoreProviderFactory) ValidateCreateCloudaccountData(ctx context.Context, input cloudprovider.SCloudaccountCredential) (cloudprovider.SCloudaccount, error) { +func (factory *SObjectStoreProviderFactory) ValidateCreateCloudaccountData(ctx context.Context, input cloudprovider.SCloudaccountCredential) (cloudprovider.SCloudaccount, error) { output := cloudprovider.SCloudaccount{} if len(input.AccessKeyId) == 0 { return output, errors.Wrap(cloudprovider.ErrMissingParameter, "access_key_id") @@ -54,7 +54,7 @@ func (self *SObjectStoreProviderFactory) ValidateCreateCloudaccountData(ctx cont return output, nil } -func (self *SObjectStoreProviderFactory) ValidateUpdateCloudaccountCredential(ctx context.Context, input cloudprovider.SCloudaccountCredential, cloudaccount string) (cloudprovider.SCloudaccount, error) { +func (factory *SObjectStoreProviderFactory) ValidateUpdateCloudaccountCredential(ctx context.Context, input cloudprovider.SCloudaccountCredential, cloudaccount string) (cloudprovider.SCloudaccount, error) { output := cloudprovider.SCloudaccount{} if len(input.AccessKeyId) == 0 { return output, errors.Wrap(cloudprovider.ErrMissingParameter, "access_key_id") @@ -69,25 +69,36 @@ func (self *SObjectStoreProviderFactory) ValidateUpdateCloudaccountCredential(ct return output, nil } -func (self *SObjectStoreProviderFactory) GetProvider(cfg cloudprovider.ProviderConfig) (cloudprovider.ICloudProvider, error) { - client, err := objectstore.NewObjectStoreClient( - objectstore.NewObjectStoreClientConfig( - cfg.URL, cfg.Account, cfg.Secret, - ).CloudproviderConfig(cfg), - ) +func (factory *SObjectStoreProviderFactory) GetProvider(cfg cloudprovider.ProviderConfig) (cloudprovider.ICloudProvider, error) { + storeCfg := objectstore.NewObjectStoreClientConfig( + cfg.URL, cfg.Account, cfg.Secret, + ).CloudproviderConfig(cfg) + var signVer string + if cfg.Options != nil { + signVer, _ = cfg.Options.GetString("sign_ver") + } + if len(signVer) > 0 { + storeCfg = storeCfg.SignVersion(objectstore.S3SignVersion(signVer)) + } + client, err := objectstore.NewObjectStoreClient(storeCfg) if err != nil { return nil, err } - return NewObjectStoreProvider(self, client, []string{ + return NewObjectStoreProvider(factory, client, []string{ string(cloudprovider.ACLPrivate), }), nil } -func (self *SObjectStoreProviderFactory) GetClientRC(info cloudprovider.SProviderInfo) (map[string]string, error) { +func (factory *SObjectStoreProviderFactory) GetClientRC(info cloudprovider.SProviderInfo) (map[string]string, error) { + var signVer string + if info.Options != nil { + signVer, _ = info.Options.GetString("sign_ver") + } return map[string]string{ "S3_ACCESS_KEY": info.Account, "S3_SECRET": info.Secret, "S3_ACCESS_URL": info.Url, + "S3_SIGN_VER": signVer, "S3_BACKEND": api.CLOUD_PROVIDER_GENERICS3, }, nil } @@ -111,15 +122,15 @@ func NewObjectStoreProvider(factory cloudprovider.ICloudProviderFactory, client } } -func (self *SObjectStoreProvider) GetIRegions() ([]cloudprovider.ICloudRegion, error) { +func (provider *SObjectStoreProvider) GetIRegions() ([]cloudprovider.ICloudRegion, error) { return nil, cloudprovider.ErrNotSupported } -func (self *SObjectStoreProvider) GetIRegionById(id string) (cloudprovider.ICloudRegion, error) { +func (provider *SObjectStoreProvider) GetIRegionById(id string) (cloudprovider.ICloudRegion, error) { return nil, cloudprovider.ErrNotSupported } -func (self *SObjectStoreProvider) GetBalance() (*cloudprovider.SBalanceInfo, error) { +func (provider *SObjectStoreProvider) GetBalance() (*cloudprovider.SBalanceInfo, error) { return &cloudprovider.SBalanceInfo{ Amount: 0.0, Currency: "CNY", @@ -127,42 +138,42 @@ func (self *SObjectStoreProvider) GetBalance() (*cloudprovider.SBalanceInfo, err }, cloudprovider.ErrNotSupported } -func (self *SObjectStoreProvider) GetOnPremiseIRegion() (cloudprovider.ICloudRegion, error) { - return self.client, nil +func (provider *SObjectStoreProvider) GetOnPremiseIRegion() (cloudprovider.ICloudRegion, error) { + return provider.client, nil } -func (self *SObjectStoreProvider) GetIProjects() ([]cloudprovider.ICloudProject, error) { +func (provider *SObjectStoreProvider) GetIProjects() ([]cloudprovider.ICloudProject, error) { return nil, cloudprovider.ErrNotSupported } -func (self *SObjectStoreProvider) GetSysInfo() (jsonutils.JSONObject, error) { - return self.client.About(), nil +func (provider *SObjectStoreProvider) GetSysInfo() (jsonutils.JSONObject, error) { + return provider.client.About(), nil } -func (self *SObjectStoreProvider) GetVersion() string { - return self.client.GetVersion() +func (provider *SObjectStoreProvider) GetVersion() string { + return provider.client.GetVersion() } -func (self *SObjectStoreProvider) GetSubAccounts() ([]cloudprovider.SSubAccount, error) { - return self.client.GetSubAccounts() +func (provider *SObjectStoreProvider) GetSubAccounts() ([]cloudprovider.SSubAccount, error) { + return provider.client.GetSubAccounts() } -func (self *SObjectStoreProvider) GetAccountId() string { - return self.client.GetAccountId() +func (provider *SObjectStoreProvider) GetAccountId() string { + return provider.client.GetAccountId() } -func (self *SObjectStoreProvider) GetStorageClasses(regionId string) []string { +func (provider *SObjectStoreProvider) GetStorageClasses(regionId string) []string { return []string{} } -func (self *SObjectStoreProvider) GetBucketCannedAcls(regionId string) []string { - return self.supportedAcls +func (provider *SObjectStoreProvider) GetBucketCannedAcls(regionId string) []string { + return provider.supportedAcls } -func (self *SObjectStoreProvider) GetObjectCannedAcls(regionId string) []string { - return self.supportedAcls +func (provider *SObjectStoreProvider) GetObjectCannedAcls(regionId string) []string { + return provider.supportedAcls } -func (self *SObjectStoreProvider) GetCapabilities() []string { - return self.client.GetCapabilities() +func (provider *SObjectStoreProvider) GetCapabilities() []string { + return provider.client.GetCapabilities() } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/volcengine/volcengine.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/volcengine/volcengine.go index 5d7a9868043..6a09a299361 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/volcengine/volcengine.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/volcengine/volcengine.go @@ -180,16 +180,11 @@ func (client *SVolcEngineClient) GetAccountId() string { if len(client.ownerId) > 0 { return client.ownerId } - - toscli, err := client.getTosClient(VOLCENGINE_DEFAULT_REGION) - if err != nil { - return "" - } - out, err := toscli.ListBuckets(context.Background(), &tos.ListBucketsInput{}) + balance, err := client.QueryBalance() if err != nil { return "" } - client.ownerId = out.Owner.ID + client.ownerId = balance.AccountId return client.ownerId } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/zstack/zstack.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/zstack/zstack.go index 76604933f2c..25a832ad4f6 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/zstack/zstack.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/zstack/zstack.go @@ -30,6 +30,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/gotypes" "yunion.io/x/pkg/util/httputils" api "yunion.io/x/cloudmux/pkg/apis/compute" @@ -186,6 +187,9 @@ func (cli *SZStackClient) connect() error { if err == nil { return nil } + if !strings.Contains(cli.authURL, "8080") { + return errors.Wrapf(err, "please set port to 8080, try again") + } return errors.Wrapf(err, "connect") } return fmt.Errorf("password auth has been deprecated, please using ak sk auth") @@ -199,6 +203,9 @@ func (cli *SZStackClient) listAll(resource string, params url.Values, retVal int if err != nil { return err } + if gotypes.IsNil(resp) { + return errors.Wrapf(errors.ErrEmpty, "empty response") + } objs, err := resp.GetArray("inventories") if err != nil { return err diff --git a/vendor/yunion.io/x/pkg/util/httputils/httputils.go b/vendor/yunion.io/x/pkg/util/httputils/httputils.go index 4ad4ad3d574..5e8bb64a258 100644 --- a/vendor/yunion.io/x/pkg/util/httputils/httputils.go +++ b/vendor/yunion.io/x/pkg/util/httputils/httputils.go @@ -234,6 +234,12 @@ func NewJsonClient(client sClient) *JsonClient { } func (e *JSONClientError) Error() string { + if !gotypes.IsNil(e.Request.Body) { + if body, ok := e.Request.Body.(*jsonutils.JSONDict); ok && body.Contains("password") { + body.Set("password", jsonutils.NewString("***")) + e.Request.Body = body + } + } errMsg := JSONClientErrorMsg{Error: e} return jsonutils.Marshal(errMsg).String() }