mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-05-23 21:11:02 +08:00
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package shell
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"yunion.io/x/onecloud/pkg/util/openstack"
|
|
"yunion.io/x/onecloud/pkg/util/shellutils"
|
|
)
|
|
|
|
func init() {
|
|
type InstanceListOptions struct {
|
|
ZoneID string `help:"Zone ID for filter instance list"`
|
|
Host string `help:"Host name for filter instance list"`
|
|
}
|
|
shellutils.R(&InstanceListOptions{}, "instance-list", "List instances", func(cli *openstack.SRegion, args *InstanceListOptions) error {
|
|
instances, err := cli.GetInstances(args.ZoneID, args.Host)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
printList(instances, 0, 0, 0, nil)
|
|
return nil
|
|
})
|
|
|
|
type InstanceOptions struct {
|
|
ID string `help:"Instance ID"`
|
|
}
|
|
shellutils.R(&InstanceOptions{}, "instance-show", "Show instance", func(cli *openstack.SRegion, args *InstanceOptions) error {
|
|
instance, err := cli.GetInstance(args.ID)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
printObject(instance)
|
|
return nil
|
|
})
|
|
|
|
shellutils.R(&InstanceOptions{}, "instance-vnc", "Show instance vnc url", func(cli *openstack.SRegion, args *InstanceOptions) error {
|
|
url, err := cli.GetInstanceVNCUrl(args.ID)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
fmt.Println(url)
|
|
return nil
|
|
})
|
|
|
|
}
|