From 25b04f50be5cceff8a3ae6ad118dfd77825bfbfa Mon Sep 17 00:00:00 2001 From: TangBin Date: Wed, 27 Nov 2019 11:30:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8D=E6=94=AF=E6=8C=81re?= =?UTF-8?q?dis=E7=9A=84=E5=85=AC=E6=9C=89=E4=BA=91=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=E4=BC=9A=E9=A2=91=E7=B9=81=E8=AF=BB=E5=8F=96oss=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/compute/models/cloudsync.go | 16 +++++++++------- pkg/compute/models/regiondrivers.go | 1 + pkg/compute/regiondrivers/aliyun.go | 4 ++++ pkg/compute/regiondrivers/base.go | 4 ++++ pkg/compute/regiondrivers/huawei.go | 4 ++++ 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/pkg/compute/models/cloudsync.go b/pkg/compute/models/cloudsync.go index e265047e7b..02ea57c88e 100644 --- a/pkg/compute/models/cloudsync.go +++ b/pkg/compute/models/cloudsync.go @@ -127,14 +127,16 @@ func syncRegionSkus(ctx context.Context, userCred mcclient.TokenCredential, loca } } - cnt, err = ElasticcacheSkuManager.GetSkuCountByRegion(regionId) - if err != nil { - log.Errorf("ElasticcacheSkuManager.GetSkuCountByRegion fail %s", err) - return - } + if localRegion.GetDriver().IsSupportedElasticcache() { + cnt, err = ElasticcacheSkuManager.GetSkuCountByRegion(regionId) + if err != nil { + log.Errorf("ElasticcacheSkuManager.GetSkuCountByRegion fail %s", err) + return + } - if cnt == 0 { - syncElasticCacheSkusByRegion(ctx, userCred, localRegion) + if cnt == 0 { + syncElasticCacheSkusByRegion(ctx, userCred, localRegion) + } } } diff --git a/pkg/compute/models/regiondrivers.go b/pkg/compute/models/regiondrivers.go index 7388cfde20..eb0cc4c84b 100644 --- a/pkg/compute/models/regiondrivers.go +++ b/pkg/compute/models/regiondrivers.go @@ -142,6 +142,7 @@ type IRegionDriver interface { } type IElasticcacheDriver interface { + IsSupportedElasticcache() bool AllowCreateElasticcacheBackup(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, elasticcache *SElasticcache) error AllowUpdateElasticcacheAuthMode(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, elasticcache *SElasticcache) error ValidateCreateElasticcacheData(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) diff --git a/pkg/compute/regiondrivers/aliyun.go b/pkg/compute/regiondrivers/aliyun.go index 76373826b9..2462950756 100644 --- a/pkg/compute/regiondrivers/aliyun.go +++ b/pkg/compute/regiondrivers/aliyun.go @@ -1535,3 +1535,7 @@ func (self *SAliyunRegionDriver) RequestElasticcacheAccountResetPassword(ctx con return ea.SyncWithCloudElasticcacheAccount(ctx, userCred, iea) } + +func (self *SAliyunRegionDriver) IsSupportedElasticcache() bool { + return true +} diff --git a/pkg/compute/regiondrivers/base.go b/pkg/compute/regiondrivers/base.go index 48022676fc..fb8ce4dafd 100644 --- a/pkg/compute/regiondrivers/base.go +++ b/pkg/compute/regiondrivers/base.go @@ -294,3 +294,7 @@ func (self *SBaseRegionDriver) ValidateResetDBInstancePassword(ctx context.Conte func (self *SBaseRegionDriver) IsSupportKeepDBInstanceManualBackup() bool { return false } + +func (self *SBaseRegionDriver) IsSupportedElasticcache() bool { + return false +} diff --git a/pkg/compute/regiondrivers/huawei.go b/pkg/compute/regiondrivers/huawei.go index 49d06f7bb4..d7e1a5dde2 100644 --- a/pkg/compute/regiondrivers/huawei.go +++ b/pkg/compute/regiondrivers/huawei.go @@ -2562,3 +2562,7 @@ func (self *SHuaWeiRegionDriver) AllowCreateElasticcacheBackup(ctx context.Conte func (self *SHuaWeiRegionDriver) AllowUpdateElasticcacheAuthMode(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, elasticcache *models.SElasticcache) error { return fmt.Errorf("not support update huawei elastic cache auth_mode") } + +func (self *SHuaWeiRegionDriver) IsSupportedElasticcache() bool { + return true +}