cloudbrain

package
v0.0.0-...-9235d7d Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2018 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const MaxCreateRetries = 10

MaxCreateRetries is the number of times the "create" job will be retried.

Variables

View Source
var (
	//VersionString gets set during `make`
	VersionString = "?"
	//RevisionString gets set during `make`
	RevisionString = "?"
	//RevisionURLString gets set during `make`
	RevisionURLString = "?"
	//GeneratedString gets set during `make`
	GeneratedString = "?"
	//CopyrightString gets set during `make`
	CopyrightString = "?"
)

Functions

This section is empty.

Types

type Core

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

Core is used as a central manager for all Cloud Brain functionality. The HTTP API and the background workers are just frontends for the Core, and calls methods on Core for functionality.

func NewCore

func NewCore(db database.DB, redisPool *redis.Pool, redisWorkerPrefix string) *Core

NewCore is used to create a new Core backed by the given database and background Backend.

func (*Core) CheckToken

func (c *Core) CheckToken(tokenID uint64, token string) (bool, error)

CheckToken is used to check whether a given tokenID+token is in the database. Returns (true, nil) iff the token is valid, (false, nil) if the token is invalid, and (false, err) if an error occurred while fetching the token.

func (*Core) CreateInstance

func (c *Core) CreateInstance(ctx context.Context, providerName string, attr CreateInstanceAttributes) (*Instance, error)

CreateInstance creates an instance in the database and queues off the cloud create job in the background.

func (*Core) GetInstance

func (c *Core) GetInstance(ctx context.Context, id string) (*Instance, error)

GetInstance gets the instance information stored in the database for a given instance ID.

func (*Core) ProviderCreateInstance

func (c *Core) ProviderCreateInstance(job *work.Job) error

ProviderCreateInstance is used to schedule the creation of the instance with the given ID on the provider selected for that instance.

func (*Core) ProviderRefresh

func (c *Core) ProviderRefresh(ctx context.Context) error

ProviderRefresh is used to synchronize the data on all the cloud providers with the data in our database.

func (*Core) ProviderRemoveInstance

func (c *Core) ProviderRemoveInstance(job *work.Job) error

ProviderRemoveInstance is used to schedule the creation of the instance with the given ID on the provider selected for that instance.

func (*Core) RemoveInstance

func (c *Core) RemoveInstance(ctx context.Context, attr DeleteInstanceAttributes) error

RemoveInstance creates an instance in the database and queues off the cloud create job in the background.

type CreateInstanceAttributes

type CreateInstanceAttributes struct {
	ImageName    string
	InstanceType string
	PublicSSHKey string
}

CreateInstanceAttributes contains attributes needed to start an instance

type DeleteInstanceAttributes

type DeleteInstanceAttributes struct {
	InstanceID string
}

DeleteInstanceAttributes contains attributes needed to delete an instance

type Instance

type Instance struct {
	ID           string
	ProviderName string
	Image        string
	State        string
	IPAddress    string
	UpstreamID   string
	ErrorReason  string
}

Instance is a single compute instance.

Jump to

Keyboard shortcuts

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