golxc

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

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

Go to latest
Published: Nov 21, 2014 License: GPL-3.0, LGPL-3.0-or-later Imports: 9 Imported by: 30

Documentation

Overview

golxc - Go package to interact with Linux Containers (LXC).

https://launchpad.net/golxc/

Index

Constants

View Source
const DefaultLXCDir = "/var/lib/lxc"

Variables

View Source
var ContainerDir = GetDefaultLXCContainerDir()

Functions

func GetDefaultLXCContainerDir

func GetDefaultLXCContainerDir() string

GetDefaultLXCContainerDir returns the current lxc.lxcpath value otherwise the const DefaultLXCDir is returned.

func IsNetworkRunning

func IsNetworkRunning() (bool, error)

IsNotworkRunning checks if the lxc network subsystem is running.

func NetworkAttributes

func NetworkAttributes() (addr, bridge string, err error)

NetworkAttributes returns the lxc network attributes: starting IP address and bridge name.

func ReadConf

func ReadConf() (map[string]string, error)

ReadConf reads the LXC network address and bridge interface out of the configuration file /etc/default/lxc.

func StartNetwork

func StartNetwork() error

StartNetwork starts the lxc network subsystem.

func StopNetwork

func StopNetwork() error

StopNetwork stops the lxc network subsystem.

Types

type Container

type Container interface {

	// Name returns the name of the container.
	Name() string

	// Create creates a new container based on the given template.
	// envArgs, if not nil, are assigned to the environment of the process, otherwise the
	// environment of the current process is used.
	Create(configFile, template string, extraArgs []string, templateArgs []string, envArgs []string) error

	// Start runs the container as a daemon.
	Start(configFile, consoleFile string) error

	// Stop terminates the running container.
	Stop() error

	// Clone creates a copy of the container, giving the copy the specified name.
	Clone(name string, extraArgs []string, templateArgs []string) (Container, error)

	// Freeze freezes all the container's processes.
	Freeze() error

	// Unfreeze thaws all frozen container's processes.
	Unfreeze() error

	// Destroy stops and removes the container.
	Destroy() error

	// Wait waits for one of the specified container states.
	Wait(states ...State) error

	// Info returns the status and the process id of the container.
	Info() (State, int, error)

	// IsConstructed checks if the container image exists.
	IsConstructed() bool

	// IsRunning checks if the state of the container is 'RUNNING'.
	IsRunning() bool

	// String returns information about the container, like the name, state,
	// and process id.
	String() string

	// LogFile returns the current filename used for the LogFile.
	LogFile() string

	// LogLevel returns the current logging level (only used if the
	// LogFile is not "").
	LogLevel() LogLevel

	// SetLogFile sets both the LogFile and LogLevel.
	SetLogFile(filename string, level LogLevel)
}

Container represents a linux container instance and provides operations to create, maintain and destroy the container.

type ContainerFactory

type ContainerFactory interface {
	// New returns a container instance which can then be used for operations
	// like Create(), Start(), Stop() or Destroy().
	New(string) Container

	// List returns all the existing containers on the system.
	List() ([]Container, error)
}

ContainerFactory represents the methods used to create Containers.

func Factory

func Factory() ContainerFactory

Factory provides the standard ContainerFactory.

type Error

type Error struct {
	Name   string
	Err    error
	Output []string
}

Error reports the failure of a LXC command.

func (Error) Error

func (e Error) Error() string

type LogLevel

type LogLevel string

LogLevel represents a container's log level.

const (
	LogDebug    LogLevel = "DEBUG"
	LogInfo     LogLevel = "INFO"
	LogNotice   LogLevel = "NOTICE"
	LogWarning  LogLevel = "WARN"
	LogError    LogLevel = "ERROR"
	LogCritical LogLevel = "CRIT"
	LogFatal    LogLevel = "FATAL"
)

type State

type State string

State represents a container state.

const (
	StateUnknown  State = "UNKNOWN"
	StateStopped  State = "STOPPED"
	StateStarting State = "STARTING"
	StateRunning  State = "RUNNING"
	StateAborting State = "ABORTING"
	StateStopping State = "STOPPING"
)

Source Files

  • config.go
  • golxc.go
  • network.go

Jump to

Keyboard shortcuts

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