diff --git a/pkg/compute/regiondrivers/aws.go b/pkg/compute/regiondrivers/aws.go index 92b03a7dc7..ac63623155 100644 --- a/pkg/compute/regiondrivers/aws.go +++ b/pkg/compute/regiondrivers/aws.go @@ -34,6 +34,7 @@ import ( "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" + "yunion.io/x/onecloud/pkg/util/logclient" "yunion.io/x/onecloud/pkg/util/seclib2" ) @@ -427,3 +428,47 @@ func (self *SAwsRegionDriver) ValidateUpdateSecurityGroupRuleInput(ctx context.C return self.SManagedVirtualizationRegionDriver.ValidateUpdateSecurityGroupRuleInput(ctx, userCred, input) } + +func (self *SAwsRegionDriver) RequestRemoteUpdateElasticcache(ctx context.Context, userCred mcclient.TokenCredential, elasticcache *models.SElasticcache, replaceTags bool, task taskman.ITask) error { + taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) { + iRegion, err := elasticcache.GetIRegion(ctx) + if err != nil { + return nil, errors.Wrap(err, "elasticcache.GetIRegion") + } + + iElasticcache, err := iRegion.GetIElasticcacheById(elasticcache.ExternalId) + if err != nil { + return nil, errors.Wrapf(err, "GetIElasticcacheById(%s)", elasticcache.ExternalId) + } + + oldTags, err := iElasticcache.GetTags() + if err != nil { + if errors.Cause(err) == cloudprovider.ErrNotSupported || errors.Cause(err) == cloudprovider.ErrNotImplemented { + return nil, nil + } + return nil, errors.Wrap(err, "iElasticcache.GetTags()") + } + tags, err := elasticcache.GetAllUserMetadata() + if err != nil { + return nil, errors.Wrapf(err, "GetAllUserMetadata") + } + tagsUpdateInfo := cloudprovider.TagsUpdateInfo{OldTags: oldTags, NewTags: tags} + mangerId := "" + if vpc, _ := elasticcache.GetVpc(); vpc != nil { + mangerId = vpc.ManagerId + } + err = cloudprovider.SetTags(ctx, iElasticcache, mangerId, tags, replaceTags) + if err != nil { + if errors.Cause(err) == cloudprovider.ErrNotSupported || errors.Cause(err) == cloudprovider.ErrNotImplemented { + return nil, nil + } + + logclient.AddActionLogWithStartable(task, elasticcache, logclient.ACT_UPDATE_TAGS, err, userCred, false) + return nil, errors.Wrap(err, "iElasticcache.SetTags") + } + cloudprovider.WaitMultiStatus(iElasticcache, []string{api.ELASTIC_CACHE_STATUS_RUNNING}, 15*time.Second, 2*time.Minute) + logclient.AddActionLogWithStartable(task, elasticcache, logclient.ACT_UPDATE_TAGS, tagsUpdateInfo, userCred, true) + return nil, nil + }) + return nil +} diff --git a/pkg/compute/regiondrivers/managedvirtual.go b/pkg/compute/regiondrivers/managedvirtual.go index 9d7d0ec302..72dd1afe15 100644 --- a/pkg/compute/regiondrivers/managedvirtual.go +++ b/pkg/compute/regiondrivers/managedvirtual.go @@ -2411,9 +2411,10 @@ func (self *SManagedVirtualizationRegionDriver) RequestRemoteUpdateDBInstance(ct err = iRds.Update(ctx, cloudprovider.SDBInstanceUpdateOptions{NAME: instance.Name, Description: instance.Description}) if err != nil { - if errors.Cause(err) != cloudprovider.ErrNotSupported { - return nil, errors.Wrap(err, "iRds.Update") + if errors.Cause(err) == cloudprovider.ErrNotSupported || errors.Cause(err) == cloudprovider.ErrNotImplemented { + return nil, nil } + return nil, errors.Wrap(err, "iRds.Update") } return nil, nil })