Documentation
¶
Index ¶
- Constants
- Variables
- func AntifloodAction(ip string, action string)
- func AntifloodCheck(ip string, action string, maxCount int) bool
- func CSRFGenerate(session *Session) string
- func ExtractIP(ipport string) string
- func GetDatabaseString() string
- func GetDecoder() *schema.Decoder
- func HandleWebsockify(ipport string, password string) string
- func HandleWssh(ipport string, username string, password string) string
- func LobsterHandler(h http.Handler) http.Handler
- func LogAction(userId int, ip string, name string, details string)
- func MailWrap(userId int, tmpl string, subparams interface{}, ccAdmin bool)
- func RedirectHandler(target string) func(w http.ResponseWriter, r *http.Request)
- func RedirectMessage(w http.ResponseWriter, r *http.Request, target string, msg utils.Message)
- func RedirectMessageExtra(w http.ResponseWriter, r *http.Request, target string, msg utils.Message, ...)
- func RegisterAPIHandler(path string, f APIHandlerFunc, method string)
- func RegisterAdminHandler(path string, f AdminHandlerFunc, onlyPost bool)
- func RegisterHttpHandler(path string, f http.HandlerFunc, onlyPost bool)
- func RegisterPanelHandler(path string, f PanelHandlerFunc, onlyPost bool)
- func RegisterPanelWidget(name string, widget PanelWidget)
- func RegisterPaymentInterface(method string, payInterface PaymentInterface)
- func RegisterSplashRoute(path string, template string)
- func RegisterVmInterface(region string, vmi VmInterface)
- func RenderTemplate(w http.ResponseWriter, category string, tmpl string, data interface{}) error
- func ReportError(err error, description string, detail string)
- func Run()
- func SessionWrap(handler func(w http.ResponseWriter, r *http.Request, session *Session)) func(w http.ResponseWriter, r *http.Request)
- func Setup(cfgPath string)
- func TestReset()
- func TestSetup()
- func TestUser() int
- func TestVm(userId int) int
- func TransactionAdd(userId int, gateway string, gatewayIdentifier string, notes string, ...)
- func UserApplyCharge(userId int, name string, detail string, k string, amount int64)
- func UserApplyCredit(userId int, amount int64, detail string)
- func UserBandwidthSummary(userId int) map[string]*BandwidthSummary
- func UserCreate(username string, password string, email string) (int, error)
- type APIHandlerFunc
- type AccountCreatedEmail
- type AccountPasswordForm
- type AdminFormParams
- type AdminHandlerFunc
- type AdminImagesAddForm
- type AdminImagesParams
- type AdminPlanParams
- type AdminPlansAddForm
- type AdminPlansParams
- type AdminRegionsParams
- type AdminUserCreditForm
- type AdminUserParams
- type AdminUserProcessFunc
- type AdminUsersParams
- type AdminVirtualMachinesParams
- type ApiActionRestriction
- type ApiAddForm
- type ApiKey
- type AuthCreateForm
- type AuthLoginForm
- type AuthPwresetParams
- type AuthPwresetRequestForm
- type AuthPwresetSubmitForm
- type BandwidthSummary
- type BandwidthUsageEmail
- type Charge
- type Config
- type ConfigBilling
- type ConfigBillingNotifications
- type ConfigBillingTermination
- type ConfigDatabase
- type ConfigDefault
- type ConfigEmail
- type ConfigHttp
- type ConfigNovnc
- type ConfigSession
- type ConfigVm
- type ConfigWssh
- type CreditSummary
- type Database
- type EmailParams
- type ErrorEmail
- type FrameParams
- type Image
- type ImageAddForm
- type ImageInfo
- type ImageStatus
- type IpAddress
- type KeyAddForm
- type LowCreditEmail
- type NewVMRegionForm
- type PanelAccountParams
- type PanelBillingParams
- type PanelChargesParams
- type PanelDashboardParams
- type PanelFormParams
- type PanelHandlerFunc
- type PanelImageDetailsParams
- type PanelImagesParams
- type PanelKeysParams
- type PanelNewVMParams
- type PanelNewVMRegionParams
- type PanelVMParams
- type PanelVirtualMachinesParams
- type PanelWidget
- type PanelWidgetFunc
- type PayForm
- type PaymentInterface
- type PaymentProcessedEmail
- type Plan
- type PwresetRequestEmail
- type Region
- type Result
- type Row
- type Rows
- type SSHKey
- type Session
- type SplashTemplateParams
- type Transaction
- type User
- type VMIAddresses
- type VMIImages
- type VMIPlans
- type VMIReimage
- type VMIRename
- type VMIResize
- type VMISnapshot
- type VMIVmCreateOptions
- type VMIVnc
- type VMReimageForm
- type VMResizeForm
- type VirtualMachine
- func (vm *VirtualMachine) Action(action string, value string) error
- func (vm *VirtualMachine) AddAddress() error
- func (vm *VirtualMachine) Delete(userId int) error
- func (vm *VirtualMachine) LoadAddresses() error
- func (vm *VirtualMachine) LoadInfo()
- func (vm *VirtualMachine) Metadata(k string, d string) string
- func (vm *VirtualMachine) Reboot() error
- func (vm *VirtualMachine) RemoveAddress(ip string, privateip string) error
- func (vm *VirtualMachine) Rename(name string) error
- func (vm *VirtualMachine) Resize(planId int) error
- func (vm *VirtualMachine) SetMetadata(k string, v string)
- func (vm *VirtualMachine) SetRdns(ip string, hostname string) error
- func (vm *VirtualMachine) Snapshot(name string) (int, error)
- func (vm *VirtualMachine) Start() error
- func (vm *VirtualMachine) Stop() error
- func (vm *VirtualMachine) Suspend(auto bool)
- func (vm *VirtualMachine) Unsuspend() error
- func (vm *VirtualMachine) Vnc() (string, error)
- type VmActionDescriptor
- type VmCreateEmail
- type VmCreateErrorEmail
- type VmCreateOptions
- type VmDeletedEmail
- type VmInfo
- type VmInterface
- type VmUnsuspendEmail
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 ¶
View Source
var L *i18n.Section
View Source
var LA i18n.SectionFunc
Functions ¶
func AntifloodAction ¶
func CSRFGenerate ¶
func GetDatabaseString ¶
func GetDatabaseString() string
func GetDecoder ¶
func HandleWebsockify ¶
Creates websockify instance if not already setup, initializes token, and returns URL to redirect to
func HandleWssh ¶
Creates wssh instance if not already setup, initializes token, and returns URL to redirect to
func RedirectHandler ¶
func RedirectHandler(target string) func(w http.ResponseWriter, r *http.Request)
func RedirectMessage ¶
func RedirectMessageExtra ¶
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 RegisterVmInterface ¶
func RegisterVmInterface(region string, vmi VmInterface)
func RenderTemplate ¶
func RenderTemplate(w http.ResponseWriter, category string, tmpl string, data interface{}) error
func ReportError ¶
func SessionWrap ¶
func SessionWrap(handler func(w http.ResponseWriter, r *http.Request, session *Session)) func(w http.ResponseWriter, r *http.Request)
func TransactionAdd ¶
func UserApplyCharge ¶
func UserApplyCredit ¶
func UserBandwidthSummary ¶
func UserBandwidthSummary(userId int) map[string]*BandwidthSummary
Types ¶
type APIHandlerFunc ¶
type AccountCreatedEmail ¶
type AccountPasswordForm ¶
type AdminFormParams ¶
type AdminFormParams struct {
Frame FrameParams
Token string
}
type AdminHandlerFunc ¶
type AdminHandlerFunc func(http.ResponseWriter, *http.Request, *Session, FrameParams)
type AdminImagesAddForm ¶
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 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 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 ApiAddForm ¶
type AuthCreateForm ¶
type AuthLoginForm ¶
type AuthPwresetParams ¶
type AuthPwresetRequestForm ¶
type AuthPwresetSubmitForm ¶
type BandwidthSummary ¶
type BandwidthUsageEmail ¶
type 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 LoadConfig ¶
type ConfigBilling ¶
type ConfigDatabase ¶
type ConfigDefault ¶
type ConfigEmail ¶
type ConfigHttp ¶
type ConfigHttp struct {
Addr string
}
type ConfigNovnc ¶
type ConfigSession ¶
type ConfigWssh ¶
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
type EmailParams ¶
type ErrorEmail ¶
type FrameParams ¶
type ImageAddForm ¶
type ImageStatus ¶
type ImageStatus int
const ( ImagePending ImageStatus = iota ImageActive ImageError )
type KeyAddForm ¶
type LowCreditEmail ¶
type NewVMRegionForm ¶
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 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 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 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 Result ¶
type Result struct {
// contains filtered or unexported fields
}
func (Result) LastInsertId ¶
func (Result) RowsAffected ¶
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 ¶
type SplashTemplateParams ¶
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 ¶
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 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 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) 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) 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 VmCreateErrorEmail ¶
type VmCreateOptions ¶
type VmCreateOptions struct {
KeyID int
}
type VmDeletedEmail ¶
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
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.