Пример #1
0
def container(name, ostemplate, **kwargs):
    """
    Require an OpenVZ container
    """
    if not openvz.exists(name):
        ctid = openvz.get_available_ctid()
        openvz.create(ctid, ostemplate=ostemplate, **kwargs)
        openvz.set(ctid, name=name)
    return Container(name)
Пример #2
0
    def set(self, **kwargs):
        """
        Set container parameters.

        Extra args are passed to :py:func:`fabtools.openvz.set`.
        """
        return vz.set(self.ctid, **kwargs)
Пример #3
0
    def set(self, **kwargs):
        """
        Set container parameters.

        Extra args are passed to :py:func:`fabtools.openvz.set`.
        """
        return vz.set(self.ctid, **kwargs)
Пример #4
0
def container(name, ostemplate, **kwargs):
    """
    Require an OpenVZ container.

    If it does not exist, the container will be created using the
    specified OS template
    (see :py:func:`fabtools.require.openvz.template()`).

    Extra args will be passed to :py:func:`fabtools.openvz.create()`::

        from fabtools import require

        require.openvz.container('foo', 'debian', ipadd='1.2.3.4')

    This function returns a :py:class:`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')

    """
    if not openvz.exists(name):
        ctid = openvz.get_available_ctid()
        openvz.create(ctid, ostemplate=ostemplate, **kwargs)
        openvz.set(ctid, name=name)
    return Container(name)
Пример #5
0
def container(name, ostemplate, **kwargs):
    """
    Require an OpenVZ container.

    If it does not exist, the container will be created using the
    specified OS template
    (see :py:func:`fabtools.require.openvz.template()`).

    Extra args will be passed to :py:func:`fabtools.openvz.create()`::

        from fabtools import require

        require.openvz.container('foo', 'debian', ipadd='1.2.3.4')

    This function returns a :py:class:`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')

    """
    if not openvz.exists(name):
        ctid = openvz.get_available_ctid()
        openvz.create(ctid, ostemplate=ostemplate, **kwargs)
        openvz.set(ctid, name=name)
    return Container(name)
Пример #6
0
 def set(self, **kwargs):
     return vz.set(self.ctid, **kwargs)