lobster

package module
v0.0.0-...-dd062b7 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2018 License: Apache-2.0 Imports: 42 Imported by: 0

README

Lobster
=======

Introduction
------------

Lobster is a simple hourly billing panel for virtual machine services. Lobster
does not manage virtual machines directly -- instead, it relies on backends that
it communicates with through VM interfaces; several backends are supported.

See https://github.com/LunaNode/lobster/wiki/GettingStarted to get started.

Regions
-------

Lobster allows multiple regions to be defined. Each region has a separate
virtual machine interface, although the interface type may be the same. Plans
are shared across regions, but images are not.

Billing
-------

Lobster currently only supports a prepaid hourly billing model. Users pay via
some payment interface, and once payment is recorded as completed, credit is
added to their account. If a user is running out of credit, Lobster will send
low credit notifications; once credit reaches zero, services are suspended, and
eventually the account is terminated.

There are three services billed by Lobster:

* Virtual machines: have an hourly price defined in the plan
* Image storage: billed based on a configurable price per gigabyte-hour
* Bandwidth: users are given a bandwidth pool allocation in each region based on the sum of the plan bandwidth of their virtual machines. If a user uses more traffic across their VMs in some region than this allocation, they will be charged at a configurable price per gigabyte. Bandwidth is billed on a per-calendar-month basis, so usage and allocations are reset each month. Note that if a user only provisions a VM for one hour, then they will receive only a proportional allocation (the bandwidth specified in the plan is the monthly allocation).

Backends
--------

Different backends have different features, but Lobster tries to support as
much as possible. Currently these backends are supported:

* OpenStack
* SolusVM
* CloudStack (experimental)

These provider-specific APIs are also supported:

* Luna Node
* Digital Ocean
* Linode
* Vultr

Lobster also supports using Cloug [1] providers as VM backends. Cloug is a cloud
API library that provides a common interface to access multiple APIs, just as
Lobster provides a common panel. Cloug is still under development, but the aim
is to eventually move all VM interface code on Lobster to Cloug.

[1] https://github.com/LunaNode/cloug

Payment gateways
----------------

Payment is generally accepted via a pay-callback system, where we direct the
user to a payment gateway and then wait for a secure callback notification from
the gateway that confirms payment.

Supported payment gateways:

* Paypal
* Coinbase

Contributing
------------

The Lobster project uses Github for coordination.

URL: https://github.com/LunaNode/lobster

Note that per the Apache license, any contribution you submit for inclusion in
Lobster shall be under the terms of the Apache license. See Section 5 of the
Apache License Version 2.0 for details.

Documentation

Index

Constants

View Source
const ALPHANUMERIC = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
View Source
const API_MAX_REQUEST_LENGTH = 32 * 1024
View Source
const BILLING_DISPLAY_DECIMALS = 3
View Source
const BILLING_PRECISION = 1000000 // credit is in units of 1/BILLING_PRECISION -dollars

billing constants

View Source
const BILLING_VM_FREQUENCY = 1

how frequently to bill virtual machines in hours

note that this is NOT the billing granularity, which is set in configuration file
instead, this determines how often to apply VM charges and do bandwidth accounting
View Source
const DATE_FORMAT = "2 January 2006"
View Source
const IMAGE_QUERY = "SELECT id, user_id, region, name, identification, status, source_vm FROM images"
View Source
const MAX_API_RESTRICTION = 512
View Source
const MAX_PASSWORD_LENGTH = 512
View Source
const MAX_USERNAME_LENGTH = 128
View Source
const MAX_VM_NAME_LENGTH = 64
View Source
const MINIMUM_CREDIT = BILLING_PRECISION // minimum credit to do things like create VMs
View Source
const MIN_PASSWORD_LENGTH = 6
View Source
const MIN_USERNAME_LENGTH = 3
View Source
const MYSQL_TIME_FORMAT = "2006-01-02 15:04:05"
View Source
const PWRESET_EXPIRE_MINUTES = 60
View Source
const SESSION_COOKIE_NAME = "lobsterSession"
View Source
const SESSION_UID_LENGTH = 64
View Source
const SSHKEY_QUERY = "SELECT id, user_id, name, val FROM sshkeys"
View Source
const TEST_BANDWIDTH = 1000
View Source
const TIME_FORMAT = "2 January 2006 15:04:05 MST"
View Source
const VM_QUERY = "SELECT vms.id, vms.user_id, vms.region, vms.name, vms.identification, " +
	"vms.status, vms.task_pending, vms.external_ip, vms.private_ip, " +
	"vms.time_created, vms.suspended, vms.plan_id, " +
	"plans.name, plans.price, plans.ram, plans.cpu, plans.storage, plans.bandwidth, " +
	"users.username, users.email " +
	"FROM vms, plans, users " +
	"WHERE vms.plan_id = plans.id AND vms.user_id = users.id"

