增加:1.

包年包月主机加入资源池后,如果auto_delete=true,则自动删除该主机 2.
包年包月资源池的宿主机支持续费操作Perform(host.id,
"renew-prepaid-recycle", {"duration": "1m"})
This commit is contained in:
Qiu Jian
2019-01-05 09:51:58 +08:00
parent 16a7306746
commit c477a05f39
11 changed files with 154 additions and 12 deletions
+15
View File
@@ -497,4 +497,19 @@ func init() {
printObject(result)
return nil
})
type PrepaidRecycleHostRenewOptions struct {
ID string `help:"ID or name of server to renew"`
DURATION string `help:"Duration of renew, ADMIN only command"`
}
R(&PrepaidRecycleHostRenewOptions{}, "host-renew-prepaid-recycle", "Renew a prepaid recycle host", func(s *mcclient.ClientSession, args *PrepaidRecycleHostRenewOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.DURATION), "duration")
result, err := modules.Hosts.PerformAction(s, args.ID, "renew-prepaid-recycle", params)
if err != nil {
return err
}
printObject(result)
return nil
})
}
+5 -1
View File
@@ -634,10 +634,14 @@ func init() {
})
type ServerPrepaidRecycleOptions struct {
ID string `help:"ID or name of server to recycle"`
ID string `help:"ID or name of server to recycle"`
AutoDelete bool `help:"after joining the pool, remove the server automatically"`
}
R(&ServerPrepaidRecycleOptions{}, "server-enable-recycle", "Put a prepaid server into recycle pool, so that it can be shared", func(s *mcclient.ClientSession, args *ServerPrepaidRecycleOptions) error {
params := jsonutils.NewDict()
if args.AutoDelete {
params.Add(jsonutils.JSONTrue, "auto_delete")
}
result, err := modules.Servers.PerformAction(s, args.ID, "prepaid-recycle", params)
if err != nil {
return err