mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
Merge pull request #3 from yunionio/bugfix/qj-misc-fix-20180730
20180730修正阿里云BUG
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 {
|
||||
|
||||
@@ -3,9 +3,9 @@ package db
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/pkg/utils"
|
||||
)
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
"github.com/yunionio/pkg/util/timeutils"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
)
|
||||
|
||||
type SResourceBase struct {
|
||||
|
||||
@@ -5,14 +5,14 @@ import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/pkg/util/regutils"
|
||||
"github.com/yunionio/pkg/util/stringutils"
|
||||
"github.com/yunionio/pkg/utils"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
)
|
||||
|
||||
type SStandaloneResourceBase struct {
|
||||
@@ -109,7 +109,7 @@ func (manager *SStandaloneResourceBaseManager) ListItemFilter(ctx context.Contex
|
||||
}
|
||||
|
||||
showEmulated := jsonutils.QueryBoolean(query, "show_emulated", false)
|
||||
if ! showEmulated {
|
||||
if !showEmulated {
|
||||
q = q.Filter(sqlchemy.IsFalse(q.Field("is_emulated")))
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
"path"
|
||||
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/structarg"
|
||||
"github.com/yunionio/pkg/utils"
|
||||
"github.com/yunionio/pkg/util/version"
|
||||
"github.com/yunionio/pkg/utils"
|
||||
"github.com/yunionio/structarg"
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
|
||||
@@ -2,6 +2,7 @@ package cloudprovider
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/mcclient"
|
||||
)
|
||||
|
||||
@@ -101,7 +101,7 @@ func (self *SAliyunGuestDriver) GetJsonDescAtHost(ctx context.Context, guest *mo
|
||||
imageId := disk.GetTemplateId()
|
||||
scimg := models.StoragecachedimageManager.GetStoragecachedimage(cache.Id, imageId)
|
||||
config.ExternalImageId = scimg.ExternalId
|
||||
config.SysDiskSize = disk.DiskSize
|
||||
config.SysDiskSize = disk.DiskSize / 1024 // MB => GB
|
||||
} else {
|
||||
config.DataDisks[i-1] = disk.DiskSize / 1024 // MB => GB
|
||||
}
|
||||
|
||||
@@ -305,8 +305,15 @@ func (manager *SCloudregionManager) ListItemFilter(ctx context.Context, q *sqlch
|
||||
q = q.Equals("provider", manager.Provider)
|
||||
}
|
||||
if jsonutils.QueryBoolean(query, "usable", false) {
|
||||
networks := NetworkManager.Query().SubQuery()
|
||||
wires := WireManager.Query().SubQuery()
|
||||
vpcs := VpcManager.Query().SubQuery()
|
||||
sq := vpcs.Query(sqlchemy.DISTINCT("cloudregion_id", vpcs.Field("cloudregion_id"))).Equals("status", VPC_STATUS_AVAILABLE)
|
||||
|
||||
sq := vpcs.Query(sqlchemy.DISTINCT("cloudregion_id", vpcs.Field("cloudregion_id")))
|
||||
sq = sq.Join(wires, sqlchemy.Equals(vpcs.Field("id"), wires.Field("vpc_id")))
|
||||
sq = sq.Join(networks, sqlchemy.Equals(wires.Field("id"), networks.Field("wire_id")))
|
||||
sq = sq.Filter(sqlchemy.Equals(networks.Field("status"), NETWORK_STATUS_AVAILABLE))
|
||||
|
||||
q = q.Filter(sqlchemy.In(q.Field("id"), sq.SubQuery()))
|
||||
}
|
||||
return q, nil
|
||||
|
||||
@@ -2,11 +2,12 @@ package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/quotas"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/quotas"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
)
|
||||
|
||||
type IGuestDriver interface {
|
||||
|
||||
@@ -1942,7 +1942,7 @@ func (self *SGuest) DoPendingDelete(ctx context.Context, userCred mcclient.Token
|
||||
for _, guestdisk := range self.GetDisks() {
|
||||
disk := guestdisk.GetDisk()
|
||||
storage := disk.GetStorage()
|
||||
if utils.IsInStringArray(storage.StorageType, sysutils.LOCAL_STORAGE_TYPES) {
|
||||
if utils.IsInStringArray(storage.StorageType, sysutils.LOCAL_STORAGE_TYPES) || disk.DiskType == DISK_TYPE_SYS || disk.DiskType == DISK_TYPE_SWAP {
|
||||
disk.DoPendingDelete(ctx, userCred)
|
||||
} else {
|
||||
self.detachDisk(ctx, disk, userCred)
|
||||
|
||||
@@ -3,26 +3,26 @@ package models
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"net/http"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/options"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/mcclient/auth"
|
||||
"github.com/yunionio/mcclient/modules"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/options"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/pkg/tristate"
|
||||
"github.com/yunionio/pkg/util/compare"
|
||||
"github.com/yunionio/pkg/util/netutils"
|
||||
"github.com/yunionio/pkg/util/regutils"
|
||||
"github.com/yunionio/pkg/util/sysutils"
|
||||
"github.com/yunionio/pkg/utils"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -147,7 +147,6 @@ func (manager *SHostManager) ListItemFilter(ctx context.Context, q *sqlchemy.SQu
|
||||
}
|
||||
var scopeQuery *sqlchemy.SSubQuery
|
||||
|
||||
|
||||
schedTagStr := jsonutils.GetAnyString(query, []string{"schedtag", "schedtag_id"})
|
||||
if len(schedTagStr) > 0 {
|
||||
schedTag, _ := SchedtagManager.FetchByIdOrName("", schedTagStr)
|
||||
@@ -158,7 +157,7 @@ func (manager *SHostManager) ListItemFilter(ctx context.Context, q *sqlchemy.SQu
|
||||
scopeQuery = hostschedtags.Query(hostschedtags.Field("host_id")).Equals("schedtag_id", schedTag.GetId()).SubQuery()
|
||||
}
|
||||
|
||||
wireStr :=jsonutils.GetAnyString(query, []string{"wire", "wire_id"})
|
||||
wireStr := jsonutils.GetAnyString(query, []string{"wire", "wire_id"})
|
||||
if len(wireStr) > 0 {
|
||||
wire, _ := WireManager.FetchByIdOrName("", wireStr)
|
||||
if wire == nil {
|
||||
|
||||
@@ -2,10 +2,11 @@ package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
)
|
||||
|
||||
type SHostschedtagManager struct {
|
||||
|
||||
@@ -3,12 +3,13 @@ package models
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/pkg/tristate"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
)
|
||||
|
||||
type SHoststorageManager struct {
|
||||
|
||||
@@ -2,10 +2,11 @@ package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
)
|
||||
|
||||
func InitDB() error {
|
||||
|
||||
@@ -5,14 +5,14 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/pkg/util/regutils"
|
||||
"github.com/yunionio/pkg/utils"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -2,10 +2,11 @@ package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
)
|
||||
|
||||
|
||||
@@ -3,10 +3,11 @@ package models
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/pkg/util/regutils"
|
||||
)
|
||||
|
||||
|
||||
@@ -6,21 +6,21 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/options"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
"github.com/yunionio/pkg/tristate"
|
||||
"github.com/yunionio/pkg/util/compare"
|
||||
"github.com/yunionio/pkg/util/fileutils"
|
||||
"github.com/yunionio/pkg/util/netutils"
|
||||
"github.com/yunionio/pkg/util/regutils"
|
||||
"github.com/yunionio/pkg/utils"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -3,9 +3,10 @@ package models
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/quotas"
|
||||
"github.com/yunionio/onecloud/pkg/compute/options"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/pkg/tristate"
|
||||
)
|
||||
|
||||
|
||||
@@ -3,11 +3,12 @@ package models
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
)
|
||||
|
||||
|
||||
@@ -4,13 +4,14 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"strings"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/pkg/utils"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
)
|
||||
|
||||
type SchedStrategyType string
|
||||
|
||||
@@ -6,14 +6,14 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/pkg/util/secrules"
|
||||
"github.com/yunionio/pkg/util/stringutils"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
)
|
||||
|
||||
type SSecurityGroupRuleManager struct {
|
||||
|
||||
@@ -4,11 +4,11 @@ import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
)
|
||||
|
||||
|
||||
@@ -4,14 +4,15 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/lockman"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/lockman"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/pkg/utils"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -3,14 +3,15 @@ package models
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
)
|
||||
|
||||
type SStoragecacheManager struct {
|
||||
@@ -165,7 +166,7 @@ func (self *SStoragecache) StartImageCacheTask(ctx context.Context, userCred mcc
|
||||
}
|
||||
|
||||
func (self *SStoragecache) StartImageUncacheTask(ctx context.Context, userCred mcclient.TokenCredential, imageId string, isForce bool, parentTaskId string) error {
|
||||
if ! isForce {
|
||||
if !isForce {
|
||||
err := self.ValidateDeleteCondition(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -219,7 +220,6 @@ func (self *SStoragecache) ValidateDeleteCondition(ctx context.Context) error {
|
||||
return self.SStandaloneResourceBase.ValidateDeleteCondition(ctx)
|
||||
}
|
||||
|
||||
|
||||
func (self *SStoragecache) AllowPerformUncacheImage(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return userCred.IsSystemAdmin()
|
||||
}
|
||||
|
||||
@@ -2,16 +2,17 @@ package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/options"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
"github.com/yunionio/pkg/tristate"
|
||||
"github.com/yunionio/pkg/util/compare"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
)
|
||||
|
||||
|
||||
@@ -3,9 +3,10 @@ package models
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
)
|
||||
|
||||
type SVCenterManager struct {
|
||||
|
||||
@@ -3,18 +3,18 @@ package models
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
|
||||
"fmt"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
"github.com/yunionio/pkg/util/compare"
|
||||
"github.com/yunionio/pkg/util/netutils"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -461,4 +461,4 @@ func (manager *SVpcManager) ListItemFilter(ctx context.Context, q *sqlchemy.SQue
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,17 @@ package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/pkg/util/compare"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
)
|
||||
|
||||
type SWireManager struct {
|
||||
|
||||
@@ -2,17 +2,17 @@ package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"fmt"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/pkg/tristate"
|
||||
"github.com/yunionio/pkg/util/compare"
|
||||
"github.com/yunionio/sqlchemy"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -57,7 +57,7 @@ func (manager *SZoneManager) AllowListItems(ctx context.Context, userCred mcclie
|
||||
|
||||
func (zone *SZone) ValidateDeleteCondition(ctx context.Context) error {
|
||||
usage := zone.GeneralUsage()
|
||||
if ! usage.isEmpty() {
|
||||
if !usage.isEmpty() {
|
||||
return httperrors.NewNotEmptyError("not empty zone")
|
||||
}
|
||||
return zone.SStandaloneResourceBase.ValidateDeleteCondition(ctx)
|
||||
|
||||
@@ -5,12 +5,12 @@ import (
|
||||
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/compute"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/onecloud/pkg/compute/options"
|
||||
"github.com/yunionio/log"
|
||||
|
||||
_ "github.com/yunionio/onecloud/pkg/compute/tasks"
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ package tasks
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -4,12 +4,12 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/pkg/utils"
|
||||
)
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ package tasks
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/onecloud/pkg/compute/options"
|
||||
)
|
||||
@@ -27,7 +27,7 @@ func (self *DiskDeleteTask) OnInit(ctx context.Context, obj db.IStandaloneModel,
|
||||
db.OpsLog.LogEvent(disk, db.ACT_DELOCATE_FAIL, reason, self.UserCred)
|
||||
return
|
||||
}
|
||||
if options.Options.EnablePendingDelete && ! disk.PendingDeleted && ! jsonutils.QueryBoolean(self.Params, "purge", false) && ! jsonutils.QueryBoolean(self.Params, "override_pending_delete", false) {
|
||||
if options.Options.EnablePendingDelete && !disk.PendingDeleted && !jsonutils.QueryBoolean(self.Params, "purge", false) && !jsonutils.QueryBoolean(self.Params, "override_pending_delete", false) {
|
||||
self.startPendingDeleteDisk(ctx, disk)
|
||||
} else {
|
||||
self.startDeleteDisk(ctx, disk)
|
||||
@@ -43,7 +43,7 @@ func (self *DiskDeleteTask) startDeleteDisk(ctx context.Context, disk *models.SD
|
||||
storage := disk.GetStorage()
|
||||
host := storage.GetMasterHost()
|
||||
isPurge := false
|
||||
if (host == nil || ! host.Enabled) && jsonutils.QueryBoolean(self.Params, "purge", false) {
|
||||
if (host == nil || !host.Enabled) && jsonutils.QueryBoolean(self.Params, "purge", false) {
|
||||
isPurge = true
|
||||
}
|
||||
disk.SetStatus(self.UserCred, models.DISK_DEALLOC, "")
|
||||
|
||||
@@ -4,16 +4,16 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient/auth"
|
||||
"github.com/yunionio/mcclient/modules"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/lockman"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/notifyclient"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/onecloud/pkg/compute/options"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient/auth"
|
||||
"github.com/yunionio/mcclient/modules"
|
||||
)
|
||||
|
||||
type GuestBatchCreateTask struct {
|
||||
|
||||
@@ -5,12 +5,12 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/notifyclient"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
)
|
||||
|
||||
type GuestCreateTask struct {
|
||||
|
||||
@@ -3,12 +3,12 @@ package tasks
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/notifyclient"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/onecloud/pkg/compute/options"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/pkg/utils"
|
||||
)
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
)
|
||||
|
||||
type GuestDeployTask struct {
|
||||
|
||||
@@ -3,10 +3,10 @@ package tasks
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/jsonutils"
|
||||
)
|
||||
|
||||
type GuestDetachAllDisksTask struct {
|
||||
|
||||
@@ -3,9 +3,9 @@ package tasks
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/jsonutils"
|
||||
)
|
||||
|
||||
type GuestDetachDiskTask struct {
|
||||
|
||||
@@ -3,9 +3,9 @@ package tasks
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/jsonutils"
|
||||
)
|
||||
|
||||
type GuestInsertIsoTask struct {
|
||||
|
||||
@@ -3,10 +3,10 @@ package tasks
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/jsonutils"
|
||||
)
|
||||
|
||||
type GuestStartTask struct {
|
||||
|
||||
@@ -4,11 +4,11 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
)
|
||||
|
||||
type GuestStopTask struct {
|
||||
|
||||
@@ -3,12 +3,12 @@ package tasks
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
)
|
||||
|
||||
type GuestSyncstatusTask struct {
|
||||
|
||||
@@ -3,10 +3,10 @@ package tasks
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/pkg/util/httputils"
|
||||
)
|
||||
|
||||
|
||||
@@ -2,15 +2,15 @@ package tasks
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
)
|
||||
|
||||
type NetworkCreateTask struct {
|
||||
|
||||
@@ -3,12 +3,12 @@ package tasks
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
)
|
||||
|
||||
type NetworkDeleteTask struct {
|
||||
|
||||
@@ -4,10 +4,10 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/jsonutils"
|
||||
)
|
||||
|
||||
type StorageCacheImageTask struct {
|
||||
|
||||
@@ -3,9 +3,9 @@ package tasks
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
)
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@ package tasks
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"time"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
)
|
||||
|
||||
type VpcCreateTask struct {
|
||||
|
||||
@@ -2,14 +2,14 @@ package tasks
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"time"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
)
|
||||
|
||||
type VpcDeleteTask struct {
|
||||
|
||||
@@ -5,15 +5,15 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/yunionio/pkg/appctx"
|
||||
"github.com/yunionio/pkg/appsrv"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
json "github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/mcclient/auth"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/pkg/appctx"
|
||||
"github.com/yunionio/pkg/appsrv"
|
||||
"github.com/yunionio/pkg/httperrors"
|
||||
"github.com/yunionio/pkg/tristate"
|
||||
"github.com/yunionio/pkg/utils"
|
||||
)
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
|
||||
"github.com/bitly/go-simplejson"
|
||||
|
||||
o "github.com/yunionio/onecloud/cmd/scheduler/options"
|
||||
"github.com/yunionio/log"
|
||||
o "github.com/yunionio/onecloud/cmd/scheduler/options"
|
||||
"github.com/yunionio/pkg/utils"
|
||||
)
|
||||
|
||||
|
||||
+1
-1
@@ -6,8 +6,8 @@ import (
|
||||
gosync "sync"
|
||||
"time"
|
||||
|
||||
"github.com/yunionio/onecloud/cmd/scheduler/options"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/cmd/scheduler/options"
|
||||
"github.com/yunionio/onecloud/pkg/scheduler/cache"
|
||||
"github.com/yunionio/onecloud/pkg/scheduler/db/models"
|
||||
u "github.com/yunionio/pkg/utils"
|
||||
|
||||
+2
-2
@@ -8,15 +8,15 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
o "github.com/yunionio/onecloud/cmd/scheduler/options"
|
||||
"github.com/yunionio/log"
|
||||
o "github.com/yunionio/onecloud/cmd/scheduler/options"
|
||||
"github.com/yunionio/onecloud/pkg/scheduler/cache"
|
||||
"github.com/yunionio/onecloud/pkg/scheduler/cache/db"
|
||||
"github.com/yunionio/onecloud/pkg/scheduler/db/models"
|
||||
"github.com/yunionio/pkg/util/errors"
|
||||
"github.com/yunionio/pkg/util/sets"
|
||||
"github.com/yunionio/pkg/utils"
|
||||
"github.com/yunionio/pkg/util/workqueue"
|
||||
"github.com/yunionio/pkg/utils"
|
||||
|
||||
"github.com/yunionio/onecloud/pkg/scheduler/core"
|
||||
)
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
o "github.com/yunionio/onecloud/cmd/scheduler/options"
|
||||
"github.com/yunionio/log"
|
||||
o "github.com/yunionio/onecloud/cmd/scheduler/options"
|
||||
"github.com/yunionio/pkg/util/errors"
|
||||
gp "github.com/yunionio/pkg/util/goroutine_pool"
|
||||
utiltrace "github.com/yunionio/pkg/util/trace"
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
|
||||
"gopkg.in/gin-gonic/gin.v1"
|
||||
|
||||
o "github.com/yunionio/onecloud/cmd/scheduler/options"
|
||||
"github.com/yunionio/log"
|
||||
o "github.com/yunionio/onecloud/cmd/scheduler/options"
|
||||
schedman "github.com/yunionio/onecloud/pkg/scheduler/manager"
|
||||
)
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ package manager
|
||||
import (
|
||||
"time"
|
||||
|
||||
o "github.com/yunionio/onecloud/cmd/scheduler/options"
|
||||
"github.com/yunionio/log"
|
||||
o "github.com/yunionio/onecloud/cmd/scheduler/options"
|
||||
"github.com/yunionio/onecloud/pkg/scheduler/api"
|
||||
"github.com/yunionio/pkg/utils"
|
||||
)
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
o "github.com/yunionio/onecloud/cmd/scheduler/options"
|
||||
"github.com/yunionio/log"
|
||||
o "github.com/yunionio/onecloud/cmd/scheduler/options"
|
||||
"github.com/yunionio/onecloud/pkg/scheduler/api"
|
||||
u "github.com/yunionio/pkg/utils"
|
||||
)
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"time"
|
||||
|
||||
o "github.com/yunionio/onecloud/cmd/scheduler/options"
|
||||
u "github.com/yunionio/pkg/utils"
|
||||
"github.com/yunionio/pkg/util/wait"
|
||||
u "github.com/yunionio/pkg/utils"
|
||||
)
|
||||
|
||||
type HistoryItem struct {
|
||||
|
||||
@@ -3,9 +3,9 @@ package aliyun
|
||||
import (
|
||||
"github.com/aliyun/alibaba-cloud-sdk-go/sdk"
|
||||
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -3,10 +3,11 @@ package aliyun
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/pkg/utils"
|
||||
)
|
||||
|
||||
|
||||
@@ -4,15 +4,15 @@ import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"time"
|
||||
|
||||
"github.com/aokoli/goutils"
|
||||
"golang.org/x/crypto/ssh"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
)
|
||||
|
||||
type SHost struct {
|
||||
|
||||
@@ -4,10 +4,11 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
)
|
||||
|
||||
type ImageStatusType string
|
||||
|
||||
@@ -3,10 +3,11 @@ package aliyun
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/pkg/util/osprofile"
|
||||
"github.com/yunionio/pkg/util/seclib"
|
||||
"github.com/yunionio/pkg/utils"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
// "github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/pkg/util/aliyun"
|
||||
)
|
||||
@@ -80,4 +80,4 @@ func (self *SAliyunProvider) GetIStorageById(id string) (cloudprovider.ICloudSto
|
||||
|
||||
func (self *SAliyunProvider) GetIStoragecacheById(id string) (cloudprovider.ICloudStoragecache, error) {
|
||||
return self.client.GetIStoragecacheById(id)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@ package aliyun
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/aliyun/alibaba-cloud-sdk-go/sdk"
|
||||
"github.com/aliyun/aliyun-oss-go-sdk/oss"
|
||||
"strings"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/pkg/utils"
|
||||
)
|
||||
|
||||
@@ -404,7 +406,6 @@ func (self *SRegion) GetMatchInstanceTypes(cpu int, memMB int, gpu int, zoneId s
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
|
||||
func (self *SRegion) CreateInstanceSimple(name string, imgId string, cpu int, memGB int, storageType string, dataDiskSizesGB []int, vswitchId string, passwd string, publicKey string) (*SInstance, error) {
|
||||
izones, err := self.GetIZones()
|
||||
if err != nil {
|
||||
@@ -534,8 +535,9 @@ func (self *SRegion) GetIStorageById(id string) (cloudprovider.ICloudStorage, er
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIStoragecacheById(id string) (cloudprovider.ICloudStoragecache, error) {
|
||||
if self.storageCache.GetGlobalId() == id {
|
||||
storageCache := self.getStoragecache()
|
||||
if storageCache.GetGlobalId() == id {
|
||||
return self.storageCache, nil
|
||||
}
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package aliyun
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/pkg/util/secrules"
|
||||
"github.com/yunionio/pkg/utils"
|
||||
|
||||
@@ -22,15 +22,15 @@ func init() {
|
||||
})
|
||||
|
||||
type InstanceCrateOptions struct {
|
||||
NAME string `help:"name of instance"`
|
||||
IMAGE string `help:"image ID"`
|
||||
CPU int `help:"CPU count"`
|
||||
MEMORYGB int `help:"MemoryGB"`
|
||||
Disk []int `help:"Data disk sizes int GB"`
|
||||
STORAGE string `help:"Storage type"`
|
||||
VSWITCH string `help:"Vswitch ID"`
|
||||
PASSWD string `help:"password"`
|
||||
PublicKey string `help:"PublicKey"`
|
||||
NAME string `help:"name of instance"`
|
||||
IMAGE string `help:"image ID"`
|
||||
CPU int `help:"CPU count"`
|
||||
MEMORYGB int `help:"MemoryGB"`
|
||||
Disk []int `help:"Data disk sizes int GB"`
|
||||
STORAGE string `help:"Storage type"`
|
||||
VSWITCH string `help:"Vswitch ID"`
|
||||
PASSWD string `help:"password"`
|
||||
PublicKey string `help:"PublicKey"`
|
||||
}
|
||||
R(&InstanceCrateOptions{}, "instance-create", "Create a instance", func(cli *aliyun.SRegion, args *InstanceCrateOptions) error {
|
||||
instance, e := cli.CreateInstanceSimple(args.NAME, args.IMAGE, args.CPU, args.MEMORYGB, args.STORAGE, args.Disk, args.VSWITCH, args.PASSWD, args.PublicKey)
|
||||
|
||||
@@ -3,6 +3,7 @@ package shell
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/mcclient/modules"
|
||||
"github.com/yunionio/pkg/util/printjson"
|
||||
|
||||
@@ -3,10 +3,11 @@ package aliyun
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
)
|
||||
|
||||
type SStorage struct {
|
||||
|
||||
@@ -4,12 +4,13 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/options"
|
||||
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/mcclient"
|
||||
"github.com/yunionio/mcclient/auth"
|
||||
"github.com/yunionio/mcclient/modules"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/options"
|
||||
)
|
||||
|
||||
type SStoragecache struct {
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/yunionio/log"
|
||||
)
|
||||
|
||||
|
||||
@@ -3,8 +3,9 @@ package aliyun
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -3,10 +3,11 @@ package aliyun
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
|
||||
"github.com/yunionio/jsonutils"
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/pkg/util/netutils"
|
||||
"github.com/yunionio/pkg/utils"
|
||||
)
|
||||
|
||||
@@ -2,8 +2,9 @@ package aliyun
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
)
|
||||
|
||||
type SWire struct {
|
||||
|
||||
@@ -3,9 +3,9 @@ package aliyun
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/yunionio/log"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/models"
|
||||
"github.com/yunionio/log"
|
||||
)
|
||||
|
||||
type InstanceChargeType string
|
||||
|
||||
Reference in New Issue
Block a user