This module provides high-level tools for managing OpenVZ templates and containers.
Warning
The remote host needs a patched kernel with OpenVZ support.
See also
Download an OpenVZ template.
Example:
from fabtools.openvz import download_template
# Use custom OS template
download_template(url='http://example.com/templates/mybox.tar.gz')
If no url is provided, the OS template will be downloaded from the download.openvz.org repository:
from fabtools.openvz import download_template
# Use OS template from http://download.openvz.org/template/precreated/
download_template('debian-6.0-x86_64')
Check if the container exists.
Create an OpenVZ container.
Set container parameters.
Get the status of the container.
Start the container.
If wait is True, wait until the container is up and running.
Warning
wait=True is broken with vzctl 3.0.24 on Debian 6.0 (squeeze)
Stop the container.
Restart the container.
Destroy the container.
Run a command inside the container.
import fabtools
res = fabtools.openvz.exec2('foo', 'hostname')
Warning
the command will be run as root.
Context manager to run commands inside a guest container.
Supported basic operations are: run, sudo and put.
Warning
commands executed with run() will be run as root inside the container. Use sudo(command, user='foo') to run them as an unpriviledged user.
Example:
from fabtools.openvz import guest
with guest('foo'):
run('hostname')
sudo('whoami', user='alice')
put('files/hello.txt')
Object-oriented interface to OpenVZ containers.
Create the container.
Extra args are passed to fabtools.openvz.create().
Set container parameters.
Extra args are passed to fabtools.openvz.set().
Start the container.
Extra args are passed to fabtools.openvz.start().
Stop the container.
Extra args are passed to fabtools.openvz.stop().
Restart the container.
Extra args are passed to fabtools.openvz.restart().