mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-06-02 14:02:39 +08:00
rebase master
This commit is contained in:
19
pkg/util/zstack/shell/configration.go
Normal file
19
pkg/util/zstack/shell/configration.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/util/shellutils"
|
||||
"yunion.io/x/onecloud/pkg/util/zstack"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type ConfigrationListOptions struct {
|
||||
}
|
||||
shellutils.R(&ConfigrationListOptions{}, "configration-list", "List configration", func(cli *zstack.SRegion, args *ConfigrationListOptions) error {
|
||||
configrations, err := cli.GetConfigrations()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(configrations, len(configrations), 0, 0, []string{})
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -20,6 +20,23 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
type DiskIdOptions struct {
|
||||
ID string
|
||||
}
|
||||
|
||||
shellutils.R(&DiskIdOptions{}, "disk-show", "Show disk", func(cli *zstack.SRegion, args *DiskIdOptions) error {
|
||||
disk, err := cli.GetDisk(args.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(disk)
|
||||
return nil
|
||||
})
|
||||
|
||||
shellutils.R(&DiskIdOptions{}, "disk-delete", "Delete disk", func(cli *zstack.SRegion, args *DiskIdOptions) error {
|
||||
return cli.DeleteDisk(args.ID)
|
||||
})
|
||||
|
||||
type DiskCreateOptions struct {
|
||||
NAME string
|
||||
Description string
|
||||
@@ -38,14 +55,6 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
type DiskDelete struct {
|
||||
ID string
|
||||
}
|
||||
|
||||
shellutils.R(&DiskDelete{}, "disk-delete", "Delete disk", func(cli *zstack.SRegion, args *DiskDelete) error {
|
||||
return cli.DeleteDisk(args.ID)
|
||||
})
|
||||
|
||||
type DiskResize struct {
|
||||
ID string
|
||||
SIZEGB int64
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package shell
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/util/shellutils"
|
||||
"yunion.io/x/onecloud/pkg/util/zstack"
|
||||
)
|
||||
@@ -18,4 +20,29 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
type ImageCreateOptions struct {
|
||||
FILE string
|
||||
FORMAT string `choices:"qcow2|raw|iso"`
|
||||
PLATFORM string `choices:"Linux|Windows|Other"`
|
||||
Desc string
|
||||
}
|
||||
|
||||
shellutils.R(&ImageCreateOptions{}, "image-create", "Create image", func(cli *zstack.SRegion, args *ImageCreateOptions) error {
|
||||
f, err := os.Open(args.FILE)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
finfo, err := f.Stat()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
image, err := cli.CreateImage(args.FILE, args.FORMAT, args.PLATFORM, args.Desc, f, finfo.Size())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(image)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
21
pkg/util/zstack/shell/image_server.go
Normal file
21
pkg/util/zstack/shell/image_server.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/util/shellutils"
|
||||
"yunion.io/x/onecloud/pkg/util/zstack"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type ImageServerListOptions struct {
|
||||
ZoneId string
|
||||
}
|
||||
shellutils.R(&ImageServerListOptions{}, "image-server-list", "List image servers", func(cli *zstack.SRegion, args *ImageServerListOptions) error {
|
||||
servers, err := cli.GetImageServers(args.ZoneId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(servers, 0, 0, 0, []string{})
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
@@ -26,6 +26,10 @@ func init() {
|
||||
ID string
|
||||
}
|
||||
|
||||
shellutils.R(&InstanceOperation{}, "instance-delete", "Delete instance", func(cli *zstack.SRegion, args *InstanceOperation) error {
|
||||
return cli.DeleteVM(args.ID)
|
||||
})
|
||||
|
||||
shellutils.R(&InstanceOperation{}, "instance-console-password", "Show instance console password", func(cli *zstack.SRegion, args *InstanceOperation) error {
|
||||
password, err := cli.GetInstanceConsolePassword(args.ID)
|
||||
if err != nil {
|
||||
@@ -44,4 +48,35 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
shellutils.R(&InstanceOperation{}, "instance-start", "Start instance", func(cli *zstack.SRegion, args *InstanceOperation) error {
|
||||
return cli.StartVM(args.ID)
|
||||
})
|
||||
|
||||
shellutils.R(&InstanceOperation{}, "instance-boot-order", "Show instance boot order", func(cli *zstack.SRegion, args *InstanceOperation) error {
|
||||
fmt.Println(cli.GetBootOrder(args.ID))
|
||||
return nil
|
||||
})
|
||||
|
||||
type InstanceStopOption struct {
|
||||
ID string
|
||||
IsForce bool
|
||||
}
|
||||
|
||||
shellutils.R(&InstanceStopOption{}, "instance-stop", "Start instance", func(cli *zstack.SRegion, args *InstanceStopOption) error {
|
||||
return cli.StopVM(args.ID, args.IsForce)
|
||||
})
|
||||
|
||||
type InstanceSecgroupOption struct {
|
||||
ID string
|
||||
SECGRPID string
|
||||
}
|
||||
|
||||
shellutils.R(&InstanceSecgroupOption{}, "instance-assign-secgroup", "Assign secgroup for a instance", func(cli *zstack.SRegion, args *InstanceSecgroupOption) error {
|
||||
return cli.AssignSecurityGroup(args.ID, args.SECGRPID)
|
||||
})
|
||||
|
||||
shellutils.R(&InstanceSecgroupOption{}, "instance-revoke-secgroup", "Assign secgroup for a instance", func(cli *zstack.SRegion, args *InstanceSecgroupOption) error {
|
||||
return cli.RevokeSecurityGroup(args.ID, args.SECGRPID)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
23
pkg/util/zstack/shell/instance_offering.go
Normal file
23
pkg/util/zstack/shell/instance_offering.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/util/shellutils"
|
||||
"yunion.io/x/onecloud/pkg/util/zstack"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type InstanceOfferingListOptions struct {
|
||||
OfferId string
|
||||
Name string
|
||||
Cpu int
|
||||
MemoryMb int
|
||||
}
|
||||
shellutils.R(&InstanceOfferingListOptions{}, "instance-offering-list", "List instance offerings", func(cli *zstack.SRegion, args *InstanceOfferingListOptions) error {
|
||||
offerings, err := cli.GetInstanceOfferings(args.OfferId, args.Name, args.Cpu, args.MemoryMb)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(offerings, len(offerings), 0, 0, []string{})
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -20,4 +20,102 @@ func init() {
|
||||
printList(networks, len(networks), 0, 0, []string{})
|
||||
return nil
|
||||
})
|
||||
|
||||
type NetworkDeleteOptions struct {
|
||||
ID string
|
||||
}
|
||||
|
||||
shellutils.R(&NetworkDeleteOptions{}, "network-delete", "Delete network", func(cli *zstack.SRegion, args *NetworkDeleteOptions) error {
|
||||
return cli.DeleteNetwork(args.ID)
|
||||
})
|
||||
|
||||
type NetworkCreateOptions struct {
|
||||
NAME string
|
||||
Desc string
|
||||
WIRE string
|
||||
CIDR string
|
||||
}
|
||||
|
||||
shellutils.R(&NetworkCreateOptions{}, "network-create", "Create network", func(cli *zstack.SRegion, args *NetworkCreateOptions) error {
|
||||
network, err := cli.CreateNetwork(args.NAME, args.CIDR, args.WIRE, args.Desc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(network)
|
||||
return nil
|
||||
})
|
||||
|
||||
type L3NetworkListOptions struct {
|
||||
ZoneId string
|
||||
WireId string
|
||||
Id string
|
||||
}
|
||||
|
||||
shellutils.R(&L3NetworkListOptions{}, "l3network-list", "List networks", func(cli *zstack.SRegion, args *L3NetworkListOptions) error {
|
||||
l3networks, err := cli.GetL3Networks(args.ZoneId, args.WireId, args.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(l3networks, len(l3networks), 0, 0, []string{})
|
||||
return nil
|
||||
})
|
||||
|
||||
type NetworkServicesOptions struct {
|
||||
}
|
||||
|
||||
shellutils.R(&NetworkServicesOptions{}, "network-service-list", "List network services", func(cli *zstack.SRegion, args *NetworkServicesOptions) error {
|
||||
service, err := cli.GetNetworkServices()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(service)
|
||||
return nil
|
||||
})
|
||||
|
||||
type NetworkServiceProviderOptions struct {
|
||||
Type string
|
||||
}
|
||||
|
||||
shellutils.R(&NetworkServiceProviderOptions{}, "network-service-provider-list", "List network service providers", func(cli *zstack.SRegion, args *NetworkServiceProviderOptions) error {
|
||||
providers, err := cli.GetNetworkServiceProviders(args.Type)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(providers, len(providers), 0, 0, []string{})
|
||||
return nil
|
||||
})
|
||||
|
||||
type NetworkServiceAttachOptions struct {
|
||||
Services []string
|
||||
ID string
|
||||
}
|
||||
|
||||
shellutils.R(&NetworkServiceAttachOptions{}, "network-service-attach", "Attach network service to l3network", func(cli *zstack.SRegion, args *NetworkServiceAttachOptions) error {
|
||||
cli.AttachServiceForl3Network(args.ID, args.Services)
|
||||
return nil
|
||||
})
|
||||
|
||||
type NetworkServiceRefOptions struct {
|
||||
L3Id string
|
||||
Type string
|
||||
}
|
||||
|
||||
shellutils.R(&NetworkServiceRefOptions{}, "network-service-ref", "List network service ref", func(cli *zstack.SRegion, args *NetworkServiceRefOptions) error {
|
||||
refs, err := cli.GetNetworkServiceRef(args.L3Id, args.Type)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(refs, len(refs), 0, 0, []string{})
|
||||
return nil
|
||||
})
|
||||
|
||||
type NetworkServiceRemoveOptions struct {
|
||||
L3ID string
|
||||
SERVICE string `choices:"Userdata|DHCP|VipQos|HostRoute|Eip|SecurityGroup|DNS|SNAT"`
|
||||
}
|
||||
|
||||
shellutils.R(&NetworkServiceRemoveOptions{}, "remove-network-service", "Remove l3network service", func(cli *zstack.SRegion, args *NetworkServiceRemoveOptions) error {
|
||||
return cli.RemoveNetworkService(args.L3ID, args.SERVICE)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/util/shellutils"
|
||||
"yunion.io/x/onecloud/pkg/util/zstack"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type OfferingListOptions struct {
|
||||
OfferId string
|
||||
}
|
||||
shellutils.R(&OfferingListOptions{}, "offering-list", "List instance offerings", func(cli *zstack.SRegion, args *OfferingListOptions) error {
|
||||
offerings, err := cli.GetInstanceOfferings(args.OfferId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(offerings, len(offerings), 0, 0, []string{})
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -11,8 +11,8 @@ func init() {
|
||||
ClusterId string
|
||||
Id string
|
||||
}
|
||||
shellutils.R(&StorageListOptions{}, "primary-storage-list", "List storages", func(cli *zstack.SRegion, args *StorageListOptions) error {
|
||||
storages, err := cli.GetPrimaryStorages(args.ZoneId, args.ClusterId, args.Id)
|
||||
shellutils.R(&StorageListOptions{}, "storage-list", "List storages", func(cli *zstack.SRegion, args *StorageListOptions) error {
|
||||
storages, err := cli.GetStorages(args.ZoneId, args.ClusterId, args.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
37
pkg/util/zstack/shell/vip.go
Normal file
37
pkg/util/zstack/shell/vip.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/util/shellutils"
|
||||
"yunion.io/x/onecloud/pkg/util/zstack"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type VipListOptions struct {
|
||||
VipId string
|
||||
}
|
||||
shellutils.R(&VipListOptions{}, "vip-list", "List vips", func(cli *zstack.SRegion, args *VipListOptions) error {
|
||||
vips, err := cli.GetVirtualIPs(args.VipId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(vips, 0, 0, 0, []string{})
|
||||
return nil
|
||||
})
|
||||
|
||||
type VipCreateOptions struct {
|
||||
NAME string
|
||||
Desc string
|
||||
Ip string
|
||||
L3ID string
|
||||
}
|
||||
|
||||
shellutils.R(&VipCreateOptions{}, "vip-create", "Create vip", func(cli *zstack.SRegion, args *VipCreateOptions) error {
|
||||
vip, err := cli.CreateVirtualIP(args.NAME, args.Desc, args.Ip, args.L3ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(vip)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user