From 27d4fab976906e68010503de30452ebfb95783f8 Mon Sep 17 00:00:00 2001 From: Qiu Jian Date: Fri, 3 Aug 2018 22:30:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0host-enable-netif=E5=92=8Chos?= =?UTF-8?q?t-disable-netif=E4=B8=A4=E4=B8=AA=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/climc/shell/hosts.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/cmd/climc/shell/hosts.go b/cmd/climc/shell/hosts.go index e4c2300938..062074928b 100644 --- a/cmd/climc/shell/hosts.go +++ b/cmd/climc/shell/hosts.go @@ -388,6 +388,40 @@ func init() { return nil }) + type HostEnableNetIfOptions struct { + ID string `help:"ID or Name of host"` + MAC string `help:"MAC of NIC to enable"` + } + R(&HostEnableNetIfOptions{}, "host-enable-netif", "Enable a network interface for a host", func(s *mcclient.ClientSession, args *HostEnableNetIfOptions) error { + params := jsonutils.NewDict() + params.Add(jsonutils.NewString(args.MAC), "mac") + result, err := modules.Hosts.PerformAction(s, args.ID, "enable-netif", params) + if err != nil { + return err + } + printObject(result) + return nil + }) + + type HostDisableNetIfOptions struct { + ID string `help:"ID or Name of host"` + MAC string `help:"MAC of NIC to disable"` + Reserve bool `help:"Reserve the IP address"` + } + R(&HostDisableNetIfOptions{}, "host-disable-netif", "Disable a network interface", func(s *mcclient.ClientSession, args *HostDisableNetIfOptions) error { + params := jsonutils.NewDict() + params.Add(jsonutils.NewString(args.MAC), "mac") + if args.Reserve { + params.Add(jsonutils.JSONTrue, "reserve") + } + result, err := modules.Hosts.PerformAction(s, args.ID, "disable-netif", params) + if err != nil { + return err + } + printObject(result) + return nil + }) + R(&HostDetailOptions{}, "host-remove-all-netifs", "Remvoe all netifs expect admin&ipmi netifs", func(s *mcclient.ClientSession, args *HostDetailOptions) error { result, err := modules.Hosts.PerformAction(s, args.ID, "remove-all-netifs", nil) if err != nil {