lxc

package module
v0.0.0-...-9af9727 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2014 License: LGPL-2.1 Imports: 9 Imported by: 0

README

The official repository for this project has been moved to LXC organization.

This repository is kept here for historical purposes only.

Go Bindings for LXC 0.9

This package implements Go bindings for the LXC C API.

Requirements

This package requires LXC 0.9 and Go 1.x.

It has been tested on

  • Ubuntu 12.10 (quantal) by manually installing LXC 0.9
  • Ubuntu 13.04 (raring) by using distribution provided packages
  • Ubuntu 13.10 (saucy) by using distribution provided packages

Installing

The typical go get github.com/caglar10ur/lxc will install LXC Go Bindings.

Documentation

Documentation can be found at GoDoc

Examples

See the examples directory for some.

Notes

Note that since LXC 0.9 does not have full user namespaces support, any code using the LXC API needs to run as root.

Documentation

Overview

Go (golang) Bindings for LXC (Linux Containers)

This package implements Go bindings for the LXC C API.

Index

Constants

View Source
const (
	// Timeout
	WAIT_FOREVER int = iota - 1
	DONT_WAIT
)

Variables

This section is empty.

Functions

func ContainerNames

func ContainerNames() []string

Returns the names of containers on the system.

func DefaultConfigPath

func DefaultConfigPath() string

Returns default config path

func GetContainer

func GetContainer(lxc *Container) bool

Increments reference counter of the container object

func PutContainer

func PutContainer(lxc *Container) bool

Decrements reference counter of the container object

func Version

func Version() string

Returns LXC version

Types

type ByteSize

type ByteSize float64
const (
	KB ByteSize = 1 << (10 * iota)
	MB
	GB
	TB
	PB
	EB
	ZB
	YB
)

func (ByteSize) String

func (b ByteSize) String() string

type Container

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

func Containers

func Containers() []Container

Returns the containers on the system.

func NewContainer

func NewContainer(name string) *Container

func (*Container) CPUStats

func (lxc *Container) CPUStats() ([]int64, error)

Returns the number of CPU cycles (in the units defined by USER_HZ on the system) consumed by tasks in this cgroup and its children in both user mode and system (kernel) mode.

func (*Container) CPUTime

func (lxc *Container) CPUTime() (time.Duration, error)

Returns the total CPU time (in nanoseconds) consumed by all tasks in this cgroup (including tasks lower in the hierarchy).

func (*Container) CPUTimePerCPU

func (lxc *Container) CPUTimePerCPU() ([]time.Duration, error)

Returns the CPU time (in nanoseconds) consumed on each CPU by all tasks in this cgroup (including tasks lower in the hierarchy).

func (*Container) CgroupItem

func (lxc *Container) CgroupItem(key string) []string

Returns the value of the given key

func (*Container) ClearConfigItem

func (lxc *Container) ClearConfigItem(key string) bool

Clears the value of given key

func (*Container) ConfigFileName

func (lxc *Container) ConfigFileName() string

Returns the container's configuration file's name

func (*Container) ConfigItem

func (lxc *Container) ConfigItem(key string) []string

Returns the value of the given key

func (*Container) ConfigPath

func (lxc *Container) ConfigPath() string

Returns the configuration file's path

func (*Container) Create

func (lxc *Container) Create(template string, args []string) bool

Creates the container using given template and arguments

func (*Container) Daemonize

func (lxc *Container) Daemonize() bool

Returns whether the daemonize flag is set

func (*Container) Defined

func (lxc *Container) Defined() bool

Returns whether the container is already defined or not

func (*Container) Destroy

func (lxc *Container) Destroy() bool

Destroys the container

func (*Container) Freeze

func (lxc *Container) Freeze() bool

Freezes the running container

func (*Container) InitPID

func (lxc *Container) InitPID() int

Returns the container's PID

func (*Container) Keys

func (lxc *Container) Keys(key string) []string

Returns the keys

func (*Container) LoadConfigFile

func (lxc *Container) LoadConfigFile(path string) bool

Loads the configuration file from given path

func (*Container) MemoryLimitInBytes

func (lxc *Container) MemoryLimitInBytes() (ByteSize, error)

func (*Container) MemoryUsageInBytes

func (lxc *Container) MemoryUsageInBytes() (ByteSize, error)

func (*Container) Name

func (lxc *Container) Name() string

Returns container's name

func (*Container) NumberOfNetworkInterfaces

func (lxc *Container) NumberOfNetworkInterfaces() int

func (*Container) Running

func (lxc *Container) Running() bool

Returns whether the container is already running or not

func (*Container) SaveConfigFile

func (lxc *Container) SaveConfigFile(path string) bool

Saves the configuration file to given path

func (*Container) SetCgroupItem

func (lxc *Container) SetCgroupItem(key string, value string) bool

Sets the value of given key

func (*Container) SetConfigItem

func (lxc *Container) SetConfigItem(key string, value string) bool

Sets the value of given key

func (*Container) SetConfigPath

func (lxc *Container) SetConfigPath(path string) bool

Sets the configuration file's path

func (*Container) SetDaemonize

func (lxc *Container) SetDaemonize()

Sets the daemonize flag

func (*Container) Shutdown

func (lxc *Container) Shutdown(timeout int) bool

Shutdowns the container

func (*Container) Start

func (lxc *Container) Start(useinit bool, args []string) bool

Starts the container

func (*Container) State

func (lxc *Container) State() State

Returns the container's state

func (*Container) Stop

func (lxc *Container) Stop() bool

Stops the container

func (*Container) SwapLimitInBytes

func (lxc *Container) SwapLimitInBytes() (ByteSize, error)

func (*Container) SwapUsageInBytes

func (lxc *Container) SwapUsageInBytes() (ByteSize, error)

func (*Container) Unfreeze

func (lxc *Container) Unfreeze() bool

Unfreezes the frozen container

func (*Container) Wait

func (lxc *Container) Wait(state State, timeout int) bool

Waits till the container changes its state or timeouts

type State

type State int
const (
	STOPPED  State = C.STOPPED
	STARTING State = C.STARTING
	RUNNING  State = C.RUNNING
	STOPPING State = C.STOPPING
	ABORTING State = C.ABORTING
	FREEZING State = C.FREEZING
	FROZEN   State = C.FROZEN
	THAWED   State = C.THAWED
)

func (State) String

func (t State) String() string

State as string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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