Variables

Functions

func AntifloodAction

func AntifloodAction(ip string, action string)

func AntifloodCheck

func AntifloodCheck(ip string, action string, maxCount int) bool

func CSRFGenerate

func CSRFGenerate(session *Session) string

func ExtractIP

func ExtractIP(ipport string) string

Extracts IP address from http.Request.RemoteAddr (127.0.0.1:9999 -> 127.0.0.1)

func GetDatabaseString

func GetDatabaseString() string

func GetDecoder

func GetDecoder() *schema.Decoder

func HandleWebsockify

func HandleWebsockify(ipport string, password string) string

Creates websockify instance if not already setup, initializes token, and returns URL to redirect to

func HandleWssh

func HandleWssh(ipport string, username string, password string) string

Creates wssh instance if not already setup, initializes token, and returns URL to redirect to

func LobsterHandler

func LobsterHandler(h http.Handler) http.Handler

func LogAction

func LogAction(userId int, ip string, name string, details string)

func MailWrap

func MailWrap(userId int, tmpl string, subparams interface{}, ccAdmin bool)

func RedirectHandler

func RedirectHandler(target string) func(w http.ResponseWriter, r *http.Request)

func RedirectMessage

func RedirectMessage(w http.ResponseWriter, r *http.Request, target string, msg utils.Message)

func RedirectMessageExtra

func RedirectMessageExtra(w http.ResponseWriter, r *http.Request, target string, msg utils.Message, extra map[string]string)

func RegisterAPIHandler

func RegisterAPIHandler(path string, f APIHandlerFunc, method string)

func RegisterAdminHandler

func RegisterAdminHandler(path string, f AdminHandlerFunc, onlyPost bool)

func RegisterHttpHandler

func RegisterHttpHandler(path string, f http.HandlerFunc, onlyPost bool)

func RegisterPanelHandler

func RegisterPanelHandler(path string, f PanelHandlerFunc, onlyPost bool)

func RegisterPanelWidget

func RegisterPanelWidget(name string, widget PanelWidget)

func RegisterPaymentInterface

func RegisterPaymentInterface(method string, payInterface PaymentInterface)

func RegisterSplashRoute

func RegisterSplashRoute(path string, template string)

func RegisterVmInterface

func RegisterVmInterface(region string, vmi VmInterface)

func RenderTemplate

func RenderTemplate(w http.ResponseWriter, category string, tmpl string, data interface{}) error

func ReportError

func ReportError(err error, description string, detail string)

func Run

func Run()

func SessionWrap

func SessionWrap(handler func(w http.ResponseWriter, r *http.Request, session *Session)) func(w http.ResponseWriter, r *http.Request)

func Setup

func Setup(cfgPath string)

func TestReset

func TestReset()

func TestSetup

func TestSetup()

func TestUser

func TestUser() int

Creates user and returns user id.

func TestVm

func TestVm(userId int) int

func TransactionAdd

func TransactionAdd(userId int, gateway string, gatewayIdentifier string, notes string, amount int64, fee int64)

func UserApplyCharge

func UserApplyCharge(userId int, name string, detail string, k string, amount int64)

func UserApplyCredit

func UserApplyCredit(userId int, amount int64, detail string)

func UserBandwidthSummary

func UserBandwidthSummary(userId int) map[string]*BandwidthSummary

func UserCreate

func UserCreate(username string, password string, email string) (int, error)

Types

type APIHandlerFunc

type APIHandlerFunc func(http.ResponseWriter, *http.Request, int, []byte)

type AccountCreatedEmail

type AccountCreatedEmail struct {
	UserId   int
	Username string
	Email    string
}

type AccountPasswordForm

