cloudprovider

package
v2.3.6+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CloudVMStatusRunning = "running"
	CloudVMStatusSuspend = "suspend"
	CloudVMStatusStopped = "stopped"
	CloudVMStatusOther   = "other"
)

Variables

View Source
var ErrDuplicateId = errors.New("duplicate id")
View Source
var ErrInvalidStatus = errors.New("invalid status")
View Source
var (
	ErrNoSuchProvder = errors.New("no such provider")
)
View Source
var ErrNotFound = errors.New("id not found")
View Source
var ErrNotImplemented = errors.New("Not implemented")
View Source
var ErrNotSupported = errors.New("Not supported")
View Source
var ErrTimeout = errors.New("timeout")

Functions

func IsSupported

func IsSupported(provider string) bool

func IsValidCloudAccount

func IsValidCloudAccount(accessUrl, account, secret, provider string) error

func RegisterFactory

func RegisterFactory(factory ICloudProviderFactory)

func WaitDeleted

func WaitDeleted(res ICloudResource, interval time.Duration, timeout time.Duration) error

func WaitStatus

func WaitStatus(res ICloudResource, expect string, interval time.Duration, timeout time.Duration) error

Types

type IBillingResource

type IBillingResource interface {
	GetBillingType() string
	GetExpiredAt() time.Time
}

type ICloudDisk

type ICloudDisk interface {
	ICloudResource
	IBillingResource

	GetIStorge() ICloudStorage

	// GetStatus() string
	GetDiskFormat() string
	GetDiskSizeMB() int // MB
	GetIsAutoDelete() bool
	GetTemplateId() string
	GetDiskType() string
	GetFsFormat() string
	GetIsNonPersistent() bool

	GetDriver() string
	GetCacheMode() string
	GetMountpoint() string
	Delete() error

	CreateISnapshot(name string, desc string) (ICloudSnapshot, error)
	GetISnapshot(idStr string) (ICloudSnapshot, error)
	GetISnapshots() ([]ICloudSnapshot, error)

	Resize(newSize int64) error
	Reset(snapshotId string) error
}

type ICloudEIP

type ICloudEIP interface {
	ICloudResource

	GetIpAddr() string
	GetMode() string
	GetAssociationType() string
	GetAssociationExternalId() string

	GetBandwidth() int

	GetInternetChargeType() string

	GetManagerId() string

	Delete() error

	Associate(instanceId string) error
	Dissociate() error

	ChangeBandwidth(bw int) error
}

type ICloudHost

type ICloudHost interface {
	ICloudResource

	GetIVMs() ([]ICloudVM, error)
	GetIVMById(id string) (ICloudVM, error)

	GetIWires() ([]ICloudWire, error)
	GetIStorages() ([]ICloudStorage, error)
	GetIStorageById(id string) (ICloudStorage, error)

	// GetStatus() string     // os status
	GetEnabled() bool      // is enabled
	GetHostStatus() string // service status
	GetAccessIp() string   //
	GetAccessMac() string  //
	GetSysInfo() jsonutils.JSONObject
	GetSN() string
	GetCpuCount() int8
	GetNodeCount() int8
	GetCpuDesc() string
	GetCpuMhz() int
	GetMemSizeMB() int
	GetStorageSizeMB() int
	GetStorageType() string
	GetHostType() string

	GetManagerId() string

	CreateVM(name string, imgId string, sysDiskSize int, cpu int, memMB int, vswitchId string, ipAddr string, desc string,
		passwd string, storageType string, diskSizes []int, publicKey string, extSecGrpId string, userData string) (ICloudVM, error)
}

type ICloudImage

type ICloudImage interface {
	ICloudResource

	Delete() error
	GetIStoragecache() ICloudStoragecache
}

type ICloudNetwork

type ICloudNetwork interface {
	ICloudResource

	GetIWire() ICloudWire
	// GetStatus() string
	GetIpStart() string
	GetIpEnd() string
	GetIpMask() int8
	GetGateway() string
	GetServerType() string
	GetIsPublic() bool

	Delete() error

	GetAllocTimeoutSeconds() int
}

type ICloudNic

type ICloudNic interface {
	GetIP() string
	GetMAC() string
	GetDriver() string
	GetINetwork() ICloudNetwork
}

type ICloudProvider

type ICloudProvider interface {
	GetId() string
	GetName() string
	GetIRegions() []ICloudRegion
	GetSysInfo() (jsonutils.JSONObject, error)
	IsPublicCloud() bool

	GetIRegionById(id string) (ICloudRegion, error)

	GetIHostById(id string) (ICloudHost, error)
	GetIVpcById(id string) (ICloudVpc, error)
	GetIStorageById(id string) (ICloudStorage, error)
	GetIStoragecacheById(id string) (ICloudStoragecache, error)

	GetBalance() (float64, error)

	GetSubAccounts() ([]SSubAccount, error)
}

func GetProvider

func GetProvider(providerId, providerName, accessUrl, account, secret, provider string) (ICloudProvider, error)

type ICloudProviderFactory

type ICloudProviderFactory interface {
	GetProvider(providerId, providerName, url, account, secret string) (ICloudProvider, error)
	GetId() string
}

type ICloudRegion

