Documentation
¶
Index ¶
- Constants
- type CloudProvider
- type CloudProviderBase
- type CloudProviderImplementation
- type ImageInfo
- type InstanceInfo
- type MachineSpec
- type Manager
- func (cm *Manager) DeleteInstance(id string) error
- func (cm *Manager) DeleteProvider(name string) error
- func (cm *Manager) DeployInstance(instanceName string, cloudName string, cloudLocation string, ...) (InstanceInfo, error)
- func (cm *Manager) GetInstance(id string) (InstanceInfo, error)
- func (cm *Manager) GetInstances(excludeLocalInstance bool) ([]InstanceInfo, error)
- func (cm *Manager) GetInstancesWithUpdatedStatus() ([]InstanceInfo, error)
- func (cm *Manager) GetProvider(id string) (CloudProvider, error)
- func (cm *Manager) GetProviders() ([]CloudProvider, error)
- func (cm *Manager) InitInstance(instanceName string, kind string, kindID string, locationName string, ...) error
- func (cm *Manager) LogsRemoteInstance(id string) (string, error)
- func (cm *Manager) NewProvider(cloudName string, cloud string) (CloudProvider, error)
- func (cm *Manager) StartInstance(id string) error
- func (cm *Manager) StopInstance(id string) error
- func (cm *Manager) SupportedProviders() []string
- func (cm *Manager) TunnelInstance(id string) error
- func (cm *Manager) UpdateInstance(id string, ip string) error
- func (cm *Manager) UploadLocalImage(imagePath string, imageName string, cloudName string, cloudLocation string, ...) error
- type ProviderInfo
- type Type
- type VolumeInfo
Constants ¶
const ( ServerStateRunning = "running" ServerStateStopped = "stopped" ServerStateOther = "other" ServerStateChanging = "changing" KindLocalVM = "local_vm" KindCloudVM = "cloud_vm" // Scaleway cloud provider Scaleway = Type("scaleway") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CloudProvider ¶
type CloudProvider interface {
CloudProviderBase
CloudProviderImplementation
}
type CloudProviderBase ¶
type CloudProviderImplementation ¶
type CloudProviderImplementation interface {
// Config methods
SupportedLocations() (locations []string) // returns the supported locations for a specific cloud provider
AuthFields() (fields []string) // returns the fields that are required to authenticate for a specific cloud provider
SetAuth(auth map[string]string) error // sets the credentials for a cloud provider
Init() error // a cloud provider always needs to have Init called to configure it and test the credentials. If auth fails, Init should return an error
SupportedMachines(location string) (map[string]MachineSpec, error) // returns a map of machine ids and their hardware specifications. A user will choose the machines for their instance
// Instance methods
NewInstance(name string, image string, pubKey string, machineType string, location string) (id string, err error)
DeleteInstance(id string, location string) error
StartInstance(id string, location string) error
StopInstance(id string, location string) error
GetInstanceInfo(id string, location string) (InstanceInfo, error)
// Image methods
GetImages() (images map[string]ImageInfo, err error)
GetProtosImages() (images map[string]ImageInfo, err error)
AddImage(url string, hash string, version string, location string) (id string, err error)
UploadLocalImage(imagePath string, imageName string, location string, timeout time.Duration) (id string, err error)
RemoveImage(name string, location string) error
// Volume methods
// - size should by provided in megabytes
NewVolume(name string, size int, location string) (id string, err error)
DeleteVolume(id string, location string) error
AttachVolume(volumeID string, instanceID string, location string) error
DettachVolume(volumeID string, instanceID string, location string) error
}
CloudProviderImplementation allows interactions with cloud instances and images
type InstanceInfo ¶
type InstanceInfo struct {
ID string
Name string
PublicKey string // ed25519 public key
PublicIP string // this can be a public or private IP, depending on where the device is located
Kind string // type of instance: local_vm, cloud_vm
KindID string // ID of the cloud provider or device ID for local VM
Location string
Status string
Architecture string
Volumes []VolumeInfo
}
InstanceInfo holds information about a cloud instance
func (InstanceInfo) GetID ¶
func (i InstanceInfo) GetID() string
func (InstanceInfo) GetName ¶
func (i InstanceInfo) GetName() string
func (InstanceInfo) GetPublicIP ¶
func (i InstanceInfo) GetPublicIP() string
func (InstanceInfo) GetPublicKey ¶
func (i InstanceInfo) GetPublicKey() string
type MachineSpec ¶
type MachineSpec struct {
Cores uint32 // Nr of cores
Memory uint32 // MiB
DefaultStorage uint32 // GB
Bandwidth uint32 // Mbit
IncludedDataTransfer uint32 // GB. 0 for unlimited
Baremetal bool // true if machine is bare metal
PriceMonthly float32 // no currency conversion at the moment. Each cloud reports this differently
}
MachineSpec holds information about the hardware characteristics of vm or baremetal instance
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages cloud providers and instances
func CreateManager ¶
func CreateManager(db *db.DB, um *user.Manager, sm *pcrypto.Manager, p2p *p2p.P2P) (*Manager, error)
CreateManager creates and returns a cloud manager
func (*Manager) DeleteInstance ¶
DeleteInstance deletes an instance
func (*Manager) DeleteProvider ¶
DeleteProvider deletes a cloud provider from the db
func (*Manager) DeployInstance ¶
func (cm *Manager) DeployInstance(instanceName string, cloudName string, cloudLocation string, release release.Release, machineType string) (InstanceInfo, error)
DeployInstance deploys an instance on the provided cloud
func (*Manager) GetInstance ¶
func (cm *Manager) GetInstance(id string) (InstanceInfo, error)
GetInstance retrieves an instance from the db and returns it
func (*Manager) GetInstances ¶
func (cm *Manager) GetInstances(excludeLocalInstance bool) ([]InstanceInfo, error)
GetInstances returns all the instances from the db
func (*Manager) GetInstancesWithUpdatedStatus ¶
func (cm *Manager) GetInstancesWithUpdatedStatus() ([]InstanceInfo, error)
GetInstances returns all the instances from the db
func (*Manager) GetProvider ¶
func (cm *Manager) GetProvider(id string) (CloudProvider, error)
GetProvider returns a cloud provider instance from the db
func (*Manager) GetProviders ¶
func (cm *Manager) GetProviders() ([]CloudProvider, error)
GetProviders returns all the cloud providers from the db
func (*Manager) InitInstance ¶
func (*Manager) LogsRemoteInstance ¶
LogsRemoteInstance retrieves the Protos logs from an instance, via SSH
func (*Manager) NewProvider ¶
func (cm *Manager) NewProvider(cloudName string, cloud string) (CloudProvider, error)
NewProvider creates and returns a cloud provider. At this point it is not saved in the db
func (*Manager) StartInstance ¶
StartInstance starts an instance
func (*Manager) StopInstance ¶
StopInstance stops an instance
func (*Manager) SupportedProviders ¶
SupportedProviders returns a list of supported cloud providers
func (*Manager) TunnelInstance ¶
TunnelInstance creates and SSH tunnel to the instance
func (*Manager) UpdateInstance ¶
UpdateInstance updates an instance
type ProviderInfo ¶
type ProviderInfo struct {
CloudProviderImplementation
ID string
Name string
Type Type
Auth map[string]string
// contains filtered or unexported fields
}
ProviderInfo stores information about a cloud provider
func (ProviderInfo) GetInfo ¶
func (pi ProviderInfo) GetInfo() ProviderInfo
GetInfo returns the ProviderInfo struct. Seems redundant but it's used via the Provider interface
func (ProviderInfo) NameStr ¶
func (pi ProviderInfo) NameStr() string
NameStr returns the name of the cloud provider instance
func (ProviderInfo) Save ¶
func (pi ProviderInfo) Save() error
Save saves the provider information to disk
func (ProviderInfo) TypeStr ¶
func (pi ProviderInfo) TypeStr() string
TypeStr returns the cloud type formatted as string
type VolumeInfo ¶
VolumeInfo holds information about a data volume