provision

package
v0.0.0-...-e22f67b Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2013 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package provision provides interfaces that need to be satisfied in order to implement a new provisioner on tsuru.

Index

Constants

View Source
const (
	StatusStarted    = Status("started")
	StatusPending    = Status("pending")
	StatusDown       = Status("down")
	StatusError      = Status("error")
	StatusInstalling = Status("installing")
	StatusCreating   = Status("creating")
)

Variables

This section is empty.

Functions

func Register

func Register(name string, p Provisioner)

Register registers a new provisioner in the Provisioner registry.

Types

type App

type App interface {
	Named

	// Log should be used to log messages in the app.
	Log(message, source string) error

	// GetFramework returns the framework (type) of the app. It is equivalent
	// to the Unit `Type` field.
	GetFramework() string

	// GetUnits returns all units of the app, in a slice.
	ProvisionUnits() []AppUnit
}

App represents a tsuru app.

It contains only relevant information for provisioning.

type AppUnit

type AppUnit interface {
	Named

	// Returns the number of the unit.
	GetMachine() int

	// Returns the status of the unit.
	GetStatus() Status

	// Returns the IP of the unit.
	GetIp() string

	// Returns the instance id of the unit.
	GetInstanceId() string
}

AppUnit represents a unit in an app.

type Error

type Error struct {
	Reason string
	Err    error
}

func (*Error) Error

func (e *Error) Error() string

type Named

type Named interface {
	GetName() string
}

Named is something that has a name, providing the GetName method.

type Provisioner

type Provisioner interface {
	// Provision is called when tsuru is creating the app.
	Provision(App) error

	// Destroy is called when tsuru is destroying the app.
	Destroy(App) error

	// AddUnits adds units to an app. The first parameter is the app, the
	// second is the number of units to add.
	//
	// It returns a slice containing all added units
	AddUnits(App, uint) ([]Unit, error)

	// RemoveUnit removes a unit from the app. It receives the app and the name
	// of the unit to be removed.
	RemoveUnit(App, string) error

	// ExecuteCommand runs a command in all units of the app.
	ExecuteCommand(stdout, stderr io.Writer, app App, cmd string, args ...string) error

	// Restart restarts the app.
	Restart(App) error

	// CollectStatus returns information about all provisioned units. It's used
	// by tsuru collector when updating the status of apps in the database.
	CollectStatus() ([]Unit, error)

	// Addr returns the address for an app. It will probably be a DNS name
	// or IP address.
	//
	// Tsuru will use this method to get the IP (althought it might not be
	// an actual IP, collector calls it "IP") of the app from the
	// provisioner.
	Addr(App) (string, error)
}

Provisioner is the basic interface of this package.

Any tsuru provisioner must implement this interface in order to provision tsuru apps.

Tsuru comes with a default provisioner: juju. One can add other provisioners by satisfying this interface and registering it using the function Register.

func Get

func Get(name string) (Provisioner, error)

Get gets the named provisioner from the registry.

type Status

type Status string

func (Status) String

func (s Status) String() string

type Unit

type Unit struct {
	Name       string
	AppName    string
	Type       string
	InstanceId string
	Machine    int
	Ip         string
	Status     Status
}

Unit represents a provision unit. Can be a machine, container or anything IP-addressable.

Directories

Path Synopsis
Package juju provide utilities functions for interaction with Juju.
Package juju provide utilities functions for interaction with Juju.

Jump to

Keyboard shortcuts

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