type AccountPasswordForm struct {
	OldPassword        string `schema:"old_password"`
	NewPassword        string `schema:"new_password"`
	NewPasswordConfirm string `schema:"new_password_confirm"`
}

type AdminFormParams

type AdminFormParams struct {
	Frame FrameParams
	Token string
}

type AdminHandlerFunc

type AdminHandlerFunc func(http.ResponseWriter, *http.Request, *Session, FrameParams)

type AdminImagesAddForm

type AdminImagesAddForm struct {
	Name           string `schema:"name"`
	Region         string `schema:"region"`
	Identification string `schema:"identification"`
}

type AdminImagesParams

type AdminImagesParams struct {
	Frame   FrameParams
	Images  []*Image
	Regions []string
	Token   string
}

type AdminPlanParams

type AdminPlanParams struct {
	Frame   FrameParams
	Plan    *Plan
	Regions []string
	Token   string
}

type AdminPlansAddForm

type AdminPlansAddForm struct {
	Name      string  `schema:"name"`
	Price     float64 `schema:"price"`
	Ram       int     `schema:"ram"`
	Cpu       int     `schema:"cpu"`
	Storage   int     `schema:"storage"`
	Bandwidth int     `schema:"bandwidth"`
	Global    string  `schema:"global"`
}

type AdminPlansParams

type AdminPlansParams struct {
	Frame   FrameParams
	Plans   []*Plan
	Regions []string
	Token   string
}

type AdminRegionsParams

type AdminRegionsParams struct {
	Frame   FrameParams
	Regions []Region
	Token   string
}

type AdminUserCreditForm

type AdminUserCreditForm struct {
	Credit      float64 `schema:"credit"`
	Description string  `schema:"description"`
}

type AdminUserParams

type AdminUserParams struct {
	Frame           FrameParams
	User            *User
	StatusAction    string // action that admin can take on this user, either "disable" or "enable" depending on current user status
	VirtualMachines []*VirtualMachine
	Token           string
}

type AdminUserProcessFunc

type AdminUserProcessFunc func(w http.ResponseWriter, r *http.Request, session *Session, frameParams FrameParams, user *User)

type AdminUsersParams

type AdminUsersParams struct {
	Frame FrameParams
	Users []*User
}

type AdminVirtualMachinesParams

type AdminVirtualMachinesParams struct {
	Frame           FrameParams
	VirtualMachines []*VirtualMachine
}

type ApiActionRestriction

type ApiActionRestriction struct {
	Path   string `json:"path"`
	Method string `json:"method"`
}

type ApiAddForm

type ApiAddForm struct {
	Label          string `schema:"label"`
	RestrictAction string `schema:"restrict_action"`
	RestrictIp     string `schema:"restrict_ip"`
}

type ApiKey

type ApiKey struct {
	Id          int
	Label       string
	UserId      int
	ApiId       string
	CreatedTime time.Time
	Nonce       int64

	// only set on apiCreate
	ApiKey string
}

type AuthCreateForm

type AuthCreateForm struct {
	Username    string `schema:"username"`
	Password    string `schema:"password"`
	Email       string `schema:"email"`
	AcceptTerms string `schema:"acceptTermsOfService"`
}

type AuthLoginForm

type AuthLoginForm struct {
	Username string `schema:"username"`
	Password string `schema:"password"`
}

type AuthPwresetParams

type AuthPwresetParams struct {
	Title         string
	Message       string
	Token         string
	PwresetUserId string
	PwresetToken  string
}

type AuthPwresetRequestForm

type AuthPwresetRequestForm struct {
	Username string `schema:"username"`
	Email    string `schema:"email"`
}

type AuthPwresetSubmitForm

type AuthPwresetSubmitForm struct {
	UserId          int    `schema:"pwreset_user_id"`
	Token           string `schema:"pwreset_token"`
	Password        string `schema:"password"`
	PasswordConfirm string `schema:"password_confirm"`
}

type BandwidthSummary

type BandwidthSummary struct {
	Used            int64
	Allocated       int64
	Billed          int64
	NotifiedPercent int
	ActualPercent   float64
}

type BandwidthUsageEmail

type BandwidthUsageEmail struct {
	UtilPercent int
	Region      string
	Fee         int64
}

type Charge

