fabtools.require.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
-
fabtools.require.openvz.
template
(name=None, url=None)[source]¶ Require an OpenVZ OS template.
If the OS template is not installed yet, it will be downloaded from url using
download_template()
:from fabtools import require # Use custom OS template require.openvz.template(url='http://example.com/templates/mybox.tar.gz')
If no url is provided,
download_template()
will attempt to download the OS template from the download.openvz.org repository:from fabtools import require # Use OS template from http://download.openvz.org/template/precreated/ require.openvz.template('debian-6.0-x86_64')
-
fabtools.require.openvz.
container
(name, ostemplate, **kwargs)[source]¶ Require an OpenVZ container.
If it does not exist, the container will be created using the specified OS template (see
fabtools.require.openvz.template()
).Extra args will be passed to
fabtools.openvz.create()
:from fabtools import require require.openvz.container('foo', 'debian', ipadd='1.2.3.4')
This function returns a
fabtools.openvz.Container
object, that can be used to perform further operations:from fabtools.require.openvz import container ct = container('foo', 'debian') ct.set('ipadd', '1.2.3.4') ct.start() ct.exec2('hostname')
This function can also be used as a context manager:
from fabtools.require.openvz import container with container('foo', 'debian') as ct: ct.set('ipadd', '1.2.3.4') ct.start() ct.exec2('hostname')