From fb65aa6a3c4d4494b65f69cc43634107672d9410 Mon Sep 17 00:00:00 2001 From: ningyu Date: Fri, 4 Jan 2019 21:15:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=9C=BA=E5=99=A8?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=8F=AF=E4=BB=A5=E6=8C=87=E5=AE=9A=E6=9C=BA?= =?UTF-8?q?=E5=99=A8=E6=98=AF=E5=AE=BF=E4=B8=BB=E6=9C=BA=EF=BC=8C=E8=BF=98?= =?UTF-8?q?=E6=98=AF=E8=99=9A=E6=8B=9F=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/climc/shell/nodes.go | 7 ++++--- pkg/mcclient/modules/mod_nodes.go | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/climc/shell/nodes.go b/cmd/climc/shell/nodes.go index b7a98b7d95..04da28548a 100644 --- a/cmd/climc/shell/nodes.go +++ b/cmd/climc/shell/nodes.go @@ -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 } diff --git a/pkg/mcclient/modules/mod_nodes.go b/pkg/mcclient/modules/mod_nodes.go index 47f2bcab27..82e36dca57 100644 --- a/pkg/mcclient/modules/mod_nodes.go +++ b/pkg/mcclient/modules/mod_nodes.go @@ -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()