fabtools.openvz¶
OpenVZ containers¶
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
Manage templates¶
-
fabtools.openvz.download_template(name=None, url=None)[source]¶ 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')
Manage containers¶
-
fabtools.openvz.create(ctid, ostemplate=None, config=None, private=None, root=None, ipadd=None, hostname=None, **kwargs)[source]¶ Create an OpenVZ container.
-
fabtools.openvz.start(ctid_or_name, wait=False, force=False, **kwargs)[source]¶ Start the container.
If wait is
True, wait until the container is up and running.Warning
wait=Trueis broken with vzctl 3.0.24 on Debian 6.0 (squeeze)
Run commands inside a container¶
-
fabtools.openvz.exec2(ctid_or_name, command)[source]¶ Run a command inside the container.
import fabtools res = fabtools.openvz.exec2('foo', 'hostname')
Warning
the command will be run as root.
-
fabtools.openvz.guest(*args, **kwds)[source]¶ 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. Usesudo(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')
Container class¶
-
class
fabtools.openvz.container.Container(ctid)[source]¶ Object-oriented interface to OpenVZ containers.
-
create(**kwargs)[source]¶ Create the container.
Extra args are passed to
fabtools.openvz.create().
-
set(**kwargs)[source]¶ Set container parameters.
Extra args are passed to
fabtools.openvz.set().
-
start(**kwargs)[source]¶ Start the container.
Extra args are passed to
fabtools.openvz.start().
-
stop(**kwargs)[source]¶ Stop the container.
Extra args are passed to
fabtools.openvz.stop().
-
restart(**kwargs)[source]¶ Restart the container.
Extra args are passed to
fabtools.openvz.restart().
-