mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #885 in YUNIONIO/onecloud from ~NINGYU/onecloud:release/ningyu-node-discovery to release/2.5.0
* commit 'fb65aa6a3c4d4494b65f69cc43634107672d9410': feat: 添加机器时,可以指定机器是宿主机,还是虚拟机
This commit is contained in:
@@ -161,11 +161,12 @@ func init() {
|
||||
})
|
||||
|
||||
type NodeCreateOptions struct {
|
||||
NAME string `help:"Node name"`
|
||||
IP string `help:"Node IP"`
|
||||
NAME string `help:"Node name"`
|
||||
IP string `help:"Node IP"`
|
||||
ResType string `help:"Resource type" choices:"host|guest"`
|
||||
}
|
||||
R(&NodeCreateOptions{}, "node-create", "Create a monitor node record", func(s *mcclient.ClientSession, args *NodeCreateOptions) error {
|
||||
data, err := modules.Nodes.NewNode(s, args.NAME, args.IP)
|
||||
data, err := modules.Nodes.NewNode(s, args.NAME, args.IP, args.ResType)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -58,10 +58,13 @@ func (this *NodeManager) BatchPerformActionInContexts(s *mcclient.ClientSession,
|
||||
}
|
||||
}
|
||||
|
||||
func (this *NodeManager) NewNode(s *mcclient.ClientSession, name string, ip string) (jsonutils.JSONObject, error) {
|
||||
func (this *NodeManager) NewNode(s *mcclient.ClientSession, name string, ip string, res_type string) (jsonutils.JSONObject, error) {
|
||||
data := jsonutils.NewDict()
|
||||
data.Add(jsonutils.NewString(name), "name")
|
||||
data.Add(jsonutils.NewString(ip), "ip")
|
||||
if len(res_type) > 0 {
|
||||
data.Add(jsonutils.NewString(res_type), "res_type")
|
||||
}
|
||||
arr := jsonutils.NewArray()
|
||||
arr.Add(data)
|
||||
params := jsonutils.NewDict()
|
||||
|
||||
Reference in New Issue
Block a user