mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
修正:1. 由于系统盘大小设置单位未转换,导致阿里云创建主机失败 2.
伪删除阿里云主机后,detach了系统盘,导致主机恢复后无系统盘 3. 修正一些格式错误 4. 补充一些climc命令
This commit is contained in:
+3
-3
@@ -6,13 +6,13 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/c-bata/go-prompt"
|
||||
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/pkg/util/version"
|
||||
"github.com/yunionio/structarg"
|
||||
|
||||
"github.com/yunionio/onecloud/cmd/climc/promputils"
|
||||
"github.com/yunionio/onecloud/cmd/climc/shell"
|
||||
"github.com/yunionio/pkg/util/version"
|
||||
"github.com/yunionio/structarg"
|
||||
)
|
||||
|
||||
type BaseOptions struct {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package shell
|
||||
|
||||
import (
|
||||
// "github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/mcclient/modules"
|
||||
)
|
||||
|
||||
@@ -28,6 +28,7 @@ func init() {
|
||||
PROVIDER string `help:"Driver for cloud provider" choices:"VMware|Aliyun"`
|
||||
AccessUrl string `help:"Access url"`
|
||||
Desc string `help:"Description"`
|
||||
Enabled bool `help:"Enabled the provider automatically"`
|
||||
}
|
||||
R(&CloudproviderCreateOptions{}, "cloud-provider-create", "Create a cloud provider", func(s *mcclient.ClientSession, args *CloudproviderCreateOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
@@ -35,6 +36,9 @@ func init() {
|
||||
params.Add(jsonutils.NewString(args.ACCOUNT), "account")
|
||||
params.Add(jsonutils.NewString(args.SECRET), "secret")
|
||||
params.Add(jsonutils.NewString(args.PROVIDER), "provider")
|
||||
if args.Enabled {
|
||||
params.Add(jsonutils.JSONTrue, "enabled")
|
||||
}
|
||||
if len(args.AccessUrl) > 0 {
|
||||
params.Add(jsonutils.NewString(args.AccessUrl), "access_url")
|
||||
}
|
||||
@@ -98,6 +102,24 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudproviderShowOptions{}, "cloud-provider-enable", "Enable cloud provider", func(s *mcclient.ClientSession, args *CloudproviderShowOptions) error {
|
||||
result, err := modules.Cloudproviders.PerformAction(s, args.ID, "enable", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudproviderShowOptions{}, "cloud-provider-disable", "Disable cloud provider", func(s *mcclient.ClientSession, args *CloudproviderShowOptions) error {
|
||||
result, err := modules.Cloudproviders.PerformAction(s, args.ID, "disable", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudproviderUpdateCredentialOptions struct {
|
||||
ID string `help:"ID or Name of cloud provider"`
|
||||
ACCOUNT string `help:"new account"`
|
||||
|
||||
@@ -9,9 +9,25 @@ import (
|
||||
func init() {
|
||||
type CloudregionListOptions struct {
|
||||
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)
|
||||
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")
|
||||
}
|
||||
result, err := modules.Cloudregions.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -80,6 +80,31 @@ func init() {
|
||||
return doComputeEventList(s, &nargs)
|
||||
})
|
||||
|
||||
R(&TypeEventListOptions{}, "vpc-event", "Show operation event logs of vpc", func(s *mcclient.ClientSession, args *TypeEventListOptions) error {
|
||||
nargs := EventListOptions{BaseEventListOptions: args.BaseEventListOptions, Id: args.ID, Type: []string{"vpc"}}
|
||||
return doComputeEventList(s, &nargs)
|
||||
})
|
||||
|
||||
R(&TypeEventListOptions{}, "zone-event", "Show operation event logs of zone", func(s *mcclient.ClientSession, args *TypeEventListOptions) error {
|
||||
nargs := EventListOptions{BaseEventListOptions: args.BaseEventListOptions, Id: args.ID, Type: []string{"zone"}}
|
||||
return doComputeEventList(s, &nargs)
|
||||
})
|
||||
|
||||
R(&TypeEventListOptions{}, "region-event", "Show operation event logs of region", func(s *mcclient.ClientSession, args *TypeEventListOptions) error {
|
||||
nargs := EventListOptions{BaseEventListOptions: args.BaseEventListOptions, Id: args.ID, Type: []string{"cloudregion"}}
|
||||
return doComputeEventList(s, &nargs)
|
||||
})
|
||||
|
||||
R(&TypeEventListOptions{}, "wire-event", "Show operation event logs of wire", func(s *mcclient.ClientSession, args *TypeEventListOptions) error {
|
||||
nargs := EventListOptions{BaseEventListOptions: args.BaseEventListOptions, Id: args.ID, Type: []string{"wire"}}
|
||||
return doComputeEventList(s, &nargs)
|
||||
})
|
||||
|
||||
R(&TypeEventListOptions{}, "network-event", "Show operation event logs of network", func(s *mcclient.ClientSession, args *TypeEventListOptions) error {
|
||||
nargs := EventListOptions{BaseEventListOptions: args.BaseEventListOptions, Id: args.ID, Type: []string{"network"}}
|
||||
return doComputeEventList(s, &nargs)
|
||||
})
|
||||
|
||||
R(&TypeEventListOptions{}, "vcenter-event", "Show operation event logs of vcenter", func(s *mcclient.ClientSession, args *TypeEventListOptions) error {
|
||||
nargs := EventListOptions{BaseEventListOptions: args.BaseEventListOptions, Id: args.ID, Type: []string{"vcenter"}}
|
||||
return doComputeEventList(s, &nargs)
|
||||
|
||||
@@ -23,6 +23,9 @@ func init() {
|
||||
Disabled bool `help:"Show disabled host only"`
|
||||
HostType string `help:"Host type filter" choices:"baremetal|hypervisor|esxi|kubelet|hyperv"`
|
||||
AnyMac string `help:"Mac matches one of the host's interface"`
|
||||
|
||||
Manager string `help:"Show regions belongs to the cloud provider"`
|
||||
|
||||
BaseListOptions
|
||||
}
|
||||
R(&HostListOptions{}, "host-list", "List hosts", func(s *mcclient.ClientSession, args *HostListOptions) error {
|
||||
@@ -51,6 +54,11 @@ func init() {
|
||||
if len(args.HostType) > 0 {
|
||||
params.Add(jsonutils.NewString(args.HostType), "host_type")
|
||||
}
|
||||
|
||||
if len(args.Manager) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Manager), "manager")
|
||||
}
|
||||
|
||||
if args.Empty {
|
||||
params.Add(jsonutils.JSONTrue, "is_empty")
|
||||
} else if args.Occupied {
|
||||
@@ -169,6 +177,18 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
type HostPropertyOptions struct {
|
||||
}
|
||||
|
||||
R(&HostPropertyOptions{}, "baremetal-register-script", "Get online baremetal register script", func(s *mcclient.ClientSession, args *HostPropertyOptions) error {
|
||||
result, err := modules.Hosts.Get(s, "bm-start-register-script", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type HostUpdateOptions struct {
|
||||
ID string `help:"ID or Name of Host"`
|
||||
Name string `help:"New name of the host"`
|
||||
|
||||
@@ -10,6 +10,7 @@ func init() {
|
||||
type HostWireListOptions struct {
|
||||
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)
|
||||
@@ -17,6 +18,8 @@ func init() {
|
||||
var err error
|
||||
if len(args.Host) > 0 {
|
||||
result, err = modules.Hostwires.ListDescendent(s, args.Host, params)
|
||||
} else if len(args.Wire) > 0 {
|
||||
result, err = modules.Hostwires.ListDescendent2(s, args.Wire, params)
|
||||
} else {
|
||||
result, err = modules.Hostwires.List(s, params)
|
||||
}
|
||||
|
||||
@@ -136,13 +136,10 @@ func init() {
|
||||
if args.PendingDelete {
|
||||
params.Add(jsonutils.JSONTrue, "pending_delete")
|
||||
}
|
||||
if !args.Admin && len(args.Tenant) == 0 {
|
||||
if s.IsSystemAdmin() {
|
||||
params.Add(jsonutils.NewString(s.GetTenantId()), "owner")
|
||||
}
|
||||
} else if !s.IsSystemAdmin() {
|
||||
return fmt.Errorf("System admin ONLY options")
|
||||
} else if len(args.Tenant) > 0 {
|
||||
if args.Admin {
|
||||
params.Add(jsonutils.JSONTrue, "admin")
|
||||
}
|
||||
if len(args.Tenant) > 0 {
|
||||
tid, e := modules.Projects.GetId(s, args.Tenant, nil)
|
||||
if e != nil {
|
||||
return e
|
||||
|
||||
@@ -2,6 +2,7 @@ package shell
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/mcclient/modules"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package shell
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/mcclient/modules"
|
||||
@@ -9,14 +11,29 @@ import (
|
||||
func init() {
|
||||
type NetworkListOptions struct {
|
||||
BaseListOptions
|
||||
Ip string `help:"search networks that contain this IP"`
|
||||
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)
|
||||
if len(args.Ip) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Ip), "ip")
|
||||
}
|
||||
result, err := modules.Networks.List(s, params)
|
||||
if len(args.Zone) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Zone), "zone")
|
||||
}
|
||||
if len(args.Vpc) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Vpc), "vpc")
|
||||
}
|
||||
var result *modules.ListResult
|
||||
var err error
|
||||
if len(args.Wire) > 0 {
|
||||
result, err = modules.Networks.ListInContext(s, params, &modules.Wires, args.Wire)
|
||||
} else {
|
||||
result, err = modules.Networks.List(s, params)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -143,6 +160,15 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&NetworkShowOptions{}, "network-purge", "Purge a managed network, not delete the remote entity", func(s *mcclient.ClientSession, args *NetworkShowOptions) error {
|
||||
result, err := modules.Networks.PerformAction(s, args.ID, "purge", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type NetworkCreateOptions struct {
|
||||
WIRE string `help:"ID or Name of wire in wihich the network is created"`
|
||||
NETWORK string `help:"Name of new network"`
|
||||
@@ -184,6 +210,41 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
type NetworkCreateOptions2 struct {
|
||||
Wire string `help:"ID or Name of wire in which the network is created"`
|
||||
Vpc string `help:"ID or Name of vpc in which the network is created"`
|
||||
Zone string `help:"ID or Name of zone in which the network is created"`
|
||||
NETWORK string `help:"Name of new network"`
|
||||
PREFIX string `help:"Start of IPv4 address range"`
|
||||
Desc string `help:"Description" metavar:"DESCRIPTION"`
|
||||
}
|
||||
R(&NetworkCreateOptions2{}, "network-create2", "Create a virtual network", func(s *mcclient.ClientSession, args *NetworkCreateOptions2) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.NewString(args.NETWORK), "name")
|
||||
params.Add(jsonutils.NewString(args.PREFIX), "guest_ip_prefix")
|
||||
if len(args.Desc) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Desc), "description")
|
||||
}
|
||||
if len(args.Wire) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Wire), "wire")
|
||||
} else if len(args.Vpc) > 0 {
|
||||
if len(args.Zone) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Zone), "zone")
|
||||
params.Add(jsonutils.NewString(args.Vpc), "vpc")
|
||||
} else {
|
||||
return fmt.Errorf("Either wire or VPC/Zone must be provided")
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("Either wire or VPC/Zone must be provided")
|
||||
}
|
||||
net, e := modules.Networks.Create(s, params)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
printObject(net)
|
||||
return nil
|
||||
})
|
||||
|
||||
type NetworkSplitOptions struct {
|
||||
NETWORK string `help:"ID or name of network to split"`
|
||||
IP string `help:"Start ip of the split network"`
|
||||
|
||||
@@ -2,6 +2,7 @@ package shell
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/mcclient/modules"
|
||||
|
||||
@@ -678,4 +678,44 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
type ServerInsertISOOptions struct {
|
||||
ID string `help:"server ID or Name"`
|
||||
ISO string `help:"Glance image ID of the ISO"`
|
||||
}
|
||||
R(&ServerInsertISOOptions{}, "server-insert-iso", "Insert an ISO image into server's cdrom", func(s *mcclient.ClientSession, args *ServerInsertISOOptions) error {
|
||||
img, err := modules.Images.Get(s, args.ISO, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
imgId, err := img.GetString("id")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.NewString(imgId), "image_id")
|
||||
result, err := modules.Servers.PerformAction(s, args.ID, "insertiso", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&ServerShowOptions{}, "server-eject-iso", "Eject iso from servers' cdrom", func(s *mcclient.ClientSession, args *ServerShowOptions) error {
|
||||
result, err := modules.Servers.PerformAction(s, args.ID, "ejectiso", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&ServerShowOptions{}, "server-iso", "Show server's mounting ISO information", func(s *mcclient.ClientSession, args *ServerShowOptions) error {
|
||||
results, err := modules.Servers.GetSpecific(s, args.ID, "iso", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(results)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ type BaseListOptions struct {
|
||||
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 {
|
||||
@@ -102,6 +103,9 @@ func FetchPagingParams(options BaseListOptions) *jsonutils.JSONDict {
|
||||
}
|
||||
params.Add(arr, "field")
|
||||
}
|
||||
if options.ShowEmulated {
|
||||
params.Add(jsonutils.JSONTrue, "show_emulated")
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package shell
|
||||
|
||||
import (
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/mcclient/modules"
|
||||
)
|
||||
@@ -8,9 +9,16 @@ import (
|
||||
func init() {
|
||||
type StoragecacheListOptions struct {
|
||||
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)
|
||||
|
||||
if len(args.Manager) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Manager), "manager")
|
||||
}
|
||||
|
||||
result, err := modules.Storagecaches.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -31,4 +39,50 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&StoragecacheShowptions{}, "storage-cache-delete", "Delete storage cache", func(s *mcclient.ClientSession, args *StoragecacheShowptions) error {
|
||||
result, err := modules.Storagecaches.Delete(s, args.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type StorageCacheImageActionOptions struct {
|
||||
ID string `help:"ID or name of storage"`
|
||||
IMAGE string `help:"ID or name of image"`
|
||||
Force bool `help:"Force refresh cache, even if the image exists in cache"`
|
||||
}
|
||||
R(&StorageCacheImageActionOptions{}, "storagecache-cache-image", "Ask a storage cache to cache a image", func(s *mcclient.ClientSession, args *StorageCacheImageActionOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.NewString(args.IMAGE), "image")
|
||||
if args.Force {
|
||||
params.Add(jsonutils.JSONTrue, "is_force")
|
||||
}
|
||||
storage, err := modules.Storagecaches.PerformAction(s, args.ID, "cache-image", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(storage)
|
||||
return nil
|
||||
})
|
||||
|
||||
type StorageUncacheImageActionOptions struct {
|
||||
ID string `help:"ID or name of storage"`
|
||||
IMAGE string `help:"ID or name of image"`
|
||||
Force bool `help:"Force uncache, even if the image exists in cache"`
|
||||
}
|
||||
R(&StorageUncacheImageActionOptions{}, "storagecache-uncache-image", "Ask a storage cache to remove image from its cache", func(s *mcclient.ClientSession, args *StorageUncacheImageActionOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.NewString(args.IMAGE), "image")
|
||||
if args.Force {
|
||||
params.Add(jsonutils.JSONTrue, "is_force")
|
||||
}
|
||||
storage, err := modules.Storagecaches.PerformAction(s, args.ID, "uncache-image", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(storage)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -11,9 +11,13 @@ import (
|
||||
func init() {
|
||||
type StorageListOptions struct {
|
||||
BaseListOptions
|
||||
Share bool `help:"Share storage list"`
|
||||
Local bool `help:"Local storage list"`
|
||||
Usable bool `help:"Usable storage list"`
|
||||
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"`
|
||||
Region string `help:"List storages in region"`
|
||||
|
||||
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)
|
||||
@@ -26,7 +30,21 @@ func init() {
|
||||
if args.Usable {
|
||||
params.Add(jsonutils.JSONTrue, "usable")
|
||||
}
|
||||
result, err := modules.Storages.List(s, params)
|
||||
if len(args.Region) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Region), "region")
|
||||
}
|
||||
|
||||
if len(args.Manager) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Manager), "manager")
|
||||
}
|
||||
|
||||
var result *modules.ListResult
|
||||
var err error
|
||||
if len(args.Zone) > 0 {
|
||||
result, err = modules.Storages.ListInContext(s, params, &modules.Zones, args.Zone)
|
||||
} else {
|
||||
result, err = modules.Storages.List(s, params)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -181,10 +199,14 @@ func init() {
|
||||
type StorageUncacheImageActionOptions struct {
|
||||
ID string `help:"ID or name of storage"`
|
||||
IMAGE string `help:"ID or name of image"`
|
||||
Force bool `help:"Force uncache, even if the image exists in cache"`
|
||||
}
|
||||
R(&StorageUncacheImageActionOptions{}, "storage-uncache-image", "Ask a storage to remove image from its cache", func(s *mcclient.ClientSession, args *StorageUncacheImageActionOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.NewString(args.IMAGE), "image")
|
||||
if args.Force {
|
||||
params.Add(jsonutils.JSONTrue, "is_force")
|
||||
}
|
||||
storage, err := modules.Storages.PerformAction(s, args.ID, "uncache-image", params)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
+31
-5
@@ -9,10 +9,16 @@ import (
|
||||
func init() {
|
||||
type VpcListOptions struct {
|
||||
BaseListOptions
|
||||
Region string `help:"ID or Name of region"`
|
||||
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)
|
||||
|
||||
if len(args.Manager) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Manager), "manager")
|
||||
}
|
||||
|
||||
var result *modules.ListResult
|
||||
var err error
|
||||
if len(args.Region) > 0 {
|
||||
@@ -23,25 +29,36 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printList(result, modules.Vpcs.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type VpcCreateOptions struct {
|
||||
REGION string `help:"ID or name of the region where the VPC is created"`
|
||||
Id string `help:"ID of the new VPC"`
|
||||
NAME string `help:"Name of the VPC"`
|
||||
Desc string `help:"Description of the VPC"`
|
||||
REGION string `help:"ID or name of the region where the VPC is created"`
|
||||
Id string `help:"ID of the new VPC"`
|
||||
NAME string `help:"Name of the VPC"`
|
||||
CIDR string `help:"CIDR block"`
|
||||
Default bool `help:"default VPC for the region" default:"false"`
|
||||
Desc string `help:"Description of the VPC"`
|
||||
Manager string `help:"ID or Name of Cloud provider"`
|
||||
}
|
||||
R(&VpcCreateOptions{}, "vpc-create", "Create a VPC", func(s *mcclient.ClientSession, args *VpcCreateOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.NewString(args.NAME), "name")
|
||||
params.Add(jsonutils.NewString(args.CIDR), "cidr_block")
|
||||
if len(args.Id) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Id), "id")
|
||||
}
|
||||
if len(args.Desc) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Desc), "description")
|
||||
}
|
||||
if args.Default {
|
||||
params.Add(jsonutils.JSONTrue, "is_default")
|
||||
}
|
||||
if len(args.Manager) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Manager), "manager")
|
||||
}
|
||||
results, err := modules.Vpcs.CreateInContext(s, params, &modules.Cloudregions, args.REGION)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -116,4 +133,13 @@ func init() {
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&VpcUpdateStatusOptions{}, "vpc-purge", "Purge a managed VPC, not delete the remote entity", func(s *mcclient.ClientSession, args *VpcUpdateStatusOptions) error {
|
||||
result, err := modules.Vpcs.PerformAction(s, args.ID, "purge", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -9,10 +9,21 @@ import (
|
||||
func init() {
|
||||
type WireListOptions struct {
|
||||
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)
|
||||
result, err := modules.Wires.List(s, params)
|
||||
if len(args.Vpc) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Vpc), "vpc")
|
||||
}
|
||||
var result *modules.ListResult
|
||||
var err error
|
||||
if len(args.Zone) > 0 {
|
||||
result, err = modules.Wires.ListInContext(s, params, &modules.Zones, args.Zone)
|
||||
} else {
|
||||
result, err = modules.Wires.List(s, params)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -59,7 +70,9 @@ func init() {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.NewString(args.NAME), "name")
|
||||
params.Add(jsonutils.NewInt(args.BW), "bandwidth")
|
||||
params.Add(jsonutils.NewString(args.Vpc), "vpc")
|
||||
if len(args.Vpc) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Vpc), "vpc")
|
||||
}
|
||||
if len(args.Desc) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Desc), "description")
|
||||
}
|
||||
|
||||
@@ -9,10 +9,29 @@ import (
|
||||
func init() {
|
||||
type ZoneListOptions struct {
|
||||
BaseListOptions
|
||||
Region string `help:"cloud region ID or Name"`
|
||||
Usable bool `help:"List zones that is usable"`
|
||||
Private bool `help:"show zones in private cloud regions only"`
|
||||
Public bool `help:"show zones in public cloud regions only"`
|
||||
}
|
||||
R(&ZoneListOptions{}, "zone-list", "List zones", func(s *mcclient.ClientSession, suboptions *ZoneListOptions) error {
|
||||
params := FetchPagingParams(suboptions.BaseListOptions)
|
||||
result, err := modules.Zones.List(s, params)
|
||||
R(&ZoneListOptions{}, "zone-list", "List zones", func(s *mcclient.ClientSession, args *ZoneListOptions) error {
|
||||
params := FetchPagingParams(args.BaseListOptions)
|
||||
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")
|
||||
}
|
||||
var err error
|
||||
var result *modules.ListResult
|
||||
if len(args.Region) > 0 {
|
||||
result, err = modules.Zones.ListInContext(s, params, &modules.Cloudregions, args.Region)
|
||||
} else {
|
||||
result, err = modules.Zones.List(s, params)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -73,6 +92,15 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&ZoneShowOptions{}, "zone-capabilities", "Show zone's capacibilities", func(s *mcclient.ClientSession, args *ZoneShowOptions) error {
|
||||
result, err := modules.Zones.GetSpecific(s, args.ID, "capabilities", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ZoneCreateOptions struct {
|
||||
NAME string `help:"Name of zone"`
|
||||
NameCN string `help:"Name in Chinese"`
|
||||
|
||||
@@ -10,9 +10,9 @@ import (
|
||||
|
||||
"gopkg.in/gin-gonic/gin.v1"
|
||||
|
||||
o "github.com/yunionio/onecloud/cmd/scheduler/options"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient/auth"
|
||||
o "github.com/yunionio/onecloud/cmd/scheduler/options"
|
||||
_ "github.com/yunionio/onecloud/pkg/scheduler/algorithmprovider"
|
||||
"github.com/yunionio/onecloud/pkg/scheduler/db/models"
|
||||
schedhandler "github.com/yunionio/onecloud/pkg/scheduler/handler"
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"gopkg.in/gin-gonic/gin.v1"
|
||||
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/structarg"
|
||||
"github.com/yunionio/pkg/util/version"
|
||||
"github.com/yunionio/structarg"
|
||||
)
|
||||
|
||||
type SchedulerOptions struct {
|
||||
|
||||
Reference in New Issue
Block a user