container

package
v0.0.0-...-a002913 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2015 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigName   = "name"
	ConfigLogDir = "log-dir"

	// ConfigIPForwarding, if set to a non-empty value, instructs the
	// container manager to enable IP forwarding as part of the
	// container initialization. Will be enabled if the enviroment
	// supports networking.
	ConfigIPForwarding = "ip-forwarding"

	// ConfigEnableNAT, if set to a non-empty value, instructs the
	// container manager to enable NAT for hosted containers. NAT is
	// required for AWS, but should be disabled for MAAS.
	ConfigEnableNAT = "enable-nat"

	// ConfigLXCDefaultMTU, if set to a positive integer (serialized
	// as a string), will cause all network interfaces on all created
	// LXC containers (not KVM instances) to use the given MTU
	// setting.
	ConfigLXCDefaultMTU = "lxc-default-mtu"

	DefaultNamespace = "juju"
)
View Source
const (
	// BridgeNetwork will have the container use the network bridge.
	BridgeNetwork = "bridge"
	// PhyscialNetwork will have the container use a specified network device.
	PhysicalNetwork = "physical"
)
View Source
const (
	// NameRegexp specifies the regular expression used to identify valid lock names.
	NameRegexp = "^[a-z]+[a-z0-9.-]*$"
)

Variables

View Source
var (
	ContainerDir        = "/var/lib/juju/containers"
	RemovedContainerDir = "/var/lib/juju/removed-containers"
)

Functions

func ImageDownloadURL

func ImageDownloadURL(kind instance.ContainerType, series, arch string) (string, error)

ImageDownloadURL determines the public URL which can be used to obtain an image blob with the specified parameters.

func NewDirectory

func NewDirectory(containerName string) (directory string, err error)

NewDirectory creates a new directory for the container name in the directory identified by `ContainerDir`.

func RemoveDirectory

func RemoveDirectory(containerName string) error

RemoveDirectory moves the container directory from `ContainerDir` to `RemovedContainerDir` and makes sure that the names don't clash.

Types

type ImageURLGetter

type ImageURLGetter interface {
	// ImageURL returns a URL which can be used to fetch an image of the
	// specified kind, series, and arch.
	ImageURL(kind instance.ContainerType, series, arch string) (string, error)

	// CACert returns the ca certificate used to validate the state server
	// certificate when using wget.
	CACert() []byte
}

ImageURLGetter implementations provide a getter which returns a URL which can be used to fetch an image blob.

func NewImageURLGetter

func NewImageURLGetter(serverRoot, envuuid string, caCert []byte) ImageURLGetter

NewImageURLGetter returns an ImageURLGetter for the specified state server address and environment UUID.

type Initialiser

type Initialiser interface {
	// Initialise installs all required packages, sync any images etc so
	// that the host machine can run containers.
	Initialise() error
}

Initialiser is responsible for performing the steps required to initialise a host machine so it can run containers.

type Lock

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

func NewLock

func NewLock(dir, name string) (*Lock, error)

NewLock returns a new lock with the given name, using the given lock directory, without acquiring it. The lock name must match the regular expression defined by NameRegexp.

func (*Lock) Lock

func (lock *Lock) Lock(message string) (err error)

Lock blocks until it is able to acquire the lock. It is good behaviour to provide a message that is output in debugging information.

func (*Lock) Unlock

func (lock *Lock) Unlock() error

Unlock releases a held lock.

type Manager

type Manager interface {
	// CreateContainer creates and starts a new container for the specified
	// machine.
	CreateContainer(
		instanceConfig *instancecfg.InstanceConfig,
		series string,
		network *NetworkConfig,
		storage *StorageConfig) (instance.Instance, *instance.HardwareCharacteristics, error)

	// DestroyContainer stops and destroyes the container identified by
	// instance id.
	DestroyContainer(instance.Id) error

	// ListContainers return a list of containers that have been started by
	// this manager.
	ListContainers() ([]instance.Instance, error)

	// IsInitialized check whether or not required packages have been installed
	// to support this manager.
	IsInitialized() bool
}

Manager is responsible for starting containers, and stopping and listing containers that it has started.

type ManagerConfig

type ManagerConfig map[string]string

ManagerConfig contains the initialization parameters for the ContainerManager. The name of the manager is used to namespace the containers on the machine.

func (ManagerConfig) PopValue

func (m ManagerConfig) PopValue(key string) string

PopValue returns the requested key from the config map. If the value doesn't exist, the function returns the empty string. If the value does exist, the value is returned, and the element removed from the map.

func (ManagerConfig) WarnAboutUnused

func (m ManagerConfig) WarnAboutUnused()

WarnAboutUnused emits a warning about each value in the map.

type NetworkConfig

type NetworkConfig struct {
	NetworkType string
	Device      string
	MTU         int

	Interfaces []network.InterfaceInfo
}

NetworkConfig defines how the container network will be configured.

func BridgeNetworkConfig

func BridgeNetworkConfig(device string, mtu int, interfaces []network.InterfaceInfo) *NetworkConfig

BridgeNetworkConfig returns a valid NetworkConfig to use the specified device as a network bridge for the container. It also allows passing in specific configuration for the container's network interfaces and default MTU to use. If interfaces is nil the default configuration is used for the respective container type.

func PhysicalNetworkConfig

func PhysicalNetworkConfig(device string, mtu int, interfaces []network.InterfaceInfo) *NetworkConfig

PhysicalNetworkConfig returns a valid NetworkConfig to use the specified device as the network device for the container. It also allows passing in specific configuration for the container's network interfaces and default MTU to use. If interfaces is nil the default configuration is used for the respective container type.

type StorageConfig

type StorageConfig struct {

	// AllowMount is true is the container is required to allow
	// mounting block devices.
	AllowMount bool
}

StorageConfig defines how the container will be configured to support storage requirements.

Directories

Path Synopsis
kvm
lxc

Jump to

Keyboard shortcuts

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