mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
huawei elastic change spec bugfix
This commit is contained in:
@@ -157,7 +157,6 @@ type IElasticcacheDriver interface {
|
||||
RequestDeleteElasticcacheAccount(ctx context.Context, userCred mcclient.TokenCredential, ea *SElasticcacheAccount, task taskman.ITask) error
|
||||
RequestDeleteElasticcacheAcl(ctx context.Context, userCred mcclient.TokenCredential, ea *SElasticcacheAcl, task taskman.ITask) error
|
||||
RequestDeleteElasticcacheBackup(ctx context.Context, userCred mcclient.TokenCredential, eb *SElasticcacheBackup, task taskman.ITask) error
|
||||
RequestChangeElasticcacheSpec(ctx context.Context, userCred mcclient.TokenCredential, elasticcache *SElasticcache, task taskman.ITask) error // 变更实例规格
|
||||
RequestSetElasticcacheMaintainTime(ctx context.Context, userCred mcclient.TokenCredential, elasticcache *SElasticcache, task taskman.ITask) error
|
||||
RequestElasticcacheChangeSpec(ctx context.Context, userCred mcclient.TokenCredential, elasticcache *SElasticcache, task taskman.ITask) error
|
||||
RequestUpdateElasticcacheAuthMode(ctx context.Context, userCred mcclient.TokenCredential, elasticcache *SElasticcache, task taskman.ITask) error
|
||||
|
||||
@@ -1764,30 +1764,6 @@ func (self *SManagedVirtualizationRegionDriver) RequestDeleteElasticcache(ctx co
|
||||
return cloudprovider.WaitDeleted(iec, 10*time.Second, 300*time.Second)
|
||||
}
|
||||
|
||||
func (self *SManagedVirtualizationRegionDriver) RequestChangeElasticcacheSpec(ctx context.Context, userCred mcclient.TokenCredential, ec *models.SElasticcache, task taskman.ITask) error {
|
||||
sku, err := task.GetParams().GetString("sku")
|
||||
if err != nil {
|
||||
return errors.Wrap(fmt.Errorf("missing parameter sku"), "managedVirtualizationRegionDriver.RequestChangeElasticcacheSpec")
|
||||
}
|
||||
|
||||
iregion, err := ec.GetIRegion()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "managedVirtualizationRegionDriver.RequestChangeElasticcacheSpec.GetIRegion")
|
||||
}
|
||||
|
||||
iec, err := iregion.GetIElasticcacheById(ec.ExternalId)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "managedVirtualizationRegionDriver.RequestChangeElasticcacheSpec.GetIElasticcacheById")
|
||||
}
|
||||
|
||||
err = iec.ChangeInstanceSpec(sku)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "managedVirtualizationRegionDriver.RequestChangeElasticcacheSpec.ChangeInstanceSpec")
|
||||
}
|
||||
|
||||
return cloudprovider.WaitStatusWithDelay(iec, api.ELASTIC_CACHE_STATUS_RUNNING, 10*time.Second, 10*time.Second, 300*time.Second)
|
||||
}
|
||||
|
||||
func (self *SManagedVirtualizationRegionDriver) RequestSetElasticcacheMaintainTime(ctx context.Context, userCred mcclient.TokenCredential, ec *models.SElasticcache, task taskman.ITask) error {
|
||||
mStart, err := task.GetParams().GetString("maintain_start_time")
|
||||
if err != nil {
|
||||
|
||||
@@ -95,9 +95,10 @@ func (self *SElasticcacheManager) RestoreInstance(instanceId string, backupId st
|
||||
}
|
||||
|
||||
// https://support.huaweicloud.com/api-dcs/dcs-zh-api-180423024.html
|
||||
func (self *SElasticcacheManager) ChangeInstanceSpec(instanceId string, newCapacity string) (jsonutils.JSONObject, error) {
|
||||
func (self *SElasticcacheManager) ChangeInstanceSpec(instanceId string, specCode string, newCapacity int64) (jsonutils.JSONObject, error) {
|
||||
params := jsonutils.NewDict()
|
||||
params.Set("new_capacity", jsonutils.NewString(newCapacity))
|
||||
params.Set("new_capacity", jsonutils.NewInt(newCapacity))
|
||||
params.Set("spec_code", jsonutils.NewString(specCode))
|
||||
|
||||
return self.CreateInContextWithSpec(nil, fmt.Sprintf("%s/extend", instanceId), params, "")
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package huawei
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -538,7 +539,12 @@ func (self *SElasticcache) ChangeInstanceSpec(spec string) error {
|
||||
}
|
||||
|
||||
newCapacity := segs[1][1 : len(segs[1])-1]
|
||||
_, err := self.region.ecsClient.Elasticcache.ChangeInstanceSpec(self.GetId(), newCapacity)
|
||||
capacity, err := strconv.Atoi(newCapacity)
|
||||
if err != nil {
|
||||
return errors.Wrap(fmt.Errorf("invalid sku capacity %s", spec), "Elasticcache.ChangeInstanceSpec")
|
||||
}
|
||||
|
||||
_, err = self.region.ecsClient.Elasticcache.ChangeInstanceSpec(self.GetId(), segs[0], int64(capacity))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "elasticcache.ChangeInstanceSpec")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user