cloud

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2020 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ALI     = "ali"
	TENCENT = "tencent"
)

Variables

View Source
var (
	CloudConfig  Config
	CloudRequest Request
)

Functions

This section is empty.

Types

type AliProvider

type AliProvider struct {
	Config
	// contains filtered or unexported fields
}

func (*AliProvider) Create

func (a *AliProvider) Create(r Request) (*Response, error)

func (*AliProvider) CreateNetwork added in v0.0.4

func (a *AliProvider) CreateNetwork(r Request) (*Response, error)

func (*AliProvider) Delete

func (a *AliProvider) Delete(...string) error

func (*AliProvider) InstanceInfo

func (a *AliProvider) InstanceInfo(id string) (*VM, error)

func (*AliProvider) List

func (a *AliProvider) List(r Request) (*Response, error)

func (*AliProvider) QueryFlavor added in v0.0.4

func (a *AliProvider) QueryFlavor(flavor string, zone string, charge string, strategy string) string

func (*AliProvider) VPC

func (a *AliProvider) VPC(r Request) (string, error)

type Config

type Config struct {
	Provider     string
	Region       string
	AccessKey    string
	AccessSecret string
}

Config is client config

type Disk

type Disk struct {
	Name string
	Size string
}

type Flavor added in v0.0.4

type Flavor struct {
	Region string
	Zone   string
	VMType string //real cloud provider type
	Image  string
}

type Interface

type Interface interface {
	CreateNetwork(request Request) (*Response, error)
	Create(request Request) (*Response, error)
	Delete(...string) error
	QueryFlavor(flavor string, zone string, charge string, strategy string) string
}

func NewProvider

func NewProvider(config Config) Interface

type Region added in v0.0.4

type Region interface {
	QueryFlavor(region string, zone string, vmType string) (Flavor, error)
}

Region return real vm type on some region zone

input: cn-hangzhou cn-hangzhou-b 2C4G
output: ecs.c6.large m-j6c7cmqwpqwn8onaey27

type Request

type Request struct {
	//VM numbers
	Num             int
	Image           string
	Flavor          string
	NamePrefix      string
	Passwd          string
	KeyPair         string
	FIP             bool
	Disks           []Disk
	ZoneID          string
	VPCID           string // if not exist, create it
	SwitchID        string // if not exist, create it
	SecuretyGroupID string // if not exist, create it
	ExternalArgs    map[string]string
}

Request is the create vm request

type Response

type Response struct {
	VPCID           string
	SwitchID        string
	SecuretyGroupID string
	VMs             []VM
}

Response is

type TencentProvider

type TencentProvider struct {
	Config
}

func (*TencentProvider) Create

func (t *TencentProvider) Create(request Request) (*Response, error)

func (*TencentProvider) CreateNetwork added in v0.0.4

func (t *TencentProvider) CreateNetwork(request Request) (*Response, error)

func (*TencentProvider) Delete

func (t *TencentProvider) Delete(...string) error

func (*TencentProvider) QueryFlavor added in v0.0.4

func (t *TencentProvider) QueryFlavor(flavor, zone, charge, strategy string) string

type VM

type VM struct {
	ID           string
	IP           string
	FIP          string
	Name         string
	CPU          int
	Memory       int
	CreationTime string
}

VM is

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL