mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-01 15:07:17 +08:00
Merge pull request #3557 from tb365/bugfix/tb-redis-bugfix-1108
redis sync fix
This commit is contained in:
@@ -61,7 +61,6 @@ func init() {
|
||||
* 发送全局通知
|
||||
*/
|
||||
type NotificationBroadcastOptions struct {
|
||||
|
||||
// CONTACTTYPE string `help:"User's contacts type, cloud be email|mobile|dingtalk|/webconsole" choices:"email|mobile|dingtalk|webconsole"`
|
||||
Topic string `required:"true" help:"Title or topic of the notification"`
|
||||
Priority string `help:"Priority of the notification" choices:"normal|important|fatal" default:"normal"`
|
||||
|
||||
@@ -24,6 +24,7 @@ const (
|
||||
ELASTIC_CACHE_STATUS_CHANGE_FAILED = "change_failed" //(修改失败)
|
||||
ELASTIC_CACHE_STATUS_INACTIVE = "inactive" //(被禁用)
|
||||
ELASTIC_CACHE_STATUS_FLUSHING = "flushing" //(清除中)
|
||||
ELASTIC_CACHE_STATUS_FLUSHING_FAILED = "flushing_failed" //(清除失败)
|
||||
ELASTIC_CACHE_STATUS_RELEASED = "released" //(已释放)
|
||||
ELASTIC_CACHE_STATUS_RELEASE_FAILED = "release_failed" //(释放失败)
|
||||
ELASTIC_CACHE_STATUS_TRANSFORMING = "transforming" //(转换中)
|
||||
@@ -94,3 +95,10 @@ const (
|
||||
ELASTIC_CACHE_PARAMETER_STATUS_UPDATING = "updating" // 更新中
|
||||
ELASTIC_CACHE_PARAMETER_STATUS_UPDATE_FAILED = "update_failed" // 更新失败
|
||||
)
|
||||
|
||||
const (
|
||||
ELASTIC_CACHE_ARCH_TYPE_SINGLE = "single" // 单副本
|
||||
ELASTIC_CACHE_ARCH_TYPE_MASTER = "master" // 主备
|
||||
ELASTIC_CACHE_ARCH_TYPE_CLUSTER = "cluster" // 集群
|
||||
ELASTIC_CACHE_ARCH_TYPE_RWSPLIT = "rwsplit" // 读写分离
|
||||
)
|
||||
|
||||
@@ -250,6 +250,11 @@ const (
|
||||
ACT_RESTORE = "restore"
|
||||
ACT_CHANGE_CONFIG = "change_config"
|
||||
ACT_RESET_PASSWORD = "reset_password"
|
||||
|
||||
ACT_SUBIMAGE_UPDATE_FAIL = "guest_image_subimages_update_fail"
|
||||
|
||||
ACT_FLUSH_INSTANCE = "flush_instance"
|
||||
ACT_FLUSH_INSTANCE_FAIL = "flush_instance_fail"
|
||||
)
|
||||
|
||||
type SOpsLogManager struct {
|
||||
|
||||
@@ -289,7 +289,8 @@ func (self *SElasticcacheAccount) GetUpdateHuaweiElasticcacheAccountParams(data
|
||||
ret.Password = &password
|
||||
oldpasswd, err := self.GetDecodedPassword()
|
||||
if err != nil {
|
||||
return ret, err
|
||||
// can not update password, if old password is emtpy
|
||||
return ret, errors.Wrap(err, "ElasticcacheAccount.GetUpdateHuaweiElasticcacheAccountParams.GetDecodedPassword")
|
||||
}
|
||||
|
||||
ret.OldPassword = &oldpasswd
|
||||
|
||||
@@ -205,22 +205,30 @@ func (manager *SElasticcacheBackupManager) AllowCreateItem(ctx context.Context,
|
||||
|
||||
func (manager *SElasticcacheBackupManager) ValidateCreateData(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
|
||||
var region *SCloudregion
|
||||
var ec *SElasticcache
|
||||
if id, _ := data.GetString("elasticcache"); len(id) > 0 {
|
||||
ec, err := db.FetchByIdOrName(ElasticcacheManager, userCred, id)
|
||||
_ec, err := db.FetchByIdOrName(ElasticcacheManager, userCred, id)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("getting elastic cache instance failed")
|
||||
}
|
||||
region = ec.(*SElasticcache).GetRegion()
|
||||
|
||||
ec = _ec.(*SElasticcache)
|
||||
} else {
|
||||
return nil, httperrors.NewMissingParameterError("elasticcache")
|
||||
}
|
||||
|
||||
region = ec.GetRegion()
|
||||
driver := region.GetDriver()
|
||||
if err := driver.AllowCreateElasticcacheBackup(ctx, userCred, ownerId, ec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
data, err := manager.SStandaloneResourceBaseManager.ValidateCreateData(ctx, userCred, ownerId, query, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return region.GetDriver().ValidateCreateElasticcacheBackupData(ctx, userCred, ownerId, data)
|
||||
return driver.ValidateCreateElasticcacheBackupData(ctx, userCred, ownerId, data)
|
||||
}
|
||||
|
||||
func (self *SElasticcacheBackup) PostCreate(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data jsonutils.JSONObject) {
|
||||
@@ -282,6 +290,7 @@ func (self *SElasticcacheBackup) PerformRestoreInstance(ctx context.Context, use
|
||||
return nil, err
|
||||
}
|
||||
|
||||
self.SetStatus(userCred, api.ELASTIC_CACHE_STATUS_BACKUPRECOVERING, "")
|
||||
return nil, self.StartRestoreInstanceTask(ctx, userCred, data.(*jsonutils.JSONDict), "")
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/tristate"
|
||||
"yunion.io/x/pkg/util/compare"
|
||||
"yunion.io/x/pkg/utils"
|
||||
"yunion.io/x/sqlchemy"
|
||||
@@ -69,6 +70,8 @@ type SElasticcache struct {
|
||||
SZoneResourceBase // 主可用区.
|
||||
SlaveZones string `width:"128" charset:"ascii" nullable:"false" list:"user" create:"optional"` // 备可用区
|
||||
|
||||
DisableDelete tristate.TriState `nullable:"false" default:"true" list:"user" update:"user" create:"optional"` // Column(Boolean, nullable=False, default=True)
|
||||
|
||||
InstanceType string `width:"96" charset:"ascii" nullable:"true" list:"user" create:"optional"` // redis.master.micro.default
|
||||
CapacityMB int `nullable:"false" list:"user" create:"optional"` // 1024
|
||||
LocalCategory string `width:"16" charset:"ascii" nullable:"false" list:"user" create:"optional"` // 对应Sku local_category
|
||||
@@ -460,7 +463,7 @@ func (self *SElasticcache) GetIRegion() (cloudprovider.ICloudRegion, error) {
|
||||
return provider.GetIRegionById(region.ExternalId)
|
||||
}
|
||||
|
||||
func (self *SElasticcache) GetCreateAliyunElasticcacheParams() (*cloudprovider.SCloudElasticCacheInput, error) {
|
||||
func (self *SElasticcache) GetCreateAliyunElasticcacheParams(data *jsonutils.JSONDict) (*cloudprovider.SCloudElasticCacheInput, error) {
|
||||
input := &cloudprovider.SCloudElasticCacheInput{}
|
||||
iregion, err := self.GetIRegion()
|
||||
if err != nil {
|
||||
@@ -472,8 +475,10 @@ func (self *SElasticcache) GetCreateAliyunElasticcacheParams() (*cloudprovider.S
|
||||
input.InstanceType = self.InstanceType
|
||||
input.InstanceName = self.GetName()
|
||||
|
||||
// todo: inject password here
|
||||
// input.Password = "xxxx"
|
||||
if password, _ := data.GetString("password"); len(password) > 0 {
|
||||
input.Password = password
|
||||
}
|
||||
|
||||
input.Engine = strings.Title(self.Engine)
|
||||
input.EngineVersion = self.EngineVersion
|
||||
input.PrivateIpAddress = self.PrivateIpAddr
|
||||
@@ -539,7 +544,7 @@ func (self *SElasticcache) GetCreateAliyunElasticcacheParams() (*cloudprovider.S
|
||||
return input, nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) GetCreateHuaweiElasticcacheParams() (*cloudprovider.SCloudElasticCacheInput, error) {
|
||||
func (self *SElasticcache) GetCreateHuaweiElasticcacheParams(data *jsonutils.JSONDict) (*cloudprovider.SCloudElasticCacheInput, error) {
|
||||
input := &cloudprovider.SCloudElasticCacheInput{}
|
||||
iregion, err := self.GetIRegion()
|
||||
if err != nil {
|
||||
@@ -552,16 +557,13 @@ func (self *SElasticcache) GetCreateHuaweiElasticcacheParams() (*cloudprovider.S
|
||||
input.CapacityGB = int64(self.CapacityMB / 1024)
|
||||
}
|
||||
|
||||
sku, err := db.FetchById(ElasticcacheSkuManager, self.InstanceType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
input.InstanceType = sku.(*SElasticcacheSku).InstanceSpec
|
||||
input.InstanceType = self.InstanceType
|
||||
input.InstanceName = self.GetName()
|
||||
|
||||
// todo: inject password here
|
||||
// input.Password = "xxxx"
|
||||
if password, _ := data.GetString("password"); len(password) > 0 {
|
||||
input.Password = password
|
||||
}
|
||||
|
||||
switch self.Engine {
|
||||
case "redis":
|
||||
input.Engine = "Redis"
|
||||
@@ -648,6 +650,7 @@ func (self *SElasticcache) AllowPerformRestart(ctx context.Context, userCred mcc
|
||||
|
||||
func (self *SElasticcache) PerformRestart(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
if utils.IsInStringArray(self.Status, []string{api.ELASTIC_CACHE_STATUS_RUNNING, api.ELASTIC_CACHE_STATUS_INACTIVE}) {
|
||||
self.SetStatus(userCred, api.ELASTIC_CACHE_STATUS_RESTARTING, "")
|
||||
return nil, self.StartRestartTask(ctx, userCred, "", data)
|
||||
} else {
|
||||
return nil, httperrors.NewInvalidStatusError("Cannot do restart elasticcache instance in status %s", self.Status)
|
||||
@@ -666,6 +669,14 @@ func (self *SElasticcache) StartRestartTask(ctx context.Context, userCred mcclie
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) ValidateDeleteCondition(ctx context.Context) error {
|
||||
if self.DisableDelete.IsTrue() {
|
||||
return httperrors.NewInvalidStatusError("Elastic cache is locked, cannot delete")
|
||||
}
|
||||
|
||||
return self.SVirtualResourceBase.ValidateDeleteCondition(ctx)
|
||||
}
|
||||
|
||||
func (self *SElasticcache) CustomizeDelete(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) error {
|
||||
return self.StartDeleteElasticcacheTask(ctx, userCred, jsonutils.NewDict(), "")
|
||||
}
|
||||
@@ -723,11 +734,11 @@ func (self *SElasticcache) PerformChangeSpec(ctx context.Context, userCred mccli
|
||||
params := jsonutils.NewDict()
|
||||
sku, _ := data.GetString("sku_ext_id")
|
||||
params.Set("sku_ext_id", jsonutils.NewString(sku))
|
||||
self.SetStatus(userCred, api.ELASTIC_CACHE_STATUS_CHANGING, "")
|
||||
return nil, self.StartChangeSpecTask(ctx, userCred, params, "")
|
||||
}
|
||||
|
||||
func (self *SElasticcache) StartChangeSpecTask(ctx context.Context, userCred mcclient.TokenCredential, params *jsonutils.JSONDict, parentTaskId string) error {
|
||||
self.SetStatus(userCred, api.ELASTIC_CACHE_STATUS_CHANGING, "")
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "ElasticcacheChangeSpecTask", self, userCred, params, parentTaskId, "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -742,6 +753,21 @@ func (self *SElasticcache) AllowPerformUpdateAuthMode(ctx context.Context, userC
|
||||
}
|
||||
|
||||
func (self *SElasticcache) ValidatorUpdateAuthModeData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
region := self.GetRegion()
|
||||
if region == nil {
|
||||
return nil, fmt.Errorf("fail to found region for elastic cache")
|
||||
}
|
||||
|
||||
driver := region.GetDriver()
|
||||
if driver == nil {
|
||||
return nil, fmt.Errorf("fail to found driver for elastic cache")
|
||||
}
|
||||
|
||||
err := driver.AllowUpdateElasticcacheAuthMode(ctx, userCred, self.GetOwnerId(), self)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
authModeV := validators.NewStringChoicesValidator("auth_mode", choices.NewChoices("on", "off"))
|
||||
if err := authModeV.Optional(false).Validate(data.(*jsonutils.JSONDict)); err != nil {
|
||||
return nil, err
|
||||
@@ -763,6 +789,7 @@ func (self *SElasticcache) PerformUpdateAuthMode(ctx context.Context, userCred m
|
||||
params := jsonutils.NewDict()
|
||||
authMode, _ := data.GetString("auth_mode")
|
||||
params.Set("auth_mode", jsonutils.NewString(authMode))
|
||||
self.SetStatus(userCred, api.ELASTIC_CACHE_STATUS_CHANGING, "")
|
||||
return nil, self.StartUpdateAuthModeTask(ctx, userCred, params, "")
|
||||
}
|
||||
|
||||
@@ -805,6 +832,7 @@ func (self *SElasticcache) PerformResetPassword(ctx context.Context, userCred mc
|
||||
return nil, err
|
||||
}
|
||||
|
||||
self.SetStatus(userCred, api.ELASTIC_CACHE_STATUS_CHANGING, "")
|
||||
return nil, self.StartResetPasswordTask(ctx, userCred, data.(*jsonutils.JSONDict), "")
|
||||
}
|
||||
|
||||
@@ -875,6 +903,7 @@ func (self *SElasticcache) PerformSetMaintainTime(ctx context.Context, userCred
|
||||
endTime, _ := data.GetString("maintain_end_time")
|
||||
params.Set("maintain_start_time", jsonutils.NewString(startTime))
|
||||
params.Set("maintain_end_time", jsonutils.NewString(endTime))
|
||||
self.SetStatus(userCred, api.ELASTIC_CACHE_STATUS_CHANGING, "")
|
||||
return nil, self.StartSetMaintainTimeTask(ctx, userCred, params, "")
|
||||
}
|
||||
|
||||
@@ -915,6 +944,7 @@ func (self *SElasticcache) PerformAllocatePublicConnection(ctx context.Context,
|
||||
params := jsonutils.NewDict()
|
||||
port, _ := data.Int("port")
|
||||
params.Set("port", jsonutils.NewInt(port))
|
||||
self.SetStatus(userCred, api.ELASTIC_CACHE_STATUS_NETWORKMODIFYING, "")
|
||||
return nil, self.StartAllocatePublicConnectionTask(ctx, userCred, params, "")
|
||||
}
|
||||
|
||||
@@ -946,6 +976,7 @@ func (self *SElasticcache) PerformReleasePublicConnection(ctx context.Context, u
|
||||
return nil, err
|
||||
}
|
||||
|
||||
self.SetStatus(userCred, api.ELASTIC_CACHE_STATUS_NETWORKMODIFYING, "")
|
||||
return nil, self.StartReleasePublicConnectionTask(ctx, userCred, jsonutils.NewDict(), "")
|
||||
}
|
||||
|
||||
@@ -1005,6 +1036,7 @@ func (self *SElasticcache) PerformUpdateInstanceParameters(ctx context.Context,
|
||||
params := jsonutils.NewDict()
|
||||
parameters, _ := data.Get("parameters")
|
||||
params.Set("parameters", parameters)
|
||||
self.SetStatus(userCred, api.ELASTIC_CACHE_STATUS_CHANGING, "")
|
||||
return nil, self.StartUpdateInstanceParametersTask(ctx, userCred, params, "")
|
||||
}
|
||||
|
||||
@@ -1051,6 +1083,7 @@ func (self *SElasticcache) PerformUpdateBackupPolicy(ctx context.Context, userCr
|
||||
return nil, err
|
||||
}
|
||||
|
||||
self.SetStatus(userCred, api.ELASTIC_CACHE_STATUS_CHANGING, "")
|
||||
return nil, self.StartUpdateBackupPolicyTask(ctx, userCred, data.(*jsonutils.JSONDict), "")
|
||||
}
|
||||
|
||||
@@ -1069,6 +1102,7 @@ func (self *SElasticcache) AllowPerformSync(ctx context.Context, userCred mcclie
|
||||
}
|
||||
|
||||
func (self *SElasticcache) PerformSync(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
self.SetStatus(userCred, api.ELASTIC_CACHE_STATUS_SYNCING, "")
|
||||
return nil, self.StartSyncTask(ctx, userCred, data.(*jsonutils.JSONDict), "")
|
||||
}
|
||||
|
||||
|
||||
@@ -141,6 +141,8 @@ type IRegionDriver interface {
|
||||
}
|
||||
|
||||
type IElasticcacheDriver interface {
|
||||
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)
|
||||
ValidateCreateElasticcacheAccountData(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error)
|
||||
ValidateCreateElasticcacheAclData(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error)
|
||||
|
||||
@@ -98,18 +98,16 @@ func (self *SSkuResourcesMeta) GetElasticCacheSkus() ([]SElasticcacheSku, error)
|
||||
return nil, errors.Wrap(err, "obj.Unmarshal")
|
||||
}
|
||||
// 处理数据
|
||||
provider := sku.Provider
|
||||
region := sku.CloudregionId
|
||||
|
||||
sku.Id = ""
|
||||
r, err := self.fetchRegion(provider, region)
|
||||
|
||||
r, err := self.fetchRegion(sku.CloudregionId)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SkuResourcesMeta.GetElasticCacheSkus.fetchRegion")
|
||||
}
|
||||
sku.CloudregionId = r.GetId()
|
||||
|
||||
if len(sku.ZoneId) > 0 {
|
||||
zone, err := self.fetchZone(provider, region, sku.ZoneId)
|
||||
zone, err := self.fetchZone(sku.ZoneId)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SkuResourcesMeta.GetElasticCacheSkus.MasterZone")
|
||||
}
|
||||
@@ -118,7 +116,7 @@ func (self *SSkuResourcesMeta) GetElasticCacheSkus() ([]SElasticcacheSku, error)
|
||||
}
|
||||
|
||||
if len(sku.SlaveZoneId) > 0 {
|
||||
zone, err := self.fetchZone(provider, region, sku.SlaveZoneId)
|
||||
zone, err := self.fetchZone(sku.SlaveZoneId)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SkuResourcesMeta.GetElasticCacheSkus.SlaveZone")
|
||||
}
|
||||
@@ -131,12 +129,11 @@ func (self *SSkuResourcesMeta) GetElasticCacheSkus() ([]SElasticcacheSku, error)
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (self *SSkuResourcesMeta) fetchZone(provider, region, zone string) (*SZone, error) {
|
||||
func (self *SSkuResourcesMeta) fetchZone(zoneExternalId string) (*SZone, error) {
|
||||
if self.zoneCaches == nil {
|
||||
self.zoneCaches = map[string]*SZone{}
|
||||
}
|
||||
|
||||
zoneExternalId := strings.Join([]string{provider, region, zone}, "/")
|
||||
if z, ok := self.zoneCaches[zoneExternalId]; ok {
|
||||
return z, nil
|
||||
}
|
||||
@@ -151,12 +148,11 @@ func (self *SSkuResourcesMeta) fetchZone(provider, region, zone string) (*SZone,
|
||||
return z, nil
|
||||
}
|
||||
|
||||
func (self *SSkuResourcesMeta) fetchRegion(provider, region string) (*SCloudregion, error) {
|
||||
func (self *SSkuResourcesMeta) fetchRegion(regionExternalId string) (*SCloudregion, error) {
|
||||
if self.regionCaches == nil {
|
||||
self.regionCaches = map[string]*SCloudregion{}
|
||||
}
|
||||
|
||||
regionExternalId := strings.Join([]string{provider, region}, "/")
|
||||
if r, ok := self.regionCaches[regionExternalId]; ok {
|
||||
return r, nil
|
||||
}
|
||||
|
||||
@@ -1265,7 +1265,7 @@ func (self *SAliyunRegionDriver) RequestCreateElasticcache(ctx context.Context,
|
||||
|
||||
provider := iprovider.(*models.SCloudprovider)
|
||||
|
||||
params, err := ec.GetCreateAliyunElasticcacheParams()
|
||||
params, err := ec.GetCreateAliyunElasticcacheParams(task.GetParams())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "aliyunRegionDriver.CreateElasticcache.GetCreateAliyunElasticcacheParams")
|
||||
}
|
||||
|
||||
@@ -2418,7 +2418,7 @@ func (self *SHuaWeiRegionDriver) RequestCreateElasticcache(ctx context.Context,
|
||||
|
||||
provider := iprovider.(*models.SCloudprovider)
|
||||
|
||||
params, err := ec.GetCreateHuaweiElasticcacheParams()
|
||||
params, err := ec.GetCreateHuaweiElasticcacheParams(task.GetParams())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "huaweiRegionDriver.CreateElasticcache.GetCreateHuaweiElasticcacheParams")
|
||||
}
|
||||
@@ -2546,3 +2546,19 @@ func (self *SHuaWeiRegionDriver) RequestElasticcacheAccountResetPassword(ctx con
|
||||
|
||||
return ea.SetStatus(userCred, api.ELASTIC_CACHE_ACCOUNT_STATUS_AVAILABLE, "")
|
||||
}
|
||||
|
||||
func (self *SHuaWeiRegionDriver) RequestUpdateElasticcacheAuthMode(ctx context.Context, userCred mcclient.TokenCredential, ec *models.SElasticcache, task taskman.ITask) error {
|
||||
return errors.Wrap(fmt.Errorf("not support update huawei elastic cache auth_mode"), "HuaWeiRegionDriver.RequestUpdateElasticcacheAuthMode")
|
||||
}
|
||||
|
||||
func (self *SHuaWeiRegionDriver) AllowCreateElasticcacheBackup(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, elasticcache *models.SElasticcache) error {
|
||||
if elasticcache.LocalCategory == api.ELASTIC_CACHE_ARCH_TYPE_SINGLE {
|
||||
return httperrors.NewBadRequestError("huawei %s mode elastic not support create backup", elasticcache.LocalCategory)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
@@ -946,6 +946,10 @@ func (self *SKVMRegionDriver) ValidateCreateElasticcacheAclData(ctx context.Cont
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (self *SKVMRegionDriver) AllowCreateElasticcacheBackup(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, elasticcache *models.SElasticcache) error {
|
||||
return fmt.Errorf("not support create kvm elastic cache backup")
|
||||
}
|
||||
|
||||
func (self *SKVMRegionDriver) ValidateCreateElasticcacheBackupData(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -985,3 +989,7 @@ func (self *SKVMRegionDriver) RequestElasticcacheAclUpdate(ctx context.Context,
|
||||
func (self *SKVMRegionDriver) RequestElasticcacheBackupRestoreInstance(ctx context.Context, userCred mcclient.TokenCredential, ea *models.SElasticcacheBackup, task taskman.ITask) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SKVMRegionDriver) AllowUpdateElasticcacheAuthMode(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, elasticcache *models.SElasticcache) error {
|
||||
return fmt.Errorf("not support update kvm elastic cache auth_mode")
|
||||
}
|
||||
|
||||
@@ -1622,6 +1622,7 @@ func (self *SManagedVirtualizationRegionDriver) RequestCreateDBInstance(ctx cont
|
||||
}
|
||||
|
||||
func (self *SManagedVirtualizationRegionDriver) RequestCreateElasticcache(ctx context.Context, userCred mcclient.TokenCredential, elasticcache *models.SElasticcache, task taskman.ITask) error {
|
||||
task.ScheduleRun(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1661,6 +1662,11 @@ func (self *SManagedVirtualizationRegionDriver) RequestSyncElasticcache(ctx cont
|
||||
|
||||
iec, err := iregion.GetIElasticcacheById(ec.ExternalId)
|
||||
if err != nil {
|
||||
if err == cloudprovider.ErrNotFound {
|
||||
ec.SetStatus(userCred, api.ELASTIC_CACHE_STATUS_UNKNOWN, "")
|
||||
return nil
|
||||
}
|
||||
|
||||
return errors.Wrap(err, "managedVirtualizationRegionDriver.RequestSyncElasticcache.GetIElasticcacheById")
|
||||
}
|
||||
|
||||
@@ -2050,6 +2056,10 @@ func (self *SManagedVirtualizationRegionDriver) ValidateCreateElasticcacheAclDat
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (self *SManagedVirtualizationRegionDriver) AllowCreateElasticcacheBackup(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, elasticcache *models.SElasticcache) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SManagedVirtualizationRegionDriver) ValidateCreateElasticcacheBackupData(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
|
||||
elasticcacheV := validators.NewModelIdOrNameValidator("elasticcache", "elasticcache", ownerId)
|
||||
if err := elasticcacheV.Validate(data); err != nil {
|
||||
@@ -2518,3 +2528,7 @@ func (self *SManagedVirtualizationRegionDriver) RequestElasticcacheBackupRestore
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SManagedVirtualizationRegionDriver) AllowUpdateElasticcacheAuthMode(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, elasticcache *models.SElasticcache) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ func (self *ElasticcacheAccountCreateTask) OnInit(ctx context.Context, obj db.IS
|
||||
}
|
||||
|
||||
func (self *ElasticcacheAccountCreateTask) OnElasticcacheAccountCreateComplete(ctx context.Context, ea *models.SElasticcacheAccount, data jsonutils.JSONObject) {
|
||||
logclient.AddActionLogWithStartable(self, ea, logclient.ACT_CREATE, nil, self.UserCred, true)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ func init() {
|
||||
|
||||
func (self *ElasticcacheAccountDeleteTask) taskFail(ctx context.Context, ea *models.SElasticcacheAccount, reason string) {
|
||||
ea.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_ACCOUNT_STATUS_DELETE_FAILED, reason)
|
||||
db.OpsLog.LogEvent(ea, db.ACT_ALLOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, ea, logclient.ACT_CREATE, reason, self.UserCred, false)
|
||||
db.OpsLog.LogEvent(ea, db.ACT_DELETE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, ea, logclient.ACT_DELETE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(ea.Id, ea.Name, api.ELASTIC_CACHE_ACCOUNT_STATUS_DELETE_FAILED, reason)
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
@@ -62,6 +62,8 @@ func (self *ElasticcacheAccountDeleteTask) OnInit(ctx context.Context, obj db.IS
|
||||
self.taskFail(ctx, ea, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
logclient.AddActionLogWithStartable(self, ea, logclient.ACT_DELETE, nil, self.UserCred, true)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,27 +36,36 @@ func init() {
|
||||
taskman.RegisterTask(ElasticcacheAccountResetPasswordTask{})
|
||||
}
|
||||
|
||||
func (self *ElasticcacheAccountResetPasswordTask) taskFail(ctx context.Context, elasticcache *models.SElasticcacheAccount, reason string) {
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_UNAVAILABLE, reason)
|
||||
db.OpsLog.LogEvent(elasticcache, db.ACT_ALLOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_CREATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_CREATE_FAILED, reason)
|
||||
func (self *ElasticcacheAccountResetPasswordTask) taskFail(ctx context.Context, ea *models.SElasticcacheAccount, reason string) {
|
||||
ea.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_CHANGE_FAILED, reason)
|
||||
ec, err := db.FetchById(models.ElasticcacheManager, ea.ElasticcacheId)
|
||||
if err == nil {
|
||||
ec.(*models.SElasticcache).SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_CHANGE_FAILED, reason)
|
||||
}
|
||||
db.OpsLog.LogEvent(ea, db.ACT_RESET_PASSWORD, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, ea, logclient.ACT_RESET_PASSWORD, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(ea.Id, ea.Name, api.ELASTIC_CACHE_STATUS_CREATE_FAILED, reason)
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
func (self *ElasticcacheAccountResetPasswordTask) OnInit(ctx context.Context, obj db.IStandaloneModel, data jsonutils.JSONObject) {
|
||||
ec := obj.(*models.SElasticcacheAccount)
|
||||
region := ec.GetRegion()
|
||||
ea := obj.(*models.SElasticcacheAccount)
|
||||
region := ea.GetRegion()
|
||||
if region == nil {
|
||||
self.taskFail(ctx, ec, fmt.Sprintf("failed to find region for elastic cache %s", ec.GetName()))
|
||||
self.taskFail(ctx, ea, fmt.Sprintf("failed to find region for elastic cache account %s", ea.GetName()))
|
||||
return
|
||||
}
|
||||
|
||||
self.SetStage("OnElasticcacheAccountResetPasswordComplete", nil)
|
||||
if err := region.GetDriver().RequestElasticcacheAccountResetPassword(ctx, self.GetUserCred(), ec, self); err != nil {
|
||||
self.taskFail(ctx, ec, err.Error())
|
||||
if err := region.GetDriver().RequestElasticcacheAccountResetPassword(ctx, self.GetUserCred(), ea, self); err != nil {
|
||||
self.taskFail(ctx, ea, err.Error())
|
||||
return
|
||||
} else {
|
||||
logclient.AddActionLogWithStartable(self, ea, logclient.ACT_RESET_PASSWORD, nil, self.UserCred, true)
|
||||
ec, err := db.FetchById(models.ElasticcacheManager, ea.ElasticcacheId)
|
||||
if err == nil {
|
||||
ec.(*models.SElasticcache).SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_RUNNING, "")
|
||||
}
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ func (self *ElasticcacheAclCreateTask) OnInit(ctx context.Context, obj db.IStand
|
||||
}
|
||||
|
||||
func (self *ElasticcacheAclCreateTask) OnElasticcacheAclCreateComplete(ctx context.Context, ea *models.SElasticcacheAcl, data jsonutils.JSONObject) {
|
||||
logclient.AddActionLogWithStartable(self, ea, logclient.ACT_CREATE, nil, self.UserCred, true)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ func (self *ElasticcacheAclDeleteTask) OnInit(ctx context.Context, obj db.IStand
|
||||
self.taskFail(ctx, ea, err.Error())
|
||||
return
|
||||
}
|
||||
logclient.AddActionLogWithStartable(self, ea, logclient.ACT_DELETE, nil, self.UserCred, true)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ func (self *ElasticcacheAclUpdateTask) OnInit(ctx context.Context, obj db.IStand
|
||||
}
|
||||
|
||||
func (self *ElasticcacheAclUpdateTask) OnElasticcacheAclUpdateComplete(ctx context.Context, ea *models.SElasticcacheAcl, data jsonutils.JSONObject) {
|
||||
logclient.AddActionLogWithStartable(self, ea, logclient.ACT_UPDATE, nil, self.UserCred, true)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ func (self *ElasticcacheAllocatePublicConnectionTask) OnInit(ctx context.Context
|
||||
|
||||
func (self *ElasticcacheAllocatePublicConnectionTask) OnElasticcacheAllocatePublicConnectionComplete(ctx context.Context, elasticcache *models.SElasticcache, data jsonutils.JSONObject) {
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_RUNNING, "")
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_ALLOCATE, "allocate public connection", self.UserCred, true)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
|
||||
|
||||
@@ -59,11 +59,12 @@ func (self *ElasticcacheBackupCreateTask) OnInit(ctx context.Context, obj db.ISt
|
||||
}
|
||||
}
|
||||
|
||||
func (self *ElasticcacheBackupCreateTask) OnElasticcacheBackupCreateComplete(ctx context.Context, ea *models.SElasticcacheBackup, data jsonutils.JSONObject) {
|
||||
ea.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_RUNNING, "")
|
||||
func (self *ElasticcacheBackupCreateTask) OnElasticcacheBackupCreateComplete(ctx context.Context, eb *models.SElasticcacheBackup, data jsonutils.JSONObject) {
|
||||
eb.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_RUNNING, "")
|
||||
logclient.AddActionLogWithStartable(self, eb, logclient.ACT_CREATE, "", self.UserCred, true)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
|
||||
func (self *ElasticcacheBackupCreateTask) OnElasticcacheBackupCreateCompleteFailed(ctx context.Context, ea *models.SElasticcacheBackup, reason string) {
|
||||
self.taskFail(ctx, ea, reason)
|
||||
func (self *ElasticcacheBackupCreateTask) OnElasticcacheBackupCreateCompleteFailed(ctx context.Context, eb *models.SElasticcacheBackup, reason string) {
|
||||
self.taskFail(ctx, eb, reason)
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ func (self *ElasticcacheBackupRestoreInstanceTask) OnInit(ctx context.Context, o
|
||||
|
||||
func (self *ElasticcacheBackupRestoreInstanceTask) OnElasticcacheBackupRestoreInstanceComplete(ctx context.Context, eb *models.SElasticcacheBackup, data jsonutils.JSONObject) {
|
||||
eb.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_RUNNING, "")
|
||||
logclient.AddActionLogWithStartable(self, eb, logclient.ACT_RESTORE, "", self.UserCred, true)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ func (self *ElasticcacheChangeSpecTask) OnInit(ctx context.Context, obj db.IStan
|
||||
|
||||
func (self *ElasticcacheChangeSpecTask) OnElasticcacheChangeSpecComplete(ctx context.Context, elasticcache *models.SElasticcache, data jsonutils.JSONObject) {
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_RUNNING, "")
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_VM_CHANGE_FLAVOR, "", self.UserCred, true)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,8 @@ func (self *ElasticcacheCreateTask) OnSyncSecurityGroupComplete(ctx context.Cont
|
||||
}
|
||||
|
||||
func (self *ElasticcacheCreateTask) OnElasticcacheCreateComplete(ctx context.Context, elasticcache *models.SElasticcache, data jsonutils.JSONObject) {
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_RUNNING, "")
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_CREATE, "", self.UserCred, true)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ func (self *ElasticcacheDeleteTask) OnInit(ctx context.Context, obj db.IStandalo
|
||||
ec.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_RELEASED, "")
|
||||
// delete related resources
|
||||
ec.DeleteSubResources(ctx, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, ec, logclient.ACT_DELETE, "", self.UserCred, true)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,10 +37,10 @@ func init() {
|
||||
}
|
||||
|
||||
func (self *ElasticcacheFlushInstanceTask) taskFail(ctx context.Context, elasticcache *models.SElasticcache, reason string) {
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_CREATE_FAILED, reason)
|
||||
db.OpsLog.LogEvent(elasticcache, db.ACT_REW_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_UNCACHED_IMAGE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_ACL_STATUS_UPDATE_FAILED, reason)
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_FLUSHING_FAILED, reason)
|
||||
db.OpsLog.LogEvent(elasticcache, db.ACT_FLUSH_INSTANCE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_FLUSH_INSTANCE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_FLUSHING_FAILED, reason)
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ func (self *ElasticcacheFlushInstanceTask) OnInit(ctx context.Context, obj db.IS
|
||||
|
||||
func (self *ElasticcacheFlushInstanceTask) OnElasticcacheFlushInstanceComplete(ctx context.Context, elasticcache *models.SElasticcache, data jsonutils.JSONObject) {
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_RUNNING, "")
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_FLUSH_INSTANCE, "", self.UserCred, true)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
|
||||
|
||||
@@ -64,10 +64,11 @@ func (self *ElasticcacheParameterUpdateTask) OnInit(ctx context.Context, obj db.
|
||||
}
|
||||
}
|
||||
|
||||
func (self *ElasticcacheParameterUpdateTask) OnElasticcacheParameterUpdateComplete(ctx context.Context, ea *models.SElasticcacheParameter, data jsonutils.JSONObject) {
|
||||
func (self *ElasticcacheParameterUpdateTask) OnElasticcacheParameterUpdateComplete(ctx context.Context, ep *models.SElasticcacheParameter, data jsonutils.JSONObject) {
|
||||
logclient.AddActionLogWithStartable(self, ep, logclient.ACT_UPDATE, "", self.UserCred, true)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
|
||||
func (self *ElasticcacheParameterUpdateTask) OnElasticcacheParameterUpdateCompleteFailed(ctx context.Context, ea *models.SElasticcacheParameter, reason string) {
|
||||
self.taskFail(ctx, ea, reason)
|
||||
func (self *ElasticcacheParameterUpdateTask) OnElasticcacheParameterUpdateCompleteFailed(ctx context.Context, ep *models.SElasticcacheParameter, reason string) {
|
||||
self.taskFail(ctx, ep, reason)
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ func (self *ElasticcacheRestartTask) OnInit(ctx context.Context, obj db.IStandal
|
||||
self.taskFail(ctx, ec, err.Error())
|
||||
return
|
||||
} else {
|
||||
logclient.AddActionLogWithStartable(self, ec, logclient.ACT_VM_RESTART, nil, self.UserCred, true)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,10 +37,10 @@ func init() {
|
||||
}
|
||||
|
||||
func (self *ElasticcacheSetMaintainTimeTask) taskFail(ctx context.Context, elasticcache *models.SElasticcache, reason string) {
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_CREATE_FAILED, reason)
|
||||
db.OpsLog.LogEvent(elasticcache, db.ACT_ALLOCATE_FAIL, reason, self.UserCred)
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_CHANGE_FAILED, reason)
|
||||
db.OpsLog.LogEvent(elasticcache, db.ACT_UPDATE, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_UPDATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_ACL_STATUS_UPDATE_FAILED, reason)
|
||||
notifyclient.NotifySystemError(elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_CHANGE_FAILED, reason)
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ func (self *ElasticcacheSetMaintainTimeTask) OnInit(ctx context.Context, obj db.
|
||||
|
||||
func (self *ElasticcacheSetMaintainTimeTask) OnElasticcacheSetMaintainTimeComplete(ctx context.Context, elasticcache *models.SElasticcache, data jsonutils.JSONObject) {
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_RUNNING, "")
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_UPDATE, "", self.UserCred, true)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ func (self *ElasticcacheSyncTask) OnInit(ctx context.Context, obj db.IStandalone
|
||||
self.taskFail(ctx, ec, err.Error())
|
||||
return
|
||||
} else {
|
||||
logclient.AddActionLogWithStartable(self, ec, logclient.ACT_SYNC_CONF, "", self.UserCred, true)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,10 +37,10 @@ func init() {
|
||||
}
|
||||
|
||||
func (self *ElasticcacheUpdateAuthModeTask) taskFail(ctx context.Context, elasticcache *models.SElasticcache, reason string) {
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_CREATE_FAILED, reason)
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_CHANGE_FAILED, reason)
|
||||
db.OpsLog.LogEvent(elasticcache, db.ACT_UPDATE, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_UPDATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_ACL_STATUS_UPDATE_FAILED, reason)
|
||||
notifyclient.NotifySystemError(elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_CHANGE_FAILED, reason)
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ func (self *ElasticcacheUpdateAuthModeTask) OnInit(ctx context.Context, obj db.I
|
||||
|
||||
func (self *ElasticcacheUpdateAuthModeTask) OnElasticcacheUpdateAuthModeComplete(ctx context.Context, elasticcache *models.SElasticcache, data jsonutils.JSONObject) {
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_RUNNING, "")
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_UPDATE, "", self.UserCred, true)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
|
||||
|
||||
@@ -37,10 +37,10 @@ func init() {
|
||||
}
|
||||
|
||||
func (self *ElasticcacheUpdateBackupPolicyTask) taskFail(ctx context.Context, elasticcache *models.SElasticcache, reason string) {
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_CREATE_FAILED, reason)
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_CHANGE_FAILED, reason)
|
||||
db.OpsLog.LogEvent(elasticcache, db.ACT_UPDATE, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_UPDATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_ACL_STATUS_UPDATE_FAILED, reason)
|
||||
notifyclient.NotifySystemError(elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_CHANGE_FAILED, reason)
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ func (self *ElasticcacheUpdateBackupPolicyTask) OnInit(ctx context.Context, obj
|
||||
|
||||
func (self *ElasticcacheUpdateBackupPolicyTask) OnElasticcacheUpdateBackupPolicyComplete(ctx context.Context, elasticcache *models.SElasticcache, data jsonutils.JSONObject) {
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_RUNNING, "")
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_UPDATE, "", self.UserCred, true)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
|
||||
|
||||
@@ -209,14 +209,14 @@ func (self *SElasticcache) GetCapacityMB() int {
|
||||
func (self *SElasticcache) GetArchType() string {
|
||||
switch self.ArchitectureType {
|
||||
case "rwsplit":
|
||||
return "rwsplit"
|
||||
return api.ELASTIC_CACHE_ARCH_TYPE_RWSPLIT
|
||||
case "cluster":
|
||||
return "cluster"
|
||||
return api.ELASTIC_CACHE_ARCH_TYPE_CLUSTER
|
||||
case "standard":
|
||||
if self.NodeType == "single" {
|
||||
return "single"
|
||||
return api.ELASTIC_CACHE_ARCH_TYPE_SINGLE
|
||||
} else if self.NodeType == "double" {
|
||||
return "master"
|
||||
return api.ELASTIC_CACHE_ARCH_TYPE_MASTER
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,8 @@ func (self *SBaseManager) _list(request requests.IRequest, responseKey string) (
|
||||
return nil, err
|
||||
}
|
||||
if body == nil {
|
||||
return nil, fmt.Errorf("empty response")
|
||||
log.Warningf("empty response")
|
||||
return &responses.ListResult{}, nil
|
||||
}
|
||||
|
||||
rets, err := body.GetArray(responseKey)
|
||||
|
||||
@@ -32,7 +32,7 @@ type SElasticcacheAccount struct {
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAccount) GetId() string {
|
||||
return fmt.Sprintf("%s/%s", self.cacheDB.InstanceID, self.cacheDB.AccessUser)
|
||||
return fmt.Sprintf("%s/admin", self.cacheDB.InstanceID)
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAccount) GetName() string {
|
||||
@@ -56,28 +56,11 @@ func (self *SElasticcacheAccount) GetAccountPrivilege() string {
|
||||
}
|
||||
|
||||
// https://support.huaweicloud.com/api-dcs/dcs-zh-api-180423031.html
|
||||
// 未找到关闭密码的开放api
|
||||
// 未找到关闭密码的开放api, 不支持开启/关闭密码访问
|
||||
// https://console.huaweicloud.com/dcs/rest/v2/41f6bfe48d7f4455b7754f7c1b11ae34/instances/26db46e2-c7d8-4b5e-bd36-b5278d2fe17c/password/reset
|
||||
// new_password: "26db46e2!"
|
||||
// no_password_access: false
|
||||
func (self *SElasticcacheAccount) ResetPassword(input cloudprovider.SCloudElasticCacheAccountResetPasswordInput) error {
|
||||
if input.NoPasswordAccess != nil {
|
||||
params := jsonutils.NewDict()
|
||||
if *input.NoPasswordAccess == true {
|
||||
params.Set("no_password_access", jsonutils.JSONTrue)
|
||||
} else {
|
||||
params.Set("no_password_access", jsonutils.JSONFalse)
|
||||
}
|
||||
|
||||
params.Set("new_password", jsonutils.JSONNull)
|
||||
err := DoUpdateWithSpec(self.cacheDB.region.ecsClient.Elasticcache.UpdateInContextWithSpec, self.GetId(), "password/reset", params)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "elasticcacheAccount.NoPasswordAccess")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
if input.OldPassword == nil {
|
||||
return fmt.Errorf("elasticcacheAccount.ResetPassword.input OldPassword should not be empty")
|
||||
}
|
||||
|
||||
@@ -173,13 +173,13 @@ func (self *SElasticcache) GetArchType() string {
|
||||
dcs.cluster:表示实例类型为集群
|
||||
*/
|
||||
if strings.Contains(self.ResourceSpecCode, "single") {
|
||||
return "single"
|
||||
return api.ELASTIC_CACHE_ARCH_TYPE_SINGLE
|
||||
} else if strings.Contains(self.ResourceSpecCode, "ha") {
|
||||
return "master"
|
||||
return api.ELASTIC_CACHE_ARCH_TYPE_MASTER
|
||||
} else if strings.Contains(self.ResourceSpecCode, "cluster") {
|
||||
return "cluster"
|
||||
return api.ELASTIC_CACHE_ARCH_TYPE_CLUSTER
|
||||
} else if strings.Contains(self.ResourceSpecCode, "proxy") {
|
||||
return "cluster"
|
||||
return api.ELASTIC_CACHE_ARCH_TYPE_CLUSTER
|
||||
}
|
||||
|
||||
return ""
|
||||
@@ -257,11 +257,8 @@ func (self *SElasticcache) GetMaintainEndTime() string {
|
||||
|
||||
func (self *SElasticcache) GetICloudElasticcacheAccounts() ([]cloudprovider.ICloudElasticcacheAccount, error) {
|
||||
iaccounts := []cloudprovider.ICloudElasticcacheAccount{}
|
||||
if len(self.AccessUser) > 0 {
|
||||
iaccount := &SElasticcacheAccount{cacheDB: self}
|
||||
iaccounts = append(iaccounts, iaccount)
|
||||
}
|
||||
|
||||
iaccount := &SElasticcacheAccount{cacheDB: self}
|
||||
iaccounts = append(iaccounts, iaccount)
|
||||
return iaccounts, nil
|
||||
}
|
||||
|
||||
@@ -672,7 +669,19 @@ func (self *SElasticcache) GetAuthMode() string {
|
||||
}
|
||||
|
||||
func (self *SElasticcache) GetICloudElasticcacheAccount(accountId string) (cloudprovider.ICloudElasticcacheAccount, error) {
|
||||
return nil, cloudprovider.ErrNotSupported
|
||||
accounts, err := self.GetICloudElasticcacheAccounts()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Elasticcache.GetICloudElasticcacheAccount.Accounts")
|
||||
}
|
||||
|
||||
for i := range accounts {
|
||||
account := accounts[i]
|
||||
if account.GetGlobalId() == accountId {
|
||||
return account, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
|
||||
func (self *SElasticcache) GetICloudElasticcacheAcl(aclId string) (cloudprovider.ICloudElasticcacheAcl, error) {
|
||||
|
||||
@@ -175,4 +175,6 @@ const (
|
||||
|
||||
ACT_INSTANCE_GROUP_BIND = "绑定主机组"
|
||||
ACT_INSTANCE_GROUP_UNBIND = "解绑主机组"
|
||||
|
||||
ACT_FLUSH_INSTANCE = "清空数据"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user