Esempio n. 1
0
    def __init__(self, conn=None, resource=None):

        if conn is None:
            self.conn = Connection.instance()
        else:
            self.conn = conn

        self.resource = resource
Esempio n. 2
0
    def domains(cls, conn=None):

        """
        :param conn: The libvirt connection
        :type conn: :py:class:`~.connection.Connection`
        :rtype: ``generator``

        Get all domains, defined and created.
        """

        conn = conn if conn is not None else Connection.instance()

        for libvirt_domain in conn.domains:
            yield Domain(conn=conn, resource=resource)
Esempio n. 3
0
    def by_name(self, name, conn=None):

        """
        :param name: The network name
        :type name: ``str``
        :param conn: The libvirt connection
        :type conn: :py:class:`~.connection.Connection`
        :rtype: :py:class:`~.network.Network`

        Lookup and return a network by name.

        .. seealso::
            :py:meth:`~.connection.Connection.network_by_name`
        """

        conn = conn if conn is not None else Connection.instance()
        resource = conn.network_by_name(name)
        return Network(conn=conn, resource=resource)
Esempio n. 4
0
    def by_uuid(self, uuid, conn=None):

        """
        :param uuid: The network UUID string
        :type uuid: ``str``
        :param conn: The libvirt connection
        :type conn: :py:class:`~.connection.Connection`
        :rtype: :py:class:`~.network.Network`

        Lookup and return a network by UUID.

        .. seealso::
            :py:meth:`~.connection.Connection.network_by_uuid`
        """

        conn = conn if conn is not None else Connection.instance()
        resource = conn.network_by_uuid(uuid)
        return Network(conn=conn, resource=resource)        
Esempio n. 5
0
    def by_name(cls, name, conn=None):

        """
        Lookup a domain by name.

        :param name: A domain name.
        :type name: ``str``
        :param conn: The libvirt connection
        :type conn: :py:class:`~.connection.Connection`
        :rtype: :py:class:`~.domain.Domain`

        .. seealso::
            :py:meth:`~.connection.Connection.domain_by_name`
        """

        conn = conn if conn is not None else Connection.instance()
        resource = conn.domain_by_name(name)

        return Domain(conn=conn, resource=resource)
Esempio n. 6
0
    def by_uuid(cls, uuid, conn=None):

        """
        Lookup a domain by UUID string.

        :param uuid: A uuid string
        :type: uuid: ``str``
        :param conn: The libvirt connection
        :type conn: :py:class:`~.connection.Connection`
        :rtype: :py:class:`~.domain.Domain`

        .. seealso::
            :py:meth:`~.connection.Connection.domain_by_uuid`
        """

        conn = conn if conn is not None else Connection.instance()
        resource = conn.domain_by_uuid(uuid)

        return Domain(conn=conn, resource=resource)
Esempio n. 7
0
    def by_id(cls, identifier, conn=None):

        """
        Lookup a domain by ID.

        :param identifier: The domain identifier
        :type identifier: ``int``
        :param conn: The libvirt connection
        :type conn: :py:class:`~.connection.Connection`
        :rtype: :py:class:`~.domain.Domain`

        .. seealso::
            :py:meth:`~.connection.Connection.domain_by_id`
        """

        conn = conn if conn is not None else Connection.instance()
        resource = conn.domain_by_id(identifier)

        return Domain(conn=conn, resource=resource)