Merge pull request #1191 in YUNIONIO/onecloud from ~QIUJIAN/onecloud:hotfix/qj-host-renew-prepaid-recycle-sanity-check to release/2.6.0

* commit 'e62ceb5007e57d71e4f049640528b91a20ae86f6':
  show expired_at colume for host
  fix: validate host status before doing renew prepaid recycle
This commit is contained in:
邱剑
2019-03-08 21:07:05 +08:00
2 changed files with 12 additions and 1 deletions
+9
View File
@@ -688,6 +688,15 @@ func (self *SHost) AllowPerformRenewPrepaidRecycle(ctx context.Context, userCred
}
func (self *SHost) PerformRenewPrepaidRecycle(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
if !self.IsPrepaidRecycle() {
return nil, httperrors.NewInputParameterError("Not a prepaid recycle host")
}
if len(self.RealExternalId) == 0 {
return nil, httperrors.NewGeneralError(fmt.Errorf("host RealExternalId is empty"))
}
if len(self.ExternalId) == 0 {
return nil, httperrors.NewGeneralError(fmt.Errorf("host ExternalId is empty"))
}
durationStr := jsonutils.GetAnyString(data, []string{"duration"})
if len(durationStr) == 0 {
return nil, httperrors.NewMissingParameterError("duration")
+3 -1
View File
@@ -177,7 +177,9 @@ func init() {
"mem_commit_rate", "cpu_commit_bound",
"mem_commit_bound", "node_count", "sn", "storage_type",
"host_type", "version", "schedtags",
"storage_size"},
"storage_size",
"expired_at",
},
[]string{})}
registerCompute(&Hosts)
}