Merge pull request #5379 from tb365/bugfix/tb-bugfix-0306

Bugfix/tb bugfix 0306
This commit is contained in:
yunion-ci-robot
2020-03-06 18:10:50 +08:00
committed by GitHub
5 changed files with 20 additions and 3 deletions
+1
View File
@@ -103,6 +103,7 @@ func (client *SCtyunClient) fetchRegions() error {
Description: zone.ZoneName,
ID: zone.RegionID,
ParentRegionID: zone.RegionID,
RegionName: zone.ZoneName,
izones: []cloudprovider.ICloudZone{&zone},
}
+2 -1
View File
@@ -35,6 +35,7 @@ type SRegion struct {
client *SCtyunClient
storageCache *SStoragecache
RegionName string
Description string `json:"description"`
ID string `json:"id"`
ParentRegionID string `json:"parent_region_id"`
@@ -162,7 +163,7 @@ func (self *SRegion) GetId() string {
}
func (self *SRegion) GetName() string {
return self.ID
return fmt.Sprintf("%s %s", CLOUD_PROVIDER_CTYUN_CN, self.RegionName)
}
func (self *SRegion) GetGlobalId() string {
+1 -1
View File
@@ -53,7 +53,7 @@ func (self *SZone) GetId() string {
}
func (self *SZone) GetName() string {
return self.ZoneName
return fmt.Sprintf("%s %s", CLOUD_PROVIDER_CTYUN_CN, self.ZoneID)
}
func (self *SZone) GetGlobalId() string {
+11 -1
View File
@@ -69,14 +69,24 @@ func (self *SElasticcacheAccount) ResetPassword(input cloudprovider.SCloudElasti
return fmt.Errorf("elasticcacheAccount.ResetPassword.input OldPassword should not be empty")
}
type ResetPasswordResult struct {
Result string `json:"result"`
Message string `json:"message"`
}
result := ResetPasswordResult{}
params := jsonutils.NewDict()
params.Set("old_password", jsonutils.NewString(*input.OldPassword))
params.Set("new_password", jsonutils.NewString(input.NewPassword))
err := DoUpdateWithSpec(self.cacheDB.region.ecsClient.Elasticcache.UpdateInContextWithSpec, self.cacheDB.GetId(), "password", params)
err := DoUpdateWithSpec2(self.cacheDB.region.ecsClient.Elasticcache.UpdateInContextWithSpec, self.cacheDB.GetId(), "password", params, &result)
if err != nil {
return errors.Wrap(err, "elasticcacheAccount.ResetPassword")
}
if result.Result != "success" {
return errors.Wrap(fmt.Errorf(result.Message), "elasticcacheAccount.ResetPassword")
}
return nil
}
+5
View File
@@ -218,6 +218,11 @@ func DoUpdateWithSpec(updateFunc updateFunc2, id string, spec string, params jso
return err
}
func DoUpdateWithSpec2(updateFunc updateFunc2, id string, spec string, params jsonutils.JSONObject, result interface{}) error {
ret, err := updateFunc(nil, id, spec, params, "")
return unmarshalResult(ret, err, result, "PUT")
}
func DoDelete(deleteFunc deleteFunc, id string, params jsonutils.JSONObject, result interface{}) error {
if len(id) == 0 {
return fmt.Errorf(" id should not be empty")