mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-01 15:07:17 +08:00
climc: 将xx-list --{provider,manager,account}放到BaseListOptions
This commit is contained in:
@@ -11,36 +11,14 @@ import (
|
||||
func init() {
|
||||
type CloudregionListOptions struct {
|
||||
options.BaseListOptions
|
||||
Private bool `help:"show private cloud regions only"`
|
||||
Public bool `help:"show public cloud regions only"`
|
||||
Manager string `help:"Show regions belongs to the cloud provider"`
|
||||
Provider string `help:"List regions of the public cloud provider" choices:"Aliyun|Qcloud|Azure|Aws|Huawei"`
|
||||
Usable bool `help:"List regions that are usable"`
|
||||
Private *bool `help:"show private cloud regions only" json:"is_private"`
|
||||
Public *bool `help:"show public cloud regions only" json:"is_public"`
|
||||
Usable *bool `help:"List regions that are usable"`
|
||||
}
|
||||
R(&CloudregionListOptions{}, "cloud-region-list", "List cloud regions", func(s *mcclient.ClientSession, args *CloudregionListOptions) error {
|
||||
var params *jsonutils.JSONDict
|
||||
{
|
||||
var err error
|
||||
params, err = args.BaseListOptions.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
}
|
||||
}
|
||||
if args.Usable {
|
||||
params.Add(jsonutils.JSONTrue, "usable")
|
||||
}
|
||||
if args.Private {
|
||||
params.Add(jsonutils.JSONTrue, "is_private")
|
||||
}
|
||||
if args.Public {
|
||||
params.Add(jsonutils.JSONTrue, "is_public")
|
||||
}
|
||||
if len(args.Manager) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Manager), "manager")
|
||||
}
|
||||
if len(args.Provider) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Provider), "provider")
|
||||
R(&CloudregionListOptions{}, "cloud-region-list", "List cloud regions", func(s *mcclient.ClientSession, opts *CloudregionListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.Cloudregions.List(s, params)
|
||||
if err != nil {
|
||||
|
||||
@@ -18,14 +18,10 @@ func init() {
|
||||
Guest string `help:"Guest ID or name"`
|
||||
Storage string `help:"Storage ID or name"`
|
||||
|
||||
Manager string `help:"List disks belongs to the cloud provider"`
|
||||
Account string `help:"List disks belongs to the cloud account"`
|
||||
Provider string `help:"List disks belongs to the provider" choices:"VMware|Aliyun|Qcloud|Azure|Aws|Huawei"`
|
||||
|
||||
BillingType string `help:"billing type" choices:"postpaid|prepaid"`
|
||||
}
|
||||
R(&DiskListOptions{}, "disk-list", "List virtual disks", func(s *mcclient.ClientSession, suboptions *DiskListOptions) error {
|
||||
params, err := options.ListStructToParams(suboptions)
|
||||
R(&DiskListOptions{}, "disk-list", "List virtual disks", func(s *mcclient.ClientSession, opts *DiskListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -10,38 +10,16 @@ import (
|
||||
|
||||
func init() {
|
||||
type ElasticipListOptions struct {
|
||||
Manager string `help:"Show servers imported from manager"`
|
||||
Region string `help:"Show servers in cloudregion"`
|
||||
Account string `help:"List hosts belongs to the cloud account"`
|
||||
Provider string `help:"List hosts belongs to the provider" choices:"VMware|Aliyun|Qcloud|Azure|Aws|Huawei"`
|
||||
Region string `help:"Show servers in cloudregion"`
|
||||
|
||||
Usable bool `help:"List all zones that is usable"`
|
||||
Usable *bool `help:"List all zones that is usable"`
|
||||
|
||||
options.BaseListOptions
|
||||
}
|
||||
R(&ElasticipListOptions{}, "eip-list", "List elastic IPs", func(s *mcclient.ClientSession, args *ElasticipListOptions) error {
|
||||
var params *jsonutils.JSONDict
|
||||
{
|
||||
var err error
|
||||
params, err = args.BaseListOptions.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if len(args.Manager) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Manager), "manager")
|
||||
}
|
||||
if len(args.Account) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Account), "account")
|
||||
}
|
||||
if len(args.Provider) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Provider), "provider")
|
||||
}
|
||||
if len(args.Region) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Region), "region")
|
||||
}
|
||||
if args.Usable {
|
||||
params.Add(jsonutils.JSONTrue, "usable")
|
||||
R(&ElasticipListOptions{}, "eip-list", "List elastic IPs", func(s *mcclient.ClientSession, opts *ElasticipListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
results, err := modules.Elasticips.List(s, params)
|
||||
if err != nil {
|
||||
|
||||
+14
-67
@@ -15,91 +15,38 @@ func init() {
|
||||
Zone string `help:"List hosts in zone"`
|
||||
Region string `help:"List hosts in region"`
|
||||
Wire string `help:"List hosts in wire"`
|
||||
Image string `help:"List hosts cached images"`
|
||||
Image string `help:"List hosts cached images" json:"cachedimage"`
|
||||
Storage string `help:"List hosts attached to storages"`
|
||||
Baremetal string `help:"List hosts that is managed by baremetal system" choices:"true|false"`
|
||||
Empty bool `help:"show empty host"`
|
||||
Occupied bool `help:"show occupid host"`
|
||||
Enabled bool `help:"Show enabled host only"`
|
||||
Disabled bool `help:"Show disabled host only"`
|
||||
Empty bool `help:"show empty host" json:"-"`
|
||||
Occupied bool `help:"show occupid host" json:"-"`
|
||||
Enabled bool `help:"Show enabled host only" json:"-"`
|
||||
Disabled bool `help:"Show disabled host only" json:"-"`
|
||||
HostType string `help:"Host type filter" choices:"baremetal|hypervisor|esxi|kubelet|hyperv|aliyun|azure|qcloud|aws|huawei"`
|
||||
AnyMac string `help:"Mac matches one of the host's interface"`
|
||||
|
||||
ResourceType string `help:"Resource type" choices:"shared|prepaid|dedicated"`
|
||||
|
||||
Manager string `help:"List hosts belongs to the cloud provider"`
|
||||
Account string `help:"List hosts belongs to the cloud account"`
|
||||
Provider string `help:"List hosts belongs to the provider" choices:"VMware|Aliyun|Qcloud|Azure|Aws|Huawei"`
|
||||
|
||||
Usable bool `help:"List all zones that is usable"`
|
||||
Usable *bool `help:"List all zones that is usable"`
|
||||
|
||||
options.BaseListOptions
|
||||
}
|
||||
R(&HostListOptions{}, "host-list", "List hosts", func(s *mcclient.ClientSession, args *HostListOptions) error {
|
||||
var params *jsonutils.JSONDict
|
||||
{
|
||||
var err error
|
||||
params, err = args.BaseListOptions.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
}
|
||||
}
|
||||
if len(args.Schedtag) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Schedtag), "schedtag")
|
||||
}
|
||||
if len(args.Zone) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Zone), "zone")
|
||||
}
|
||||
if len(args.Region) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Region), "region")
|
||||
}
|
||||
if len(args.Wire) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Wire), "wire")
|
||||
}
|
||||
if len(args.Image) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Image), "cachedimage")
|
||||
}
|
||||
if len(args.Storage) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Storage), "storage")
|
||||
}
|
||||
if len(args.Baremetal) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Baremetal), "baremetal")
|
||||
}
|
||||
if len(args.HostType) > 0 {
|
||||
params.Add(jsonutils.NewString(args.HostType), "host_type")
|
||||
}
|
||||
if len(args.ResourceType) > 0 {
|
||||
params.Add(jsonutils.NewString(args.ResourceType), "resource_type")
|
||||
R(&HostListOptions{}, "host-list", "List hosts", func(s *mcclient.ClientSession, opts *HostListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(args.Manager) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Manager), "manager")
|
||||
}
|
||||
if len(args.Account) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Account), "account")
|
||||
}
|
||||
if len(args.Provider) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Provider), "provider")
|
||||
}
|
||||
|
||||
if args.Usable {
|
||||
params.Add(jsonutils.JSONTrue, "usable")
|
||||
}
|
||||
|
||||
if args.Empty {
|
||||
if opts.Empty {
|
||||
params.Add(jsonutils.JSONTrue, "is_empty")
|
||||
} else if args.Occupied {
|
||||
} else if opts.Occupied {
|
||||
params.Add(jsonutils.JSONFalse, "is_empty")
|
||||
}
|
||||
if args.Enabled {
|
||||
if opts.Enabled {
|
||||
params.Add(jsonutils.NewInt(1), "enabled")
|
||||
} else if args.Disabled {
|
||||
} else if opts.Disabled {
|
||||
params.Add(jsonutils.NewInt(0), "enabled")
|
||||
}
|
||||
if len(args.AnyMac) > 0 {
|
||||
params.Add(jsonutils.NewString(args.AnyMac), "any_mac")
|
||||
}
|
||||
result, err := modules.Hosts.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -14,53 +14,19 @@ func init() {
|
||||
options.BaseListOptions
|
||||
Ip string `help:"search networks that contain this IP"`
|
||||
Zone string `help:"search networks in a zone"`
|
||||
Wire string `help:"search networks belongs to a wire"`
|
||||
Wire string `help:"search networks belongs to a wire" json:"-"`
|
||||
Vpc string `help:"search networks belongs to a VPC"`
|
||||
Region string `help:"search networks belongs to a CloudRegion"`
|
||||
Region string `help:"search networks belongs to a CloudRegion" json:"cloudregion"`
|
||||
ServerType string `help:"search networks belongs to a ServerType"`
|
||||
|
||||
Manager string `help:"List networks belongs to the cloud provider"`
|
||||
Account string `help:"List networks belongs to the cloud account"`
|
||||
Provider string `help:"List networks belongs to the provider" choices:"VMware|Aliyun|Qcloud|Azure|Aws|Huawei"`
|
||||
}
|
||||
R(&NetworkListOptions{}, "network-list", "List networks", func(s *mcclient.ClientSession, args *NetworkListOptions) error {
|
||||
var params *jsonutils.JSONDict
|
||||
{
|
||||
var err error
|
||||
params, err = args.BaseListOptions.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
}
|
||||
}
|
||||
if len(args.Ip) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Ip), "ip")
|
||||
}
|
||||
if len(args.Zone) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Zone), "zone")
|
||||
}
|
||||
if len(args.Vpc) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Vpc), "vpc")
|
||||
}
|
||||
if len(args.Region) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Region), "cloudregion")
|
||||
}
|
||||
if len(args.ServerType) > 0 {
|
||||
params.Add(jsonutils.NewString(args.ServerType), "server_type")
|
||||
}
|
||||
if len(args.Manager) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Manager), "manager")
|
||||
}
|
||||
if len(args.Account) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Account), "account")
|
||||
}
|
||||
if len(args.Provider) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Provider), "provider")
|
||||
R(&NetworkListOptions{}, "network-list", "List networks", func(s *mcclient.ClientSession, opts *NetworkListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var result *modules.ListResult
|
||||
var err error
|
||||
if len(args.Wire) > 0 {
|
||||
result, err = modules.Networks.ListInContext(s, params, &modules.Wires, args.Wire)
|
||||
if len(opts.Wire) > 0 {
|
||||
result, err = modules.Networks.ListInContext(s, params, &modules.Wires, opts.Wire)
|
||||
} else {
|
||||
result, err = modules.Networks.List(s, params)
|
||||
}
|
||||
|
||||
+5
-14
@@ -1,8 +1,6 @@
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
@@ -11,24 +9,17 @@ import (
|
||||
func init() {
|
||||
type ServerSkusListOptions struct {
|
||||
options.BaseListOptions
|
||||
Provider string `help:"provider" choices:"all|aliyun|azure|aws|qcloud|huawei" default:""`
|
||||
Region string `help:"region Id or name"`
|
||||
Zone string `help:"zone Id or name"`
|
||||
Cpu int `help:"Cpu core count"`
|
||||
Mem int `help:"Memory size in MB"`
|
||||
Name string `help:"Name of Sku"`
|
||||
Region string `help:"region Id or name"`
|
||||
Zone string `help:"zone Id or name"`
|
||||
Cpu int `help:"Cpu core count" json:"cpu_core_count"`
|
||||
Mem int `help:"Memory size in MB" json:"memory_size_mb"`
|
||||
Name string `help:"Name of Sku"`
|
||||
}
|
||||
R(&ServerSkusListOptions{}, "server-sku-list", "List all avaiable Server SKU", func(s *mcclient.ClientSession, args *ServerSkusListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if args.Cpu > 0 {
|
||||
params.Add(jsonutils.NewInt(int64(args.Cpu)), "cpu_core_count")
|
||||
}
|
||||
if args.Mem > 0 {
|
||||
params.Add(jsonutils.NewInt(int64(args.Mem)), "memory_size_mb")
|
||||
}
|
||||
results, err := modules.ServerSkus.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -10,46 +10,17 @@ import (
|
||||
func init() {
|
||||
type SnapshotsListOptions struct {
|
||||
options.BaseListOptions
|
||||
Disk string `help:"Disk snapshots"`
|
||||
Disk string `help:"Disk snapshots" json:"disk_id"`
|
||||
FakeDeleted bool `help:"Show fake deleted snapshot or not"`
|
||||
Local bool `help:"Show local snapshots"`
|
||||
Share bool `help:"Show shared snapshots"`
|
||||
Local *bool `help:"Show local snapshots"`
|
||||
Share *bool `help:"Show shared snapshots"`
|
||||
DiskType string `help:"Filter by disk type" choices:"sys|data"`
|
||||
|
||||
Manager string `help:"Show snapshots belongs to a specific cloud provider"`
|
||||
Account string `help:"List hosts belongs to the cloud account"`
|
||||
Provider string `help:"List hosts belongs to the provider" choices:"VMware|Aliyun|Qcloud|Azure|Aws|Huawei"`
|
||||
}
|
||||
R(&SnapshotsListOptions{}, "snapshot-list", "Show snapshots", func(s *mcclient.ClientSession, args *SnapshotsListOptions) error {
|
||||
params, err := args.BaseListOptions.Params()
|
||||
params, err := options.ListStructToParams(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(args.Disk) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Disk), "disk_id")
|
||||
}
|
||||
params.Add(jsonutils.NewBool(args.FakeDeleted), "fake_deleted")
|
||||
if args.Local {
|
||||
params.Add(jsonutils.NewBool(args.Local), "local")
|
||||
}
|
||||
if args.Share {
|
||||
params.Add(jsonutils.NewBool(args.Share), "share")
|
||||
}
|
||||
if len(args.Disk) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Disk), "disk_id")
|
||||
}
|
||||
if len(args.DiskType) > 0 {
|
||||
params.Add(jsonutils.NewString(args.DiskType), "disk_type")
|
||||
}
|
||||
if len(args.Provider) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Provider), "provider")
|
||||
}
|
||||
if len(args.Manager) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Manager), "manager")
|
||||
}
|
||||
if len(args.Account) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Account), "account")
|
||||
}
|
||||
result, err := modules.Snapshots.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -10,24 +10,12 @@ import (
|
||||
func init() {
|
||||
type StoragecacheListOptions struct {
|
||||
options.BaseListOptions
|
||||
|
||||
Manager string `help:"Show regions belongs to the cloud provider"`
|
||||
}
|
||||
R(&StoragecacheListOptions{}, "storage-cache-list", "List storage caches", func(s *mcclient.ClientSession, args *StoragecacheListOptions) error {
|
||||
var params *jsonutils.JSONDict
|
||||
{
|
||||
var err error
|
||||
params, err = args.BaseListOptions.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
}
|
||||
R(&StoragecacheListOptions{}, "storage-cache-list", "List storage caches", func(s *mcclient.ClientSession, opts *StoragecacheListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(args.Manager) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Manager), "manager")
|
||||
}
|
||||
|
||||
result, err := modules.Storagecaches.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
+10
-43
@@ -12,53 +12,20 @@ import (
|
||||
func init() {
|
||||
type StorageListOptions struct {
|
||||
options.BaseListOptions
|
||||
Share bool `help:"Share storage list"`
|
||||
Local bool `help:"Local storage list"`
|
||||
Usable bool `help:"Usable storage list"`
|
||||
Zone string `help:"List storages in zone"`
|
||||
Share *bool `help:"Share storage list"`
|
||||
Local *bool `help:"Local storage list"`
|
||||
Usable *bool `help:"Usable storage list"`
|
||||
Zone string `help:"List storages in zone" json:"-"`
|
||||
Region string `help:"List storages in region"`
|
||||
|
||||
Manager string `help:"List storages belongs to the cloud provider"`
|
||||
Account string `help:"List storages belongs to the cloud account"`
|
||||
Provider string `help:"List storages belongs to the provider" choices:"VMware|Aliyun|Qcloud|Azure|Aws|Huawei"`
|
||||
}
|
||||
R(&StorageListOptions{}, "storage-list", "List storages", func(s *mcclient.ClientSession, args *StorageListOptions) error {
|
||||
var params *jsonutils.JSONDict
|
||||
{
|
||||
var err error
|
||||
params, err = args.BaseListOptions.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
}
|
||||
R(&StorageListOptions{}, "storage-list", "List storages", func(s *mcclient.ClientSession, opts *StorageListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if args.Share {
|
||||
params.Add(jsonutils.JSONTrue, "share")
|
||||
}
|
||||
if args.Local {
|
||||
params.Add(jsonutils.JSONTrue, "local")
|
||||
}
|
||||
if args.Usable {
|
||||
params.Add(jsonutils.JSONTrue, "usable")
|
||||
}
|
||||
if len(args.Region) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Region), "region")
|
||||
}
|
||||
|
||||
if len(args.Manager) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Manager), "manager")
|
||||
}
|
||||
if len(args.Account) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Account), "account")
|
||||
}
|
||||
if len(args.Provider) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Provider), "provider")
|
||||
}
|
||||
|
||||
var result *modules.ListResult
|
||||
var err error
|
||||
if len(args.Zone) > 0 {
|
||||
result, err = modules.Storages.ListInContext(s, params, &modules.Zones, args.Zone)
|
||||
if len(opts.Zone) > 0 {
|
||||
result, err = modules.Storages.ListInContext(s, params, &modules.Zones, opts.Zone)
|
||||
} else {
|
||||
result, err = modules.Storages.List(s, params)
|
||||
}
|
||||
|
||||
+7
-27
@@ -11,37 +11,17 @@ func init() {
|
||||
type VpcListOptions struct {
|
||||
options.BaseListOptions
|
||||
|
||||
Region string `help:"ID or Name of region"`
|
||||
|
||||
Manager string `help:"List vpcs belongs to the cloud provider"`
|
||||
Account string `help:"List vpcs belongs to the cloud account"`
|
||||
Provider string `help:"List vpcs belongs to the public cloud" choices:"Aliyun|Qcloud|Azure|Aws|Huawei"`
|
||||
Region string `help:"ID or Name of region" json:"-"`
|
||||
}
|
||||
R(&VpcListOptions{}, "vpc-list", "List VPCs", func(s *mcclient.ClientSession, args *VpcListOptions) error {
|
||||
var params *jsonutils.JSONDict
|
||||
{
|
||||
var err error
|
||||
params, err = args.BaseListOptions.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if len(args.Manager) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Manager), "manager")
|
||||
}
|
||||
if len(args.Account) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Account), "account")
|
||||
}
|
||||
if len(args.Provider) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Provider), "provider")
|
||||
R(&VpcListOptions{}, "vpc-list", "List VPCs", func(s *mcclient.ClientSession, opts *VpcListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var result *modules.ListResult
|
||||
var err error
|
||||
if len(args.Region) > 0 {
|
||||
result, err = modules.Vpcs.ListInContext(s, params, &modules.Cloudregions, args.Region)
|
||||
if len(opts.Region) > 0 {
|
||||
result, err = modules.Vpcs.ListInContext(s, params, &modules.Cloudregions, opts.Region)
|
||||
} else {
|
||||
result, err = modules.Vpcs.List(s, params)
|
||||
}
|
||||
|
||||
@@ -12,43 +12,18 @@ func init() {
|
||||
options.BaseListOptions
|
||||
|
||||
Region string `help:"List hosts in region"`
|
||||
Zone string `help:"list wires in zone"`
|
||||
Zone string `help:"list wires in zone" json:"-"`
|
||||
Vpc string `help:"List wires in vpc"`
|
||||
|
||||
Manager string `help:"List hosts belongs to the cloud provider"`
|
||||
Account string `help:"List hosts belongs to the cloud account"`
|
||||
Provider string `help:"List hosts belongs to the provider" choices:"VMware|Aliyun|Qcloud|Azure|Aws|Huawei"`
|
||||
}
|
||||
R(&WireListOptions{}, "wire-list", "List wires", func(s *mcclient.ClientSession, args *WireListOptions) error {
|
||||
var params *jsonutils.JSONDict
|
||||
{
|
||||
var err error
|
||||
params, err = args.BaseListOptions.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
}
|
||||
}
|
||||
if len(args.Vpc) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Vpc), "vpc")
|
||||
}
|
||||
if len(args.Region) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Region), "region")
|
||||
}
|
||||
if len(args.Manager) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Manager), "manager")
|
||||
}
|
||||
if len(args.Account) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Account), "account")
|
||||
}
|
||||
if len(args.Provider) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Provider), "provider")
|
||||
R(&WireListOptions{}, "wire-list", "List wires", func(s *mcclient.ClientSession, opts *WireListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var result *modules.ListResult
|
||||
var err error
|
||||
if len(args.Zone) > 0 {
|
||||
result, err = modules.Wires.ListInContext(s, params, &modules.Zones, args.Zone)
|
||||
if len(opts.Zone) > 0 {
|
||||
result, err = modules.Wires.ListInContext(s, params, &modules.Zones, opts.Zone)
|
||||
} else {
|
||||
result, err = modules.Wires.List(s, params)
|
||||
}
|
||||
|
||||
@@ -174,6 +174,10 @@ type BaseListOptions struct {
|
||||
ExportFile string `help:"Export to file" metavar:"<EXPORT_FILE_PATH>" json:"-"`
|
||||
ExportKeys string `help:"Export field keys"`
|
||||
ExportTexts string `help:"Export field displayname texts" json:"-"`
|
||||
|
||||
Manager string `help:"List objects belonging to the cloud provider"`
|
||||
Account string `help:"List objects belonging to the cloud account"`
|
||||
Provider string `help:"List objects from the provider" choices:"VMware|Aliyun|Qcloud|Azure|Aws|Huawei"`
|
||||
}
|
||||
|
||||
func (opts *BaseListOptions) Params() (*jsonutils.JSONDict, error) {
|
||||
|
||||
@@ -130,7 +130,6 @@ type RouteTablePurgeOptions struct {
|
||||
}
|
||||
|
||||
type RouteTableListOptions struct {
|
||||
Manager string
|
||||
Vpc string
|
||||
Cloudregion string
|
||||
|
||||
|
||||
@@ -23,10 +23,6 @@ type ServerListOptions struct {
|
||||
WithEip *bool `help:"Show Servers with EIP"`
|
||||
WithoutEip *bool `help:"Show Servers without EIP"`
|
||||
|
||||
Manager string `help:"Show servers imported from manager"`
|
||||
Account string `help:"List hosts belongs to the cloud account"`
|
||||
Provider string `help:"List hosts belongs to the provider" choices:"VMware|Aliyun|Qcloud|Azure|Aws|Huawei"`
|
||||
|
||||
ResourceType string `help:"Resource type" choices:"shared|prepaid|dedicated"`
|
||||
|
||||
BillingType string `help:"billing type" choices:"postpaid|prepaid"`
|
||||
|
||||
Reference in New Issue
Block a user