Documentation
¶
Overview ¶
golxc - Go package to interact with Linux Containers (LXC).
Index ¶
- Constants
- Variables
- func GetDefaultLXCContainerDir() string
- func IsNetworkRunning() (bool, error)
- func NetworkAttributes() (addr, bridge string, err error)
- func ReadConf() (map[string]string, error)
- func StartNetwork() error
- func StopNetwork() error
- type Container
- type ContainerFactory
- type Error
- type LogLevel
- type State
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 ¶
IsNotworkRunning checks if the lxc network subsystem is running.
func NetworkAttributes ¶
NetworkAttributes returns the lxc network attributes: starting IP address and bridge name.
func ReadConf ¶
ReadConf reads the LXC network address and bridge interface out of the configuration file /etc/default/lxc.
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.
type Error ¶
Error reports the failure of a LXC command.
Source Files
¶
- config.go
- golxc.go
- network.go
Click to show internal directories.
Click to hide internal directories.