type ICloudRegion interface {
	ICloudResource

	GetLatitude() float32
	GetLongitude() float32

	GetIZones() ([]ICloudZone, error)
	GetIVpcs() ([]ICloudVpc, error)
	GetIEips() ([]ICloudEIP, error)
	GetISnapshots() ([]ICloudSnapshot, error)

	GetISnapshotById(snapshotId string) (ICloudSnapshot, error)
	GetIZoneById(id string) (ICloudZone, error)
	GetIVpcById(id string) (ICloudVpc, error)
	GetIHostById(id string) (ICloudHost, error)
	GetIStorageById(id string) (ICloudStorage, error)
	GetIStoragecacheById(id string) (ICloudStoragecache, error)

	CreateIVpc(name string, desc string, cidr string) (ICloudVpc, error)

	CreateEIP(name string, bwMbps int, chargeType string) (ICloudEIP, error)

	GetIEipById(id string) (ICloudEIP, error)

	GetProvider() string
}

type ICloudResource

type ICloudResource interface {
	GetId() string
	GetName() string
	GetGlobalId() string

	GetStatus() string

	Refresh() error

	IsEmulated() bool
	GetMetadata() *jsonutils.JSONDict
}

type ICloudSecurityGroup

type ICloudSecurityGroup interface {
	ICloudResource
	GetDescription() string
	GetRules() ([]secrules.SecurityRule, error)
}

type ICloudSnapshot

type ICloudSnapshot interface {
	ICloudResource
	GetManagerId() string
	GetSize() int32
	GetDiskId() string
	GetDiskType() string
	Delete() error
	GetRegionId() string
}

type ICloudStorage

type ICloudStorage interface {
	ICloudResource

	GetIStoragecache() ICloudStoragecache

	GetIZone() ICloudZone
	GetIDisks() ([]ICloudDisk, error)

	GetStorageType() string
	GetMediumType() string
	GetCapacityMB() int // MB
	GetStorageConf() jsonutils.JSONObject
	GetEnabled() bool

	GetManagerId() string

	CreateIDisk(name string, sizeGb int, desc string) (ICloudDisk, error)
	GetIDisk(idStr string) (ICloudDisk, error)
}

type ICloudStoragecache

type ICloudStoragecache interface {
	ICloudResource

	GetIImages() ([]ICloudImage, error)

	GetManagerId() string

	CreateIImage(snapshotId, imageName, osType, imageDesc string) (ICloudImage, error)

	DownloadImage(userCred mcclient.TokenCredential, imageId string, extId string, path string) (jsonutils.JSONObject, error)

	UploadImage(userCred mcclient.TokenCredential, imageId string, osArch, osType, osDist string, extId string, isForce bool) (string, error)
}

type ICloudVM

type ICloudVM interface {
	ICloudResource
	IBillingResource

	GetCreateTime() time.Time
	GetIHost() ICloudHost

	GetIDisks() ([]ICloudDisk, error)
	GetINics() ([]ICloudNic, error)

	GetIEIP() (ICloudEIP, error)

	GetVcpuCount() int8
	GetVmemSizeMB() int //MB
	GetBootOrder() string
	GetVga() string
	GetVdi() string
	GetOSType() string
	GetOSName() string
	GetBios() string
	GetMachine() string

	SyncSecurityGroup(secgroupId string, name string, rules []secrules.SecurityRule) error
	GetHypervisor() string

	StartVM() error
	StopVM(isForce bool) error
	DeleteVM() error

	UpdateVM(name string) error

	UpdateUserData(userData string) error

	RebuildRoot(imageId string, passwd string, publicKey string, sysSizeGB int) (string, error)

	DeployVM(name string, password string, publicKey string, deleteKeypair bool, description string) error

	ChangeConfig(instanceId string, ncpu int, vmem int) error
	GetVNCInfo() (jsonutils.JSONObject, error)
	AttachDisk(diskId string) error
	DetachDisk(diskId string) error
}

type ICloudVpc

type ICloudVpc interface {
	ICloudResource

	GetRegion() ICloudRegion
	GetIsDefault() bool
	GetCidrBlock() string
	// GetStatus() string
	GetIWires() ([]ICloudWire, error)
	GetISecurityGroups() ([]ICloudSecurityGroup, error)

	GetManagerId() string

	Delete() error

	GetIWireById(wireId string) (ICloudWire, error)

	SyncSecurityGroup(secgroupId string, name string, rules []secrules.SecurityRule) (string, error)
}

type ICloudWire

type ICloudWire interface {
	ICloudResource
	GetIVpc() ICloudVpc
	GetIZone() ICloudZone
	GetINetworks() ([]ICloudNetwork, error)
	GetBandwidth() int

	GetINetworkById(netid string) (ICloudNetwork, error)

	CreateINetwork(name string, cidr string, desc string) (ICloudNetwork, error)
}

type ICloudZone

type ICloudZone interface {
	ICloudResource

	GetIRegion() ICloudRegion

	GetIHosts() ([]ICloudHost, error)
	GetIHostById(id string) (ICloudHost, error)

	GetIStorages() ([]ICloudStorage, error)
	GetIStorageById(id string) (ICloudStorage, error)
}

type SSubAccount

type SSubAccount struct {
	Name    string
	State   string
	Account string
}

Jump to

Keyboard shortcuts

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