mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
37 lines
862 B
Go
37 lines
862 B
Go
package shell
|
|
|
|
import (
|
|
"yunion.io/x/onecloud/pkg/util/esxi"
|
|
"yunion.io/x/onecloud/pkg/util/shellutils"
|
|
)
|
|
|
|
func init() {
|
|
type HostListOptions struct {
|
|
DATACENTER string `help:"List hosts in datacenter"`
|
|
}
|
|
shellutils.R(&HostListOptions{}, "host-list", "List hosts in datacenter", func(cli *esxi.SESXiClient, args *HostListOptions) error {
|
|
dc, err := cli.FindDatacenterByMoId(args.DATACENTER)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
hosts, err := dc.GetIHosts()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
printList(hosts, nil)
|
|
return nil
|
|
})
|
|
|
|
type HostShowOptions struct {
|
|
IP string `help:"Host IP"`
|
|
}
|
|
shellutils.R(&HostShowOptions{}, "host-show", "Show details of a host by IP", func(cli *esxi.SESXiClient, args *HostShowOptions) error {
|
|
host, err := cli.FindHostByIp(args.IP)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
printObject(host)
|
|
return nil
|
|
})
|
|
}
|