mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Automatic merge from release/2.1.0 -> release/2.2.0
* commit '3ad67f084545e115a4ed896a57785045bfb12771': zhengjiajie add the post method of project_host
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
/**
|
||||
* move host to one tree-node
|
||||
*/
|
||||
type ProjectHostCreateOptions struct {
|
||||
LABELS string `help:"Labels for tree-node(split by comma)"`
|
||||
HOST_NAME []string `help:"Host names to move to"`
|
||||
}
|
||||
R(&ProjectHostCreateOptions{}, "projecthost-create", "move host to tree-node", func(s *mcclient.ClientSession, args *ProjectHostCreateOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.NewString(args.LABELS), "node_labels")
|
||||
arr := jsonutils.NewArray()
|
||||
if len(args.HOST_NAME) > 0 {
|
||||
for _, f := range args.HOST_NAME {
|
||||
tmpObj := jsonutils.NewDict()
|
||||
tmpObj.Add(jsonutils.NewString(f), "host_name")
|
||||
arr.Add(tmpObj)
|
||||
}
|
||||
}
|
||||
params.Add(arr, "service_hosts")
|
||||
|
||||
rst, err := modules.ProjectHosts.Create(s, params)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printObject(rst)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user