type Charge struct {
	Id     int
	UserId int
	Name   string
	Detail string
	Key    string
	Time   time.Time
	Amount int64
}

func ChargeList

func ChargeList(userId int, year int, month time.Month) []*Charge

type Config

type Config struct {
	Default              ConfigDefault
	Vm                   ConfigVm
	Billing              ConfigBilling
	BillingNotifications ConfigBillingNotifications
	BillingTermination   ConfigBillingTermination
	Session              ConfigSession
	Database             ConfigDatabase
	Http                 ConfigHttp
	Email                ConfigEmail
	Novnc                ConfigNovnc
	Wssh                 ConfigWssh
}

func GetConfig

func GetConfig() *Config

func LoadConfig

func LoadConfig(cfgPath string) *Config

type ConfigBilling

type ConfigBilling struct {
	BandwidthOverageFee float64
	StorageFee          float64
	Currency            string
	BillingInterval     int
	BillingVmMinimum    int
	DepositMinimum      float64
	DepositMaximum      float64
}

type ConfigBillingNotifications

type ConfigBillingNotifications struct {
	LowBalanceIntervals int
	Frequency           int
}

type ConfigBillingTermination

type ConfigBillingTermination struct {
	TerminateBalanceIntervals int
	TerminateMinNotifications int
	SuspendBalanceIntervals   int
	SuspendMinNotifications   int
}

type ConfigDatabase

type ConfigDatabase struct {
	Host     string
	Username string
	Password string
	Name     string
}

type ConfigDefault

type ConfigDefault struct {
	UrlBase     string
	AdminEmail  string
	FromEmail   string
	ProxyHeader string
	Debug       bool
	Language    string
}

type ConfigEmail

type ConfigEmail struct {
	Host     string
	Port     int
	NoTLS    bool
	Username string
	Password string
}

type ConfigHttp

type ConfigHttp struct {
	Addr string
}

type ConfigNovnc

type ConfigNovnc struct {
	Url    string
	Listen string
}

type ConfigSession

type ConfigSession struct {
	Domain string
	Secure bool
}

type ConfigVm

type ConfigVm struct {
	MaximumIps int
}

type ConfigWssh

type ConfigWssh struct {
	Url    string
	Listen string
}

type CreditSummary

type CreditSummary struct {
	Credit        int64
	Hourly        int64
	Daily         int64
	Monthly       int64
	DaysRemaining string
	Status        string
}

func UserCreditSummary

func UserCreditSummary(userId int) *CreditSummary

type Database

type Database struct {
	// contains filtered or unexported fields
}

func GetDatabase

func GetDatabase() *Database

func MakeDatabase

func MakeDatabase() *Database

func (*Database) Exec

func (this *Database) Exec(q string, args ...interface{}) Result

func (*Database) Query

func (this *Database) Query(q string, args ...interface{}) Rows

func (*Database) QueryRow

func (this *Database) QueryRow(q string, args ...interface{}) Row

type EmailParams

type EmailParams struct {
	UserId   int
	Username string
	Email    string
	UrlBase  string
	Params   interface{}
}

type ErrorEmail

type ErrorEmail struct {
	Error       string
	Description string
	Detail      string
}

type FrameParams

type FrameParams struct {
	Message    utils.Message
	Error      bool
	UserId     int
	Admin      bool
	OriginalId int      // non-zero only if admin is logged in as another user
	Styles     []string // additional CSS
	Scripts    []string // additional JS
}

type Image

type Image struct {
	Id             int
	UserId         int
	Region         string
	Name           string
	Identification string
	Status         string
	SourceVm       int

	Info *ImageInfo
}

type ImageAddForm

type ImageAddForm struct {
	Region   string `schema:"region"`
	Name     string `schema:"name"`
	Location string `schema:"location"`
	Format   string `schema:"format"`
}

type ImageInfo

type ImageInfo struct {
	Size    int64
	Status  ImageStatus
	Details map[string]string
}

type ImageStatus

type ImageStatus int
const (
	ImagePending ImageStatus = iota
	ImageActive
	ImageError
)

type IpAddress

type IpAddress struct {
	Ip        string
	PrivateIp string // blank means N/A

	CanRdns  bool
	Hostname string // current rDNS setting, always blank if CanRdns is false
}

type KeyAddForm

type KeyAddForm struct {
	Name string `schema:"name"`
	Key  string `schema:"key"`
}

type LowCreditEmail

type LowCreditEmail struct {
	Credit         int64
	Hourly         int64
	RemainingHours int
}

type NewVMRegionForm

type NewVMRegionForm struct {
	Name    string `schema:"name"`
	PlanId  int    `schema:"plan_id"`
	ImageId int    `schema:"image_id"`
	KeyId   int    `schema:"key_id"`
}

type PanelAccountParams

type PanelAccountParams struct {
	Frame FrameParams
	User  *User
	Keys  []*ApiKey
	Token string
}

type PanelBillingParams

type PanelBillingParams struct {
	Frame          FrameParams
	CreditSummary  *CreditSummary
	PaymentMethods []string
}

type PanelChargesParams

type PanelChargesParams struct {
	Frame   FrameParams
	Year    int
	Month   time.Month
	Charges []*Charge

	Previous time.Time
	Next     time.Time
}

type PanelDashboardParams

type PanelDashboardParams struct {
	Frame            FrameParams
	VirtualMachines  []*VirtualMachine
	CreditSummary    *CreditSummary
	BandwidthSummary map[string]*BandwidthSummary
	WidgetData       map[string]interface{}
}

type PanelFormParams

type PanelFormParams struct {
	Frame FrameParams
	Token string
}

type PanelHandlerFunc

type PanelHandlerFunc func(http.ResponseWriter, *http.Request, *Session, FrameParams)

type PanelImageDetailsParams

type PanelImageDetailsParams struct {
	Frame FrameParams
	Image *Image
}

type PanelImagesParams

type PanelImagesParams struct {
	Frame   FrameParams
	Images  []*Image
	Regions []string
	Token   string
}

type PanelKeysParams

type PanelKeysParams struct {
	Frame FrameParams
	Keys  []*SSHKey
	Token string
}

type PanelNewVMParams

type PanelNewVMParams struct {
	Frame   FrameParams
	Regions []string
}

type PanelNewVMRegionParams

type PanelNewVMRegionParams struct {
	Frame        FrameParams
	Region       string
	PublicImages []*Image
	UserImages   []*Image
	Plans        []*Plan
	Keys         []*SSHKey
	Token        string
}

type PanelVMParams

type PanelVMParams struct {
	Frame  FrameParams
	Vm     *VirtualMachine
	Images []*Image
	Plans  []*Plan
	Token  string
}

type PanelVirtualMachinesParams

type PanelVirtualMachinesParams struct {
	Frame           FrameParams
	VirtualMachines []*VirtualMachine
}

type PanelWidget

type PanelWidget interface {
	// returns struct that will be passed to the panel dashboard template
	Prepare(session *Session) interface{}
}

type PanelWidgetFunc

type PanelWidgetFunc func(*Session) interface{}

func (PanelWidgetFunc) Prepare

func (f PanelWidgetFunc) Prepare(session *Session) interface{}

type PayForm

type PayForm struct {
	Gateway string  `schema:"gateway"`
	Amount  float64 `schema:"amount"`
}

type PaymentInterface

type PaymentInterface interface {
	Payment(w http.ResponseWriter, r *http.Request, frameParams FrameParams, userId int, username string, amount float64)
}

type PaymentProcessedEmail

type PaymentProcessedEmail *Transaction

type Plan

type Plan struct {
	Id        int
	Name      string
	Price     int64
	Ram       int
	Cpu       int
	Storage   int
	Bandwidth int
	Global    bool
	Enabled   bool

	// region-specific identification from planGet
	Identification string

	// loadable region bindings, if not global
	// maps from region to identification
	RegionPlans map[string]string

	// loadable metadata (key-value pairs)
	Metadata map[string]string
}

func (*Plan) LoadMetadata

func (plan *Plan) LoadMetadata()

func (*Plan) LoadRegionPlans

func (plan *Plan) LoadRegionPlans()

type PwresetRequestEmail

type PwresetRequestEmail string

type Region

type Region struct {
	Region  string
	Enabled bool
}

type Result

type Result struct {
	// contains filtered or unexported fields
}

func (Result) LastInsertId

func (r Result) LastInsertId() int

func (Result) RowsAffected

func (r Result) RowsAffected() int

type Row

type Row struct {
	// contains filtered or unexported fields
}

func (Row) Scan

func (r Row) Scan(dest ...interface{})

type Rows

type Rows struct {
	// contains filtered or unexported fields
}

func (Rows) Close

func (r Rows) Close()

func (Rows) Next

func (r Rows) Next() bool

func (Rows) Scan

func (r Rows) Scan(dest ...interface{})

type SSHKey

type SSHKey struct {
	ID     int
	UserID int
	Name   string
	Key    string
}

type Session

type Session struct {
	Id         string
	UserId     int
	Admin      bool
	OriginalId int // user id prior to logging in as another user
	Regenerate bool
}

func (*Session) IsLoggedIn

func (this *Session) IsLoggedIn() bool

func (*Session) Reset

func (this *Session) Reset()

type SplashTemplateParams

type SplashTemplateParams struct {
	Title   string
	Message string
	Token   string
}

type Transaction

type Transaction struct {
	Id                int
	UserId            int
	Gateway           string
	GatewayIdentifier string
	Notes             string
	Amount            int64
	Fee               int64
	Time              time.Time
}

func TransactionGet

func TransactionGet(transactionId int) *Transaction

func TransactionGetByGateway

func TransactionGetByGateway(gateway string, gatewayIdentifier string) *Transaction

func TransactionList

func TransactionList() []*Transaction

type User

type User struct {
	Id                int
	Username          string
	Email             string
	CreateTime        time.Time
	Credit            int64
	VmLimit           int
	LastBillingNotify time.Time
	Status            string
	Admin             bool
}

func UserDetails

func UserDetails(userId int) *User

func UserList

func UserList() []*User

type VMIAddresses

type VMIAddresses interface {
	VmAddresses(vm *VirtualMachine) ([]*IpAddress, error)
	VmAddAddress(vm *VirtualMachine) error
	VmRemoveAddress(vm *VirtualMachine, ip string, privateip string) error
	VmSetRdns(vm *VirtualMachine, ip string, hostname string) error
}

type VMIImages

type VMIImages interface {
	// Download an image from an external URL.
	// Format is currently either 'template' or 'iso' in the form, although user may provide arbitrary format string.
	ImageFetch(url string, format string) (string, error)

	ImageInfo(imageIdentification string) (*ImageInfo, error)
	ImageDelete(imageIdentification string) error

	// List public images in backend.
	// Only Name, Identification should be set.
	ImageList() ([]*Image, error)
}

type VMIPlans

type VMIPlans interface {
	PlanList() ([]*Plan, error)
}

type VMIReimage

type VMIReimage interface {
	VmReimage(vm *VirtualMachine, imageIdentification string) error
}

type VMIRename

type VMIRename interface {
	VmRename(vm *VirtualMachine, name string) error
}

type VMIResize

type VMIResize interface {
	VmResize(vm *VirtualMachine, plan *Plan) error
}

type VMISnapshot

type VMISnapshot interface {
	// On success, should return image identification of a created snapshot.
	// (if backend store images and snapshots separately, the interface can tag the identification, e.g. "snapshot:XYZ" and "image:ABC")
	VmSnapshot(vm *VirtualMachine) (string, error)
}

type VMIVmCreateOptions

type VMIVmCreateOptions struct {
	ImageIdentification string
	SSHKey              SSHKey
}

type VMIVnc

type VMIVnc interface {
	// On success, url is a link that we should redirect to.
	VmVnc(vm *VirtualMachine) (string, error)
}

type VMReimageForm

type VMReimageForm struct {
	Image int `schema:"image"`
}

type VMResizeForm

type VMResizeForm struct {
	PlanId int `schema:"plan_id"`
}

type VirtualMachine

type VirtualMachine struct {
	Id             int
	UserId         int
	Region         string
	Name           string
	Identification string
	Status         string
	TaskPending    bool
	ExternalIP     string
	PrivateIP      string
	CreatedTime    time.Time
	Suspended      string
	Plan           Plan
	User           User

	Info      *VmInfo
	Addresses []*IpAddress
}

func (*VirtualMachine) Action

func (vm *VirtualMachine) Action(action string, value string) error

func (*VirtualMachine) AddAddress

func (vm *VirtualMachine) AddAddress() error

func (*VirtualMachine) Delete

func (vm *VirtualMachine) Delete(userId int) error

func (*VirtualMachine) LoadAddresses

func (vm *VirtualMachine) LoadAddresses() error

func (*VirtualMachine) LoadInfo

func (vm *VirtualMachine) LoadInfo()

func (*VirtualMachine) Metadata

func (vm *VirtualMachine) Metadata(k string, d string) string

Returns the metadata value if set, or d (default) otherwise.

func (*VirtualMachine) Reboot

func (vm *VirtualMachine) Reboot() error

func (*VirtualMachine) RemoveAddress

func (vm *VirtualMachine) RemoveAddress(ip string, privateip string) error

func (*VirtualMachine) Rename

func (vm *VirtualMachine) Rename(name string) error

func (*VirtualMachine) Resize

func (vm *VirtualMachine) Resize(planId int) error

func (*VirtualMachine) SetMetadata

func (vm *VirtualMachine) SetMetadata(k string, v string)

func (*VirtualMachine) SetRdns

func (vm *VirtualMachine) SetRdns(ip string, hostname string) error

func (*VirtualMachine) Snapshot

func (vm *VirtualMachine) Snapshot(name string) (int, error)

func (*VirtualMachine) Start

func (vm *VirtualMachine) Start() error

func (*VirtualMachine) Stop

func (vm *VirtualMachine) Stop() error

func (*VirtualMachine) Suspend

func (vm *VirtualMachine) Suspend(auto bool)

func (*VirtualMachine) Unsuspend

func (vm *VirtualMachine) Unsuspend() error

func (*VirtualMachine) Vnc

func (vm *VirtualMachine) Vnc() (string, error)

type VmActionDescriptor

type VmActionDescriptor struct {
	Action      string
	Name        string            // used for button text
	Options     map[string]string // if non-nil, set of options to offer in modal / dropdown menu; not used for sanitization!
	Description string            // if non-empty, will be displayed in a modal
	Dangerous   bool              // if true, we will have confirmation window
}

describes an action that we can perform on a virtual machine

type VmCreateEmail

type VmCreateEmail struct {
	Id   int
	Name string
}

type VmCreateErrorEmail

type VmCreateErrorEmail struct {
	Id   int
	Name string
}

type VmCreateOptions

type VmCreateOptions struct {
	KeyID int
}

type VmDeletedEmail

type VmDeletedEmail struct {
	Id   int
	Name string
}

type VmInfo

type VmInfo struct {
	Ip            string
	PrivateIp     string
	Status        string
	Hostname      string
	BandwidthUsed int64 // in bytes
	LoginDetails  string
	Details       map[string]string
	Actions       []*VmActionDescriptor

	// these fields are filled in by lobster, so VM interface should generally not set
	// occassionally it may be useful for interface to override though
	//   these are autodetected from whether we can cast the interface, so if
	//    interface discovers that some capabilities aren't supported on some
	//    virtual machines, it may want to override that
	//   in that event it should set OverrideCapabilities
	CanVnc               bool
	CanReimage           bool
	CanSnapshot          bool
	CanResize            bool
	CanAddresses         bool
	OverrideCapabilities bool
	PendingSnapshots     []*Image
}

type VmInterface

type VmInterface interface {
	// Creates a virtual machine with the given name and plan (specified in vm object), and image.
	// Returns vmIdentification string and optional error.
	// Should return vmIdentification != "" only if err == nil.
	VmCreate(vm *VirtualMachine, options *VMIVmCreateOptions) (string, error)

	// Deletes the specified virtual machine.
	VmDelete(vm *VirtualMachine) error

	VmInfo(vm *VirtualMachine) (*VmInfo, error)

	VmStart(vm *VirtualMachine) error
	VmStop(vm *VirtualMachine) error
	VmReboot(vm *VirtualMachine) error

	// action is an element of VmInfo.Actions (although this is not guaranteed)
	VmAction(vm *VirtualMachine, action string, value string) error

	// returns the number of bytes transferred by the given VM since the last call
	// if this is the first call, then BandwidthAccounting must return zero
	BandwidthAccounting(vm *VirtualMachine) int64
}

type VmUnsuspendEmail

type VmUnsuspendEmail struct {
	Name string
}

Directories

Path Synopsis
core
module
payment
vmi

Jump to

Keyboard shortcuts

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