pylxclite

A python wrapper for Linux Containers (LXC)


License
LGPL-3.0
Install
pip install pylxclite==0.0.3

Documentation

pylxclite

A simple python wrapper on LXC commands

Tested on: CentOS 6.5

lxc-1.0.5-5.el6.x86_64 Python 2.6.6

Installation

easy_install pylxclite
pip install pylxclite

Usage

You can query current containers using:

import lxc
>>> lxc.ls()
['gmo', '360', 'goo']

Check if a container exists:

import lxc
>>> lxc.exists("name")

Create a container:

import lxc
>>> lxc.create('name')

Clone a container:

import lxc
>>> lxc.clone('orig', 'new')

Get stopped containers:

import lxc
>>> lxc.stoppped()
'{"STOPPED": ["gmo","test"]}'

Get running containers:

import lxc
>>> lxc.running()
'{"RUNNING": ["360","goo"]}'

Get container infos:

import lxc
>>> lxc.info('admin')
Name:           admin
State:          RUNNING
PID:            15446
IP:             192.168.122.233
CPU use:        1.20 seconds
BlkIO use:      26.13 MiB
Memory use:     15.42 MiB
Link:           veth6QP3MI
TX bytes:       1.35 KiB
RX bytes:       43.56 KiB
Total bytes:    44.92 KiB

Start container:

import lxc
>>> lxc.start('gmo')
'Oooooooooook!'

Stop container:

import lxc
>>> lxc.stop('gmo',True)
'Oooooooooook!'