From 60c40963597eae8a1bfca52ffa253b22ee5c7a00 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Thu, 30 Aug 2018 02:29:55 +0000 Subject: [PATCH] climc: use BaseListOptions from mcclient/options --- cmd/climc/shell/alarmlogs.go | 8 +- cmd/climc/shell/alarms.go | 13 ++- cmd/climc/shell/alarmtemplates.go | 13 ++- cmd/climc/shell/baremetalnetworks.go | 14 ++- cmd/climc/shell/baremetalstorages.go | 14 ++- cmd/climc/shell/cachedimages.go | 14 ++- cmd/climc/shell/cloudproviders.go | 13 ++- cmd/climc/shell/cloudregions.go | 13 ++- cmd/climc/shell/contactgroups.go | 14 ++- cmd/climc/shell/contacts.go | 25 ++++- cmd/climc/shell/disks.go | 13 ++- cmd/climc/shell/dnsrecords.go | 13 ++- cmd/climc/shell/hostcachedimages.go | 13 ++- cmd/climc/shell/hosts.go | 13 ++- cmd/climc/shell/hoststorages.go | 13 ++- cmd/climc/shell/hostwires.go | 13 ++- cmd/climc/shell/instances.go | 14 ++- cmd/climc/shell/isolatedevices.go | 13 ++- cmd/climc/shell/k8s/clusters.go | 18 +++- cmd/climc/shell/k8s/k8s.go | 7 -- cmd/climc/shell/k8s/nodes.go | 16 +++- cmd/climc/shell/k8s/repos.go | 13 ++- cmd/climc/shell/keypairs.go | 13 ++- cmd/climc/shell/labels.go | 13 ++- cmd/climc/shell/metrics.go | 38 ++++++-- cmd/climc/shell/monitor_types.go | 14 ++- cmd/climc/shell/monitorinputs.go | 26 ++++- cmd/climc/shell/monitortemplates.go | 25 ++++- cmd/climc/shell/networks.go | 13 ++- cmd/climc/shell/nodes.go | 13 ++- cmd/climc/shell/notification.go | 3 +- cmd/climc/shell/operations.go | 13 ++- cmd/climc/shell/processes.go | 14 ++- cmd/climc/shell/processlogs.go | 14 ++- cmd/climc/shell/project_admin.go | 14 ++- cmd/climc/shell/project_admin_candidates.go | 14 ++- cmd/climc/shell/rates.go | 13 ++- cmd/climc/shell/recipient.go | 13 ++- cmd/climc/shell/reservedips.go | 13 ++- cmd/climc/shell/resource_details.go | 13 ++- cmd/climc/shell/resource_fees.go | 13 ++- cmd/climc/shell/schedtaghosts.go | 14 ++- cmd/climc/shell/schedtags.go | 13 ++- cmd/climc/shell/secgrouprules.go | 13 ++- cmd/climc/shell/secgroups.go | 13 ++- cmd/climc/shell/serverdisks.go | 13 ++- cmd/climc/shell/servernetworks.go | 13 ++- cmd/climc/shell/service_hosts.go | 13 ++- cmd/climc/shell/service_name_suggestions.go | 14 ++- cmd/climc/shell/servicetrees.go | 13 ++- cmd/climc/shell/shell.go | 101 -------------------- cmd/climc/shell/specs.go | 37 +++++-- cmd/climc/shell/storagecachedimages.go | 13 ++- cmd/climc/shell/storagecaches.go | 13 ++- cmd/climc/shell/storages.go | 13 ++- cmd/climc/shell/tasks.go | 24 ++++- cmd/climc/shell/treenodes.go | 13 ++- cmd/climc/shell/vcenters.go | 13 ++- cmd/climc/shell/vpcs.go | 13 ++- cmd/climc/shell/wires.go | 13 ++- cmd/climc/shell/zones.go | 13 ++- 61 files changed, 730 insertions(+), 247 deletions(-) diff --git a/cmd/climc/shell/alarmlogs.go b/cmd/climc/shell/alarmlogs.go index 9ceb4c8398..ef6f68e2c6 100644 --- a/cmd/climc/shell/alarmlogs.go +++ b/cmd/climc/shell/alarmlogs.go @@ -7,6 +7,7 @@ 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" ) func init() { @@ -15,7 +16,7 @@ func init() { * 列出报警日志 */ type AlarmLogListOptions struct { - BaseListOptions + options.BaseListOptions Host string `help:"Name of the host"` Id int64 `help:"ID of tree node"` Label []string `help:"Labels to this tree node"` @@ -26,7 +27,10 @@ func init() { ThisTimeUntil string `help:"This time until the alarm event"` } R(&AlarmLogListOptions{}, "alarmlog-list", "List all alarm's event", func(s *mcclient.ClientSession, args *AlarmLogListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + params, err := args.BaseListOptions.Params() + if err != nil { + return err + } if len(args.Host) > 0 { params.Add(jsonutils.NewString(args.Host), "host") } diff --git a/cmd/climc/shell/alarms.go b/cmd/climc/shell/alarms.go index 876fbdb714..f321805f96 100644 --- a/cmd/climc/shell/alarms.go +++ b/cmd/climc/shell/alarms.go @@ -5,6 +5,7 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modules" + "yunion.io/x/onecloud/pkg/mcclient/options" ) func init() { @@ -116,10 +117,18 @@ func init() { * 列出报警规则 */ type AlarmListOptions struct { - BaseListOptions + options.BaseListOptions } R(&AlarmListOptions{}, "alarm-list", "List all alarms", func(s *mcclient.ClientSession, args *AlarmListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.Alarms.List(s, params) if err != nil { return err diff --git a/cmd/climc/shell/alarmtemplates.go b/cmd/climc/shell/alarmtemplates.go index fe5e88f93a..a1e474248a 100644 --- a/cmd/climc/shell/alarmtemplates.go +++ b/cmd/climc/shell/alarmtemplates.go @@ -7,6 +7,7 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modules" + "yunion.io/x/onecloud/pkg/mcclient/options" ) func init() { @@ -78,12 +79,20 @@ func init() { * 列出报警模板 */ type AlarmTemplateListOptions struct { - BaseListOptions + options.BaseListOptions LIST_TYPE string `help:"Type of list: avaliable|applied|created "` LABELS string `help:"Labels for node(split by comma)"` } R(&AlarmTemplateListOptions{}, "alarmtemplate-list", "List all alarm templates ", func(s *mcclient.ClientSession, args *AlarmTemplateListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } params.Add(jsonutils.NewString(args.LIST_TYPE), "type") params.Add(jsonutils.NewString(args.LABELS), "node_labels") diff --git a/cmd/climc/shell/baremetalnetworks.go b/cmd/climc/shell/baremetalnetworks.go index e50649b058..24a3ef65bf 100644 --- a/cmd/climc/shell/baremetalnetworks.go +++ b/cmd/climc/shell/baremetalnetworks.go @@ -2,19 +2,27 @@ 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" ) func init() { type HostNetworkListOptions struct { - BaseListOptions + options.BaseListOptions Host string `help:"ID or Name of Host"` Network string `help:"ID or name of network"` } R(&HostNetworkListOptions{}, "host-network-list", "List baremetal network pairs", func(s *mcclient.ClientSession, args *HostNetworkListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } if len(args.Network) > 0 { params.Add(jsonutils.NewString(args.Network), "network_id") } diff --git a/cmd/climc/shell/baremetalstorages.go b/cmd/climc/shell/baremetalstorages.go index d2ff553bad..28a4705aa3 100644 --- a/cmd/climc/shell/baremetalstorages.go +++ b/cmd/climc/shell/baremetalstorages.go @@ -1,17 +1,27 @@ 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" ) func init() { type BaremetalStorageListOptions struct { - BaseListOptions + options.BaseListOptions Host string `help:"ID or Name of Host"` } R(&BaremetalStorageListOptions{}, "baremetal-storage-list", "List baremetal storage pairs", func(s *mcclient.ClientSession, args *BaremetalStorageListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } var result *modules.ListResult var err error if len(args.Host) > 0 { diff --git a/cmd/climc/shell/cachedimages.go b/cmd/climc/shell/cachedimages.go index 8f0da36818..0e2323086a 100644 --- a/cmd/climc/shell/cachedimages.go +++ b/cmd/climc/shell/cachedimages.go @@ -1,16 +1,26 @@ 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" ) func init() { type CachedImageListOptions struct { - BaseListOptions + options.BaseListOptions } R(&CachedImageListOptions{}, "cached-image-list", "List cached images", func(s *mcclient.ClientSession, args *CachedImageListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.Cachedimages.List(s, params) if err != nil { return err diff --git a/cmd/climc/shell/cloudproviders.go b/cmd/climc/shell/cloudproviders.go index 36c986ddf2..38e36bd697 100644 --- a/cmd/climc/shell/cloudproviders.go +++ b/cmd/climc/shell/cloudproviders.go @@ -5,15 +5,24 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modules" + "yunion.io/x/onecloud/pkg/mcclient/options" ) func init() { type CloudproviderListOptions struct { - BaseListOptions + options.BaseListOptions } R(&CloudproviderListOptions{}, "cloud-provider-list", "List cloud providers", func(s *mcclient.ClientSession, args *CloudproviderListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.Cloudproviders.List(s, params) if err != nil { return err diff --git a/cmd/climc/shell/cloudregions.go b/cmd/climc/shell/cloudregions.go index 3093838000..48223281d7 100644 --- a/cmd/climc/shell/cloudregions.go +++ b/cmd/climc/shell/cloudregions.go @@ -5,18 +5,27 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modules" + "yunion.io/x/onecloud/pkg/mcclient/options" ) func init() { type CloudregionListOptions struct { - BaseListOptions + 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"` Usable bool `help:"List regions that are usable"` } R(&CloudregionListOptions{}, "cloud-region-list", "List cloud regions", func(s *mcclient.ClientSession, args *CloudregionListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + 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") } diff --git a/cmd/climc/shell/contactgroups.go b/cmd/climc/shell/contactgroups.go index db2af9df11..9841ffaa8f 100644 --- a/cmd/climc/shell/contactgroups.go +++ b/cmd/climc/shell/contactgroups.go @@ -1,8 +1,10 @@ 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" ) func init() { @@ -11,10 +13,18 @@ func init() { * 获得一个全部通信地址组 */ type ContactGroupsListOptions struct { - BaseListOptions + options.BaseListOptions } R(&ContactGroupsListOptions{}, "contact-group-list", "List all contact groups for all the domainsconta", func(s *mcclient.ClientSession, args *ContactGroupsListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.ContactGroups.List(s, params) if err != nil { diff --git a/cmd/climc/shell/contacts.go b/cmd/climc/shell/contacts.go index 69b000f0fa..bde3f7f035 100644 --- a/cmd/climc/shell/contacts.go +++ b/cmd/climc/shell/contacts.go @@ -5,6 +5,7 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modules" + "yunion.io/x/onecloud/pkg/mcclient/options" ) func init() { @@ -70,10 +71,18 @@ func init() { * 获得所有用户的所有通信地址列表 */ type ContactsListOptions struct { - BaseListOptions + options.BaseListOptions } R(&ContactsListOptions{}, "contact-list", "List all contacts for all users", func(s *mcclient.ClientSession, args *ContactsListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.Contacts.List(s, params) if err != nil { @@ -88,11 +97,19 @@ func init() { * 获得一个用户全部通信地址 */ type ContactsListForUserOptions struct { - BaseListOptions + options.BaseListOptions UID string `help:"The user you wanna find contact from (Keystone User ID)"` } R(&ContactsListForUserOptions{}, "contact-show", "List all contacts for the users", func(s *mcclient.ClientSession, args *ContactsListForUserOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.Contacts.Get(s, args.UID, params) if err != nil { diff --git a/cmd/climc/shell/disks.go b/cmd/climc/shell/disks.go index 3f4d35033b..131224c7c7 100644 --- a/cmd/climc/shell/disks.go +++ b/cmd/climc/shell/disks.go @@ -5,11 +5,12 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modules" + "yunion.io/x/onecloud/pkg/mcclient/options" ) func init() { type DiskListOptions struct { - BaseListOptions + options.BaseListOptions Unused bool `help:"Show unused disks"` Share bool `help:"Show Share storage disks"` Local bool `help:"Show Local storage disks"` @@ -17,7 +18,15 @@ func init() { Storage string `help:"Storage ID or name"` } R(&DiskListOptions{}, "disk-list", "List virtual disks", func(s *mcclient.ClientSession, suboptions *DiskListOptions) error { - params := FetchPagingParams(suboptions.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = suboptions.BaseListOptions.Params() + if err != nil { + return err + + } + } if suboptions.Unused { params.Add(jsonutils.JSONTrue, "unused") } diff --git a/cmd/climc/shell/dnsrecords.go b/cmd/climc/shell/dnsrecords.go index 05185894ef..f856a11603 100644 --- a/cmd/climc/shell/dnsrecords.go +++ b/cmd/climc/shell/dnsrecords.go @@ -7,6 +7,7 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modules" + "yunion.io/x/onecloud/pkg/mcclient/options" ) type DNSRecordOptions struct { @@ -38,10 +39,18 @@ func parseDNSRecords(args *DNSRecordOptions, params *jsonutils.JSONDict) { func init() { type DNSListOptions struct { - BaseListOptions + options.BaseListOptions } R(&DNSListOptions{}, "dns-list", "List dns records", func(s *mcclient.ClientSession, suboptions *DNSListOptions) error { - params := FetchPagingParams(suboptions.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = suboptions.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.DNSRecords.List(s, params) if err != nil { return err diff --git a/cmd/climc/shell/hostcachedimages.go b/cmd/climc/shell/hostcachedimages.go index fbfa6cc69c..0eeb17cea6 100644 --- a/cmd/climc/shell/hostcachedimages.go +++ b/cmd/climc/shell/hostcachedimages.go @@ -4,16 +4,25 @@ 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" ) func init() { type HostCachedImageListOptions struct { - BaseListOptions + options.BaseListOptions Host string `help:"ID or Name of Host"` Image string `help:"ID or Name of image"` } R(&HostCachedImageListOptions{}, "host-cachedimage-list", "List host cached image pairs", func(s *mcclient.ClientSession, args *HostCachedImageListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } var result *modules.ListResult var err error if len(args.Host) > 0 { diff --git a/cmd/climc/shell/hosts.go b/cmd/climc/shell/hosts.go index 1f12bc8433..c7a44ccf07 100644 --- a/cmd/climc/shell/hosts.go +++ b/cmd/climc/shell/hosts.go @@ -6,6 +6,7 @@ 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" ) func init() { @@ -26,10 +27,18 @@ func init() { Manager string `help:"Show regions belongs to the cloud provider"` - BaseListOptions + options.BaseListOptions } R(&HostListOptions{}, "host-list", "List hosts", func(s *mcclient.ClientSession, args *HostListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + 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") } diff --git a/cmd/climc/shell/hoststorages.go b/cmd/climc/shell/hoststorages.go index 3085b10d0a..88d25a21a9 100644 --- a/cmd/climc/shell/hoststorages.go +++ b/cmd/climc/shell/hoststorages.go @@ -4,16 +4,25 @@ 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" ) func init() { type HostStorageListOptions struct { - BaseListOptions + options.BaseListOptions Host string `help:"ID or Name of Host"` Storage string `help:"ID or Name of Storage"` } R(&HostStorageListOptions{}, "host-storage-list", "List host storage pairs", func(s *mcclient.ClientSession, args *HostStorageListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } var result *modules.ListResult var err error if len(args.Storage) > 0 { diff --git a/cmd/climc/shell/hostwires.go b/cmd/climc/shell/hostwires.go index f27163f1a0..acc6e9bf3f 100644 --- a/cmd/climc/shell/hostwires.go +++ b/cmd/climc/shell/hostwires.go @@ -4,16 +4,25 @@ 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" ) func init() { type HostWireListOptions struct { - BaseListOptions + options.BaseListOptions Host string `help:"ID or Name of Host"` Wire string `help:"ID or Name of Wire"` } R(&HostWireListOptions{}, "host-wire-list", "List host wire", func(s *mcclient.ClientSession, args *HostWireListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } var result *modules.ListResult var err error if len(args.Host) > 0 { diff --git a/cmd/climc/shell/instances.go b/cmd/climc/shell/instances.go index ce2f6a7c70..2453a7939f 100644 --- a/cmd/climc/shell/instances.go +++ b/cmd/climc/shell/instances.go @@ -1,16 +1,26 @@ 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" ) func init() { type InstanceListOptions struct { - BaseListOptions + options.BaseListOptions } R(&InstanceListOptions{}, "instance-list", "List instances", func(s *mcclient.ClientSession, suboptions *InstanceListOptions) error { - params := FetchPagingParams(suboptions.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = suboptions.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.Instances.List(s, params) if err != nil { return err diff --git a/cmd/climc/shell/isolatedevices.go b/cmd/climc/shell/isolatedevices.go index 65ddfddc19..8b4c3e8da1 100644 --- a/cmd/climc/shell/isolatedevices.go +++ b/cmd/climc/shell/isolatedevices.go @@ -4,17 +4,26 @@ 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" ) func init() { type DeviceListOptions struct { - BaseListOptions + options.BaseListOptions Unused bool `help:"Only show unused devices"` Gpu bool `help:"Only show gpu devices"` Host string `help:"Host ID or Name"` } R(&DeviceListOptions{}, "isolated-device-list", "List isolated devices like GPU", func(s *mcclient.ClientSession, args *DeviceListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } if len(args.Host) > 0 { params.Add(jsonutils.NewString(args.Host), "host") } diff --git a/cmd/climc/shell/k8s/clusters.go b/cmd/climc/shell/k8s/clusters.go index 96d203d294..bd290b8ecf 100644 --- a/cmd/climc/shell/k8s/clusters.go +++ b/cmd/climc/shell/k8s/clusters.go @@ -6,10 +6,10 @@ import ( "strings" "yunion.io/x/jsonutils" - "yunion.io/x/pkg/util/sets" - "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modules/k8s" + "yunion.io/x/onecloud/pkg/mcclient/options" + "yunion.io/x/pkg/util/sets" ) func initCluster() { @@ -17,11 +17,19 @@ func initCluster() { return resourceCmdN("cluster", suffix) } type listOpt struct { - BaseListOptions + options.BaseListOptions } R(&listOpt{}, cmdN("list"), "List k8s clusters", func(s *mcclient.ClientSession, args *listOpt) error { - args.Details = true - params := FetchPagingParams(args.BaseListOptions) + args.Details = options.Bool(true) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := k8s.Clusters.List(s, params) if err != nil { return err diff --git a/cmd/climc/shell/k8s/k8s.go b/cmd/climc/shell/k8s/k8s.go index 9449483ddf..3b8dc9d72c 100644 --- a/cmd/climc/shell/k8s/k8s.go +++ b/cmd/climc/shell/k8s/k8s.go @@ -4,7 +4,6 @@ import ( "fmt" "yunion.io/x/jsonutils" - "yunion.io/x/onecloud/cmd/climc/shell" "yunion.io/x/onecloud/pkg/mcclient/modules" "yunion.io/x/onecloud/pkg/mcclient/modules/k8s" @@ -30,8 +29,6 @@ func init() { initService() } -type BaseListOptions shell.BaseListOptions - type clusterBaseOptions struct { Cluster string `default:"$K8S_CLUSTER|default" help:"Kubernetes cluster name"` } @@ -99,10 +96,6 @@ var ( printBatchResults = printutils.PrintJSONBatchResults ) -func FetchPagingParams(o BaseListOptions) *jsonutils.JSONDict { - return shell.FetchPagingParams(shell.BaseListOptions(o)) -} - func resourceCmdN(prefix, suffix string) string { return fmt.Sprintf("k8s-%s-%s", prefix, suffix) } diff --git a/cmd/climc/shell/k8s/nodes.go b/cmd/climc/shell/k8s/nodes.go index 9ad1510472..59af25159b 100644 --- a/cmd/climc/shell/k8s/nodes.go +++ b/cmd/climc/shell/k8s/nodes.go @@ -7,6 +7,7 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modules/k8s" + "yunion.io/x/onecloud/pkg/mcclient/options" ) func initNode() { @@ -14,14 +15,19 @@ func initNode() { return resourceCmdN("node", suffix) } type listOpt struct { - BaseListOptions + options.BaseListOptions Cluster string `help:"Filter by cluster"` } R(&listOpt{}, cmdN("list"), "List k8s node", func(s *mcclient.ClientSession, args *listOpt) error { - args.Details = true - params := FetchPagingParams(args.BaseListOptions) - if args.Cluster != "" { - params.Add(jsonutils.NewString(args.Cluster), "cluster") + args.Details = options.Bool(true) + var params *jsonutils.JSONDict + { + var err error + params, err = options.ListStructToParams(args) + if err != nil { + return err + + } } result, err := k8s.Nodes.List(s, params) if err != nil { diff --git a/cmd/climc/shell/k8s/repos.go b/cmd/climc/shell/k8s/repos.go index ee34d8a2f9..1c94ee8b4a 100644 --- a/cmd/climc/shell/k8s/repos.go +++ b/cmd/climc/shell/k8s/repos.go @@ -5,6 +5,7 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modules/k8s" + "yunion.io/x/onecloud/pkg/mcclient/options" ) func initRepo() { @@ -12,10 +13,18 @@ func initRepo() { return resourceCmdN("repo", suffix) } type listOpt struct { - BaseListOptions + options.BaseListOptions } R(&listOpt{}, cmdN("list"), "List k8s global helm repos", func(s *mcclient.ClientSession, args *listOpt) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := k8s.Repos.List(s, params) if err != nil { return err diff --git a/cmd/climc/shell/keypairs.go b/cmd/climc/shell/keypairs.go index d56d2122a2..a45abec9c4 100644 --- a/cmd/climc/shell/keypairs.go +++ b/cmd/climc/shell/keypairs.go @@ -7,15 +7,24 @@ 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" ) func init() { type KeypairList struct { - BaseListOptions + options.BaseListOptions } R(&KeypairList{}, "keypair-list", "List keypairs.", func(s *mcclient.ClientSession, args *KeypairList) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.Keypairs.List(s, params) if err != nil { diff --git a/cmd/climc/shell/labels.go b/cmd/climc/shell/labels.go index 9a0a96e242..169111bd2d 100644 --- a/cmd/climc/shell/labels.go +++ b/cmd/climc/shell/labels.go @@ -4,6 +4,7 @@ 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" ) func init() { @@ -81,10 +82,18 @@ func init() { * 列出所有的标签 */ type LabelListOptions struct { - BaseListOptions + options.BaseListOptions } R(&LabelListOptions{}, "label-list", "List labels", func(s *mcclient.ClientSession, args *LabelListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.Labels.List(s, params) if err != nil { return err diff --git a/cmd/climc/shell/metrics.go b/cmd/climc/shell/metrics.go index 0509bffbe4..8b8b410271 100644 --- a/cmd/climc/shell/metrics.go +++ b/cmd/climc/shell/metrics.go @@ -1,8 +1,10 @@ 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" ) func init() { @@ -26,10 +28,18 @@ func init() { * 列出所有监控指标 */ type MetricsListOptions struct { - BaseListOptions + options.BaseListOptions } R(&MetricsListOptions{}, "metric-list", "List all metrics", func(s *mcclient.ClientSession, args *MetricsListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.Metrics.List(s, params) if err != nil { @@ -44,11 +54,19 @@ func init() { * 查看监控指标详情 */ type MetricsShowOptions struct { - BaseListOptions + options.BaseListOptions ID string `help:"The ID of the metric"` } R(&MetricsShowOptions{}, "metric-show", "Show metric details", func(s *mcclient.ClientSession, args *MetricsShowOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.Metrics.Get(s, args.ID, params) if err != nil { @@ -63,11 +81,19 @@ func init() { * 根据name查看监控指标详情 */ type MetricsShowByNameOptions struct { - BaseListOptions + options.BaseListOptions NAME string `help:"The NAME of the metric"` } R(&MetricsShowByNameOptions{}, "metric-details", "Show metric details by name", func(s *mcclient.ClientSession, args *MetricsShowByNameOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.Metrics.GetSpecific(s, "", args.NAME, params) if err != nil { diff --git a/cmd/climc/shell/monitor_types.go b/cmd/climc/shell/monitor_types.go index 7004926d28..9aa06a8943 100644 --- a/cmd/climc/shell/monitor_types.go +++ b/cmd/climc/shell/monitor_types.go @@ -1,8 +1,10 @@ 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" ) func init() { @@ -11,10 +13,18 @@ func init() { * 列出全部的监控类型 */ type MonitorTypesOptions struct { - BaseListOptions + options.BaseListOptions } R(&MonitorTypesOptions{}, "monitortype-list", "List all monitor types", func(s *mcclient.ClientSession, args *MonitorTypesOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.MonitorTypes.List(s, params) if err != nil { diff --git a/cmd/climc/shell/monitorinputs.go b/cmd/climc/shell/monitorinputs.go index e0bfc28a49..6809637f99 100644 --- a/cmd/climc/shell/monitorinputs.go +++ b/cmd/climc/shell/monitorinputs.go @@ -1,8 +1,10 @@ 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" ) func init() { @@ -11,10 +13,18 @@ func init() { * 列出所有监控数据源 */ type MonitorInputsListOptions struct { - BaseListOptions + options.BaseListOptions } R(&MonitorInputsListOptions{}, "monitorinputs-list", "List all monitor-inputs", func(s *mcclient.ClientSession, args *MonitorInputsListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.MonitorInputs.List(s, params) if err != nil { @@ -29,11 +39,19 @@ func init() { * 查看监控数据源下的监控项 */ type MonitorInputsShowOptions struct { - BaseListOptions + options.BaseListOptions ID string `help:"The ID of the monitor-input"` } R(&MonitorInputsShowOptions{}, "monitorinputs-metrics-list", "List all metrics for the monitor-inputs", func(s *mcclient.ClientSession, args *MonitorInputsShowOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.MonitorInputs.GetSpecific(s, args.ID, "metrics", params) if err != nil { diff --git a/cmd/climc/shell/monitortemplates.go b/cmd/climc/shell/monitortemplates.go index b89f32d7d9..4ad2ad2bfa 100644 --- a/cmd/climc/shell/monitortemplates.go +++ b/cmd/climc/shell/monitortemplates.go @@ -6,6 +6,7 @@ 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" ) func init() { @@ -47,10 +48,18 @@ func init() { * 列出监控模板 */ type MonitorTemplateListOptions struct { - BaseListOptions + options.BaseListOptions } R(&MonitorTemplateListOptions{}, "monitortemplate-list", "List all monitor-template", func(s *mcclient.ClientSession, args *MonitorTemplateListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.MonitorTemplates.List(s, params) if err != nil { @@ -65,11 +74,19 @@ func init() { * 查看监控模板详情 */ type MonitorTemplateShowOptions struct { - BaseListOptions + options.BaseListOptions ID string `help:"The ID of the monitor-template"` } R(&MonitorTemplateShowOptions{}, "monitortemplate-show", "Show monitor-template", func(s *mcclient.ClientSession, args *MonitorTemplateShowOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.MonitorTemplates.Get(s, args.ID, params) if err != nil { diff --git a/cmd/climc/shell/networks.go b/cmd/climc/shell/networks.go index 52d6900a28..0e093b50a3 100644 --- a/cmd/climc/shell/networks.go +++ b/cmd/climc/shell/networks.go @@ -6,18 +6,27 @@ 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" ) func init() { type NetworkListOptions struct { - BaseListOptions + 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"` Vpc string `help:"search networks belongs to a VPC"` } R(&NetworkListOptions{}, "network-list", "List networks", func(s *mcclient.ClientSession, args *NetworkListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + 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") } diff --git a/cmd/climc/shell/nodes.go b/cmd/climc/shell/nodes.go index fac2eb66c2..b7a98b7d95 100644 --- a/cmd/climc/shell/nodes.go +++ b/cmd/climc/shell/nodes.go @@ -6,6 +6,7 @@ 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" ) func init() { @@ -14,11 +15,19 @@ func init() { * 查看所有的监控节点 | 列出匹配标签的节点列表 */ type NodeListOptions struct { - BaseListOptions + options.BaseListOptions Labels []string `help:"Node labels"` } R(&NodeListOptions{}, "node-list", "List all nodes", func(s *mcclient.ClientSession, args *NodeListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } if len(args.Labels) > 0 { for _, f := range args.Labels { parts := strings.Split(f, "=") diff --git a/cmd/climc/shell/notification.go b/cmd/climc/shell/notification.go index b2b21af2b7..d6a0641854 100644 --- a/cmd/climc/shell/notification.go +++ b/cmd/climc/shell/notification.go @@ -5,6 +5,7 @@ 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" ) func init() { @@ -71,7 +72,7 @@ func init() { * 查询已发送的通知任务 */ type NotificationListOptions struct { - BaseListOptions + options.BaseListOptions } R(&NotificationListOptions{}, "notify-list", "List notification history", func(s *mcclient.ClientSession, args *NotificationListOptions) error { result, err := modules.Notifications.List(s, nil) diff --git a/cmd/climc/shell/operations.go b/cmd/climc/shell/operations.go index cb08861efa..b778b52e29 100644 --- a/cmd/climc/shell/operations.go +++ b/cmd/climc/shell/operations.go @@ -4,14 +4,23 @@ 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" ) func init() { type OperationListOptions struct { - BaseListOptions + options.BaseListOptions } R(&OperationListOptions{}, "operation-list", "List operations", func(s *mcclient.ClientSession, suboptions *OperationListOptions) error { - params := FetchPagingParams(suboptions.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = suboptions.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.Operations.List(s, params) if err != nil { return err diff --git a/cmd/climc/shell/processes.go b/cmd/climc/shell/processes.go index 84fbc5e82a..efa3f9b08b 100644 --- a/cmd/climc/shell/processes.go +++ b/cmd/climc/shell/processes.go @@ -1,16 +1,26 @@ 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" ) func init() { type TaskListOptions struct { - BaseListOptions + options.BaseListOptions } R(&TaskListOptions{}, "process-list", "List processes", func(s *mcclient.ClientSession, suboptions *TaskListOptions) error { - params := FetchPagingParams(suboptions.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = suboptions.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.Processes.List(s, params) if err != nil { return err diff --git a/cmd/climc/shell/processlogs.go b/cmd/climc/shell/processlogs.go index d6c038962d..29f92cd850 100644 --- a/cmd/climc/shell/processlogs.go +++ b/cmd/climc/shell/processlogs.go @@ -1,16 +1,26 @@ 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" ) func init() { type TaskListOptions struct { - BaseListOptions + options.BaseListOptions } R(&TaskListOptions{}, "prosesslog-list", "List processlogs", func(s *mcclient.ClientSession, suboptions *TaskListOptions) error { - params := FetchPagingParams(suboptions.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = suboptions.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.Processlogs.List(s, params) if err != nil { return err diff --git a/cmd/climc/shell/project_admin.go b/cmd/climc/shell/project_admin.go index 21f51564eb..7a7a0c8d25 100644 --- a/cmd/climc/shell/project_admin.go +++ b/cmd/climc/shell/project_admin.go @@ -1,8 +1,10 @@ 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" ) func init() { @@ -11,10 +13,18 @@ func init() { * 列出所有监控指标 */ type ProjectAdminListOptions struct { - BaseListOptions + options.BaseListOptions } R(&ProjectAdminListOptions{}, "projectadmin-list", "List all Project Admins", func(s *mcclient.ClientSession, args *ProjectAdminListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.ProjectAdmin.List(s, params) if err != nil { diff --git a/cmd/climc/shell/project_admin_candidates.go b/cmd/climc/shell/project_admin_candidates.go index fcd6be3848..2af2cdfed7 100644 --- a/cmd/climc/shell/project_admin_candidates.go +++ b/cmd/climc/shell/project_admin_candidates.go @@ -1,8 +1,10 @@ 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" ) func init() { @@ -11,10 +13,18 @@ func init() { * 列出所有监控指标 */ type ProjectAdminCandidateListOptions struct { - BaseListOptions + options.BaseListOptions } R(&ProjectAdminCandidateListOptions{}, "projectadmincandidate-list", "List all Project Admin Candidates", func(s *mcclient.ClientSession, args *ProjectAdminCandidateListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.ProjectAdminCandidate.List(s, params) if err != nil { diff --git a/cmd/climc/shell/rates.go b/cmd/climc/shell/rates.go index d4c931c2e5..34f52ece8d 100644 --- a/cmd/climc/shell/rates.go +++ b/cmd/climc/shell/rates.go @@ -4,6 +4,7 @@ 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" ) func init() { @@ -11,14 +12,22 @@ func init() { * 列出列表 */ type RateListOptions struct { - BaseListOptions + options.BaseListOptions RESTYPE string `"help":"res_type of the rate"` ACTION string `"help":"action of list :querygroup or queryhistory"` SubResType string `"help":"query the subResType"` Id string `"help":"ID of rate"` } R(&RateListOptions{}, "rate-list", "List all rates ", func(s *mcclient.ClientSession, args *RateListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } params.Add(jsonutils.NewString(args.RESTYPE), "res_type") params.Add(jsonutils.NewString(args.ACTION), "action") diff --git a/cmd/climc/shell/recipient.go b/cmd/climc/shell/recipient.go index 5c81470bc9..b870d0629d 100644 --- a/cmd/climc/shell/recipient.go +++ b/cmd/climc/shell/recipient.go @@ -4,6 +4,7 @@ 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" ) func init() { @@ -74,12 +75,20 @@ func init() { * 查询树节点的报警接收人信息 */ type TreeNodeRecipientsListOptions struct { - BaseListOptions + options.BaseListOptions LIST_TYPE string `help:"Type of list: junior|senior"` LABELS string `help:"Labels for tree-node(split by comma)"` } R(&TreeNodeRecipientsListOptions{}, "treenode-recipient-list", "List recipient for the tree-node ", func(s *mcclient.ClientSession, args *TreeNodeRecipientsListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } params.Add(jsonutils.NewString(args.LIST_TYPE), "type") params.Add(jsonutils.NewString(args.LABELS), "node_labels") diff --git a/cmd/climc/shell/reservedips.go b/cmd/climc/shell/reservedips.go index 0de0d0f9e8..6ce216ff58 100644 --- a/cmd/climc/shell/reservedips.go +++ b/cmd/climc/shell/reservedips.go @@ -4,6 +4,7 @@ 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" ) func init() { @@ -40,11 +41,19 @@ func init() { }) type ReservedIPListOptions struct { - BaseListOptions + options.BaseListOptions Network string `help:"Network filter"` } R(&ReservedIPListOptions{}, "reserved-ip-list", "Show all reserved IPs for any network", func(s *mcclient.ClientSession, args *ReservedIPListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } if len(args.Network) > 0 { params.Add(jsonutils.NewString(args.Network), "network") } diff --git a/cmd/climc/shell/resource_details.go b/cmd/climc/shell/resource_details.go index c0fc3eb309..7ea8e8eee7 100644 --- a/cmd/climc/shell/resource_details.go +++ b/cmd/climc/shell/resource_details.go @@ -4,6 +4,7 @@ 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" ) func init() { @@ -11,12 +12,20 @@ func init() { * 列出列表 */ type ResourceDetailListOptions struct { - BaseListOptions + options.BaseListOptions QUERYTYPE string `"help":"query type of the resource_detail"` ProjectId string `"help":"project id of the resource_detail"` } R(&ResourceDetailListOptions{}, "resourcedetail-list", "List all resource details", func(s *mcclient.ClientSession, args *ResourceDetailListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } if len(args.QUERYTYPE) > 0 { params.Add(jsonutils.NewString(args.QUERYTYPE), "query_type") } diff --git a/cmd/climc/shell/resource_fees.go b/cmd/climc/shell/resource_fees.go index 08c8c324de..49e50764e2 100644 --- a/cmd/climc/shell/resource_fees.go +++ b/cmd/climc/shell/resource_fees.go @@ -4,6 +4,7 @@ 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" ) func init() { @@ -11,7 +12,7 @@ func init() { * 列出列表 */ type ResourceFeeListOptions struct { - BaseListOptions + options.BaseListOptions STATTYPE string `"help":"stat type of the resource_fee"` STATMONTH string `"help":"stat month of the resource_fee"` ProjectId string `"help":"project id of the resource_fee"` @@ -19,7 +20,15 @@ func init() { EndDay string `"help":"end day of the resource_fee"` } R(&ResourceFeeListOptions{}, "resourcefee-list", "List all resource fees", func(s *mcclient.ClientSession, args *ResourceFeeListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } if len(args.STATTYPE) > 0 { params.Add(jsonutils.NewString(args.STATTYPE), "stat_type") } diff --git a/cmd/climc/shell/schedtaghosts.go b/cmd/climc/shell/schedtaghosts.go index 9ff4f6a1aa..cb719cfb51 100644 --- a/cmd/climc/shell/schedtaghosts.go +++ b/cmd/climc/shell/schedtaghosts.go @@ -1,13 +1,15 @@ 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" ) func init() { type SchedtagHostListOptions struct { - BaseListOptions + options.BaseListOptions Schedtag string `help:"ID or Name of schedtag"` } R(&SchedtagHostListOptions{}, "schedtag-host-list", "List all scheduler tag and host pairs", func(s *mcclient.ClientSession, args *SchedtagHostListOptions) error { @@ -15,7 +17,15 @@ func init() { if err != nil { return err } - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } var result *modules.ListResult if len(args.Schedtag) > 0 { result, err = mod.ListDescendent(s, args.Schedtag, params) diff --git a/cmd/climc/shell/schedtags.go b/cmd/climc/shell/schedtags.go index e0ec4648d5..86f4178cc7 100644 --- a/cmd/climc/shell/schedtags.go +++ b/cmd/climc/shell/schedtags.go @@ -5,14 +5,23 @@ 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" ) func init() { type SchedtagListOptions struct { - BaseListOptions + options.BaseListOptions } R(&SchedtagListOptions{}, "schedtag-list", "List schedule tags", func(s *mcclient.ClientSession, suboptions *SchedtagListOptions) error { - params := FetchPagingParams(suboptions.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = suboptions.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.Schedtags.List(s, params) if err != nil { return err diff --git a/cmd/climc/shell/secgrouprules.go b/cmd/climc/shell/secgrouprules.go index eb9fd4b621..222c3c6968 100644 --- a/cmd/climc/shell/secgrouprules.go +++ b/cmd/climc/shell/secgrouprules.go @@ -4,11 +4,12 @@ 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" ) func init() { type SecGroupRulesListOptions struct { - BaseListOptions + options.BaseListOptions Secgroup string `help:"Secgroup ID or Name"` Direction string `help:"filter Direction of rule" choices:"in|out"` Protocol string `help:"filter Protocol of rule" choices:"any|tcp|udp|icmp"` @@ -16,7 +17,15 @@ func init() { } R(&SecGroupRulesListOptions{}, "secgroup-rule-list", "List all security group", func(s *mcclient.ClientSession, args *SecGroupRulesListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } if len(args.Secgroup) > 0 { params.Add(jsonutils.NewString(args.Secgroup), "secgroup") } diff --git a/cmd/climc/shell/secgroups.go b/cmd/climc/shell/secgroups.go index 8090fe5610..a0a5818163 100644 --- a/cmd/climc/shell/secgroups.go +++ b/cmd/climc/shell/secgroups.go @@ -6,15 +6,24 @@ 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" ) func init() { type SecGroupsListOptions struct { - BaseListOptions + options.BaseListOptions } R(&SecGroupsListOptions{}, "secgroup-list", "List all security group", func(s *mcclient.ClientSession, args *SecGroupsListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.SecGroups.List(s, params) if err != nil { return err diff --git a/cmd/climc/shell/serverdisks.go b/cmd/climc/shell/serverdisks.go index eb8cab800d..98186a768d 100644 --- a/cmd/climc/shell/serverdisks.go +++ b/cmd/climc/shell/serverdisks.go @@ -5,15 +5,24 @@ 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" ) func init() { type ServerDiskListOptions struct { - BaseListOptions + options.BaseListOptions Server string `help:"ID or Name of Server"` } R(&ServerDiskListOptions{}, "server-disk-list", "List server disk pairs", func(s *mcclient.ClientSession, args *ServerDiskListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } var result *modules.ListResult var err error if len(args.Server) > 0 { diff --git a/cmd/climc/shell/servernetworks.go b/cmd/climc/shell/servernetworks.go index c867c57842..2674d48e2b 100644 --- a/cmd/climc/shell/servernetworks.go +++ b/cmd/climc/shell/servernetworks.go @@ -4,18 +4,27 @@ 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" ) func init() { type ServerNetworkListOptions struct { - BaseListOptions + options.BaseListOptions Server string `help:"ID or Name of Server"` Mac string `help:"search the MAC address"` Ip string `help:"search the IP address"` Network string `help:"Network ID or name"` } R(&ServerNetworkListOptions{}, "server-network-list", "List server network pairs", func(s *mcclient.ClientSession, args *ServerNetworkListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } if len(args.Mac) > 0 { params.Add(jsonutils.NewString(args.Mac), "mac_addr") } diff --git a/cmd/climc/shell/service_hosts.go b/cmd/climc/shell/service_hosts.go index 1e3a5d2cc9..77c134fba1 100644 --- a/cmd/climc/shell/service_hosts.go +++ b/cmd/climc/shell/service_hosts.go @@ -4,6 +4,7 @@ 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" ) func init() { @@ -72,11 +73,19 @@ func init() { * 查看指定服务树节点的机器 */ type ServiceHostListOptions struct { - BaseListOptions + options.BaseListOptions Labels string `help:"Labels for tree-node(split by comma)"` } R(&ServiceHostListOptions{}, "servicehost-list", "List all hosts for the tree-node", func(s *mcclient.ClientSession, args *ServiceHostListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } if len(args.Labels) > 0 { params.Add(jsonutils.NewString(args.Labels), "node_labels") } diff --git a/cmd/climc/shell/service_name_suggestions.go b/cmd/climc/shell/service_name_suggestions.go index 23eb4e155b..fd01ef652e 100644 --- a/cmd/climc/shell/service_name_suggestions.go +++ b/cmd/climc/shell/service_name_suggestions.go @@ -1,8 +1,10 @@ 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" ) func init() { @@ -11,10 +13,18 @@ func init() { * 列出所有监控指标 */ type ServiceNameSuggestionListOptions struct { - BaseListOptions + options.BaseListOptions } R(&ServiceNameSuggestionListOptions{}, "servicenamesuggestion-list", "List all serviceNameSuggestion", func(s *mcclient.ClientSession, args *ServiceNameSuggestionListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.ServiceNameSuggestion.List(s, params) if err != nil { diff --git a/cmd/climc/shell/servicetrees.go b/cmd/climc/shell/servicetrees.go index b89767b996..aeda96d62a 100644 --- a/cmd/climc/shell/servicetrees.go +++ b/cmd/climc/shell/servicetrees.go @@ -4,6 +4,7 @@ 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" ) func init() { @@ -79,10 +80,18 @@ func init() { * 列出服务树 */ type ServiceTreeListOptions struct { - BaseListOptions + options.BaseListOptions } R(&ServiceTreeListOptions{}, "servicetree-list", "List all service tree", func(s *mcclient.ClientSession, args *ServiceTreeListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.ServiceTrees.List(s, params) if err != nil { return err diff --git a/cmd/climc/shell/shell.go b/cmd/climc/shell/shell.go index 03246aa46c..6eea679223 100644 --- a/cmd/climc/shell/shell.go +++ b/cmd/climc/shell/shell.go @@ -2,8 +2,6 @@ package shell import ( "fmt" - - "yunion.io/x/jsonutils" ) type CMD struct { @@ -19,105 +17,6 @@ func R(options interface{}, command string, desc string, callback interface{}) { CommandTable = append(CommandTable, CMD{options, command, desc, callback}) } -type BaseListOptions struct { - Limit int `default:"20" help:"Page limit"` - Offset int `default:"0" help:"Page offset"` - OrderBy string `help:"Name of the field to be ordered by"` - Order string `help:"List order" choices:"desc|asc"` - Details bool `help:"Show more details"` - Search string `help:"Filter results by a simple keyword search"` - Meta bool `help:"Piggyback metadata information"` - Filter []string `help:"Filters"` - JointFilter []string `help:"Filters with joint table col; joint_tbl(related_key).filter_col.filter_cond(filters)"` - FilterAny bool `help:"If true, match if any of the filters matches; otherwise, match if all of the filters match"` - Admin bool `help:"Is an admin call?"` - Tenant string `help:"Tenant ID or Name"` - User string `help:"User ID or Name"` - System bool `help:"Show system resource"` - PendingDelete bool `help:"Show pending deleted resource"` - Field []string `help:"Show only specified fields"` - ShowEmulated bool `help:"Show all resources including the emulated resources"` -} - -func FetchPagingParams(options BaseListOptions) *jsonutils.JSONDict { - params := jsonutils.NewDict() - if options.Limit > 0 { - params.Add(jsonutils.NewInt(int64(options.Limit)), "limit") - } - if options.Offset > 0 { - params.Add(jsonutils.NewInt(int64(options.Offset)), "offset") - } - if len(options.OrderBy) > 0 { - params.Add(jsonutils.NewString(options.OrderBy), "order_by") - } - if len(options.Order) > 0 { - params.Add(jsonutils.NewString(options.Order), "order") - } - if options.Details { - params.Add(jsonutils.JSONTrue, "details") - } else { - params.Add(jsonutils.JSONFalse, "details") - } - if len(options.Search) > 0 { - params.Add(jsonutils.NewString(options.Search), "search") - } - if options.Meta { - params.Add(jsonutils.JSONTrue, "with_meta") - } - if len(options.JointFilter) > 0 { - arr := jsonutils.NewArray() - for _, f := range options.JointFilter { - arr.Add(jsonutils.NewString(f)) - } - params.Add(arr, "joint_filter") - } - if len(options.Filter) > 0 { - arr := jsonutils.NewArray() - for _, f := range options.Filter { - arr.Add(jsonutils.NewString(f)) - } - params.Add(arr, "filter") - if options.FilterAny { - params.Add(jsonutils.JSONTrue, "filter_any") - } - } - if options.Admin { - params.Add(jsonutils.JSONTrue, "admin") - } - if len(options.Tenant) > 0 { - params.Add(jsonutils.NewString(options.Tenant), "tenant") - if !options.Admin { - params.Add(jsonutils.JSONTrue, "admin") - } - } - if len(options.User) > 0 { - params.Add(jsonutils.NewString(options.User), "user") - } - if options.System { - params.Add(jsonutils.JSONTrue, "system") - if !options.Admin { - params.Add(jsonutils.JSONTrue, "admin") - } - } - if options.PendingDelete { - params.Add(jsonutils.JSONTrue, "pending_delete") - if !options.Admin { - params.Add(jsonutils.JSONTrue, "admin") - } - } - if len(options.Field) > 0 { - arr := jsonutils.NewArray() - for _, f := range options.Field { - arr.Add(jsonutils.NewString(f)) - } - params.Add(arr, "field") - } - if options.ShowEmulated { - params.Add(jsonutils.JSONTrue, "show_emulated") - } - return params -} - func InvalidUpdateError() error { return fmt.Errorf("No valid update data") } diff --git a/cmd/climc/shell/specs.go b/cmd/climc/shell/specs.go index bdc61e7029..e5f9094f7b 100644 --- a/cmd/climc/shell/specs.go +++ b/cmd/climc/shell/specs.go @@ -6,17 +6,26 @@ 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" ) func init() { type ListOptions struct { - BaseListOptions + options.BaseListOptions Model string `help:"Specified model specs" choices:"hosts|isolated_devices|guests"` HostType string `help:"Host type filter" choices:"baremetal|hypervisor|esxi|kubelet|hyperv"` Gpu bool `help:"Only show gpu devices"` } R(&ListOptions{}, "spec", "List all kinds of model specs", func(s *mcclient.ClientSession, args *ListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } model := "" if len(args.Model) != 0 { model = args.Model @@ -36,7 +45,7 @@ func init() { }) type HostsQueryOptions struct { - BaseListOptions + options.BaseListOptions HostType string `help:"Host type filter" choices:"baremetal|hypervisor|esxi|kubelet|hyperv"` Ncpu int64 `help:"#CPU count of host" metavar:""` MemSize string `help:"Memory GB size"` @@ -61,7 +70,15 @@ func init() { } return keys } - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } if len(args.HostType) > 0 { params.Add(jsonutils.NewString(args.HostType), "host_type") } @@ -80,7 +97,7 @@ func init() { }) type IsoDevQueryOptions struct { - BaseListOptions + options.BaseListOptions Model string `help:"Device model name"` Vendor string `help:"Device vendor name"` } @@ -95,7 +112,15 @@ func init() { } return keys } - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } resp, err := modules.Specs.SpecsQueryModelObjects(s, "isolated_devices", newSpecKeys(), params) if err != nil { return err diff --git a/cmd/climc/shell/storagecachedimages.go b/cmd/climc/shell/storagecachedimages.go index 504826d14b..0b2579d5b2 100644 --- a/cmd/climc/shell/storagecachedimages.go +++ b/cmd/climc/shell/storagecachedimages.go @@ -4,16 +4,25 @@ 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" ) func init() { type StorageCachedImageListOptions struct { - BaseListOptions + options.BaseListOptions Storagecache string `help:"ID or Name of Storage"` Image string `help:"ID or Name of image"` } R(&StorageCachedImageListOptions{}, "storage-cached-image-list", "List storage cached image pairs", func(s *mcclient.ClientSession, args *StorageCachedImageListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } var result *modules.ListResult var err error if len(args.Storagecache) > 0 { diff --git a/cmd/climc/shell/storagecaches.go b/cmd/climc/shell/storagecaches.go index 0e10d6ab75..d24a1b31dc 100644 --- a/cmd/climc/shell/storagecaches.go +++ b/cmd/climc/shell/storagecaches.go @@ -4,16 +4,25 @@ 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" ) func init() { type StoragecacheListOptions struct { - BaseListOptions + 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 { - params := FetchPagingParams(args.BaseListOptions) + 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") diff --git a/cmd/climc/shell/storages.go b/cmd/climc/shell/storages.go index 4608be45f9..4d0cca8701 100644 --- a/cmd/climc/shell/storages.go +++ b/cmd/climc/shell/storages.go @@ -6,11 +6,12 @@ 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" ) func init() { type StorageListOptions struct { - BaseListOptions + options.BaseListOptions Share bool `help:"Share storage list"` Local bool `help:"Local storage list"` Usable bool `help:"Usable storage list"` @@ -20,7 +21,15 @@ func init() { Manager string `help:"Show regions belongs to the cloud provider"` } R(&StorageListOptions{}, "storage-list", "List storages", func(s *mcclient.ClientSession, args *StorageListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } if args.Share { params.Add(jsonutils.JSONTrue, "share") } diff --git a/cmd/climc/shell/tasks.go b/cmd/climc/shell/tasks.go index d4b3edafef..9d62fcbebe 100644 --- a/cmd/climc/shell/tasks.go +++ b/cmd/climc/shell/tasks.go @@ -1,16 +1,26 @@ 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" ) func init() { type TaskListOptions struct { - BaseListOptions + options.BaseListOptions } R(&TaskListOptions{}, "task-list", "List taskman", func(s *mcclient.ClientSession, suboptions *TaskListOptions) error { - params := FetchPagingParams(suboptions.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = suboptions.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.Tasks.List(s, params) if err != nil { return err @@ -20,7 +30,15 @@ func init() { }) R(&TaskListOptions{}, "region-task-list", "List tasks on region server", func(s *mcclient.ClientSession, suboptions *TaskListOptions) error { - params := FetchPagingParams(suboptions.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = suboptions.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.ComputeTasks.List(s, params) if err != nil { return err diff --git a/cmd/climc/shell/treenodes.go b/cmd/climc/shell/treenodes.go index 8bbd156b13..75c82042ed 100644 --- a/cmd/climc/shell/treenodes.go +++ b/cmd/climc/shell/treenodes.go @@ -7,6 +7,7 @@ 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" ) func init() { @@ -58,12 +59,20 @@ func init() { }) type ServiceTreeNodeListOptions struct { - BaseListOptions + options.BaseListOptions Label string `help:"Label of node"` Pid int64 `help:"Pid of node" default:"-1"` } R(&ServiceTreeNodeListOptions{}, "servicetree-node-list", "List servicetree nodes", func(s *mcclient.ClientSession, args *ServiceTreeNodeListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } if args.Pid >= 0 { params.Add(jsonutils.NewInt(args.Pid), "pid") } diff --git a/cmd/climc/shell/vcenters.go b/cmd/climc/shell/vcenters.go index 134ec4b253..4b33f4e265 100644 --- a/cmd/climc/shell/vcenters.go +++ b/cmd/climc/shell/vcenters.go @@ -4,14 +4,23 @@ 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" ) func init() { type VCenterListOptions struct { - BaseListOptions + options.BaseListOptions } R(&VCenterListOptions{}, "vcenter-list", "List VMWare vcenters", func(s *mcclient.ClientSession, args *VCenterListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } result, err := modules.VCenters.List(s, params) if err != nil { return err diff --git a/cmd/climc/shell/vpcs.go b/cmd/climc/shell/vpcs.go index 1cd7c4b9ae..547a775dd0 100644 --- a/cmd/climc/shell/vpcs.go +++ b/cmd/climc/shell/vpcs.go @@ -4,16 +4,25 @@ 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" ) func init() { type VpcListOptions struct { - BaseListOptions + options.BaseListOptions Region string `help:"ID or Name of region"` Manager string `help:"Show regions belongs to the cloud provider"` } R(&VpcListOptions{}, "vpc-list", "List VPCs", func(s *mcclient.ClientSession, args *VpcListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + 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") diff --git a/cmd/climc/shell/wires.go b/cmd/climc/shell/wires.go index 09eb4f68c0..d83d778cc0 100644 --- a/cmd/climc/shell/wires.go +++ b/cmd/climc/shell/wires.go @@ -4,16 +4,25 @@ 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" ) func init() { type WireListOptions struct { - BaseListOptions + options.BaseListOptions Zone string `help:"list wires in zone"` Vpc string `help:"List wires in vpc"` } R(&WireListOptions{}, "wire-list", "List wires", func(s *mcclient.ClientSession, args *WireListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + 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") } diff --git a/cmd/climc/shell/zones.go b/cmd/climc/shell/zones.go index 16cc1cf3e0..4ca0b2d254 100644 --- a/cmd/climc/shell/zones.go +++ b/cmd/climc/shell/zones.go @@ -4,18 +4,27 @@ 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" ) func init() { type ZoneListOptions struct { - BaseListOptions + options.BaseListOptions Region string `help:"cloud region ID or Name"` Usable bool `help:"List all zones that is usable"` Private bool `help:"show all zones in private cloud regions only"` Public bool `help:"show all zones in public cloud regions only"` } R(&ZoneListOptions{}, "zone-list", "List zones", func(s *mcclient.ClientSession, args *ZoneListOptions) error { - params := FetchPagingParams(args.BaseListOptions) + 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") }