mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
huawei reset password bugfix
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user