Ejemplo n.º 1
0
def default_bridge(conn=None):
    if platform.system() == 'SunOS':
        return ["bridge", default_nic()]

    dev = default_route()

    if (dev is not None and
        (not conn or not uriutil.is_uri_remote(conn.getURI(), conn=conn))):
        # New style peth0 == phys dev, eth0 == bridge, eth0 == default route
        if os.path.exists("/sys/class/net/%s/bridge" % dev):
            return ["bridge", dev]

        # Old style, peth0 == phys dev, eth0 == netloop, xenbr0 == bridge,
        # vif0.0 == netloop enslaved, eth0 == default route
        try:
            defn = int(dev[-1])
        except:
            defn = -1

        if (defn >= 0 and
            os.path.exists("/sys/class/net/peth%d/brport" % defn) and
            os.path.exists("/sys/class/net/xenbr%d/bridge" % defn)):
            return ["bridge", "xenbr%d" % defn]

    return None
Ejemplo n.º 2
0
def default_bridge(conn=None):
    if platform.system() == 'SunOS':
        return ["bridge", default_nic()]

    dev = default_route()

    if (dev is not None and
        (not conn or not uriutil.is_uri_remote(conn.getURI(), conn=conn))):
        # New style peth0 == phys dev, eth0 == bridge, eth0 == default route
        if os.path.exists("/sys/class/net/%s/bridge" % dev):
            return ["bridge", dev]

        # Old style, peth0 == phys dev, eth0 == netloop, xenbr0 == bridge,
        # vif0.0 == netloop enslaved, eth0 == default route
        try:
            defn = int(dev[-1])
        except:
            defn = -1

        if (defn >= 0 and
            os.path.exists("/sys/class/net/peth%d/brport" % defn) and
            os.path.exists("/sys/class/net/xenbr%d/bridge" % defn)):
            return ["bridge", "xenbr%d" % defn]

    return None
Ejemplo n.º 3
0
def _daemon_lib_ver(conn, uri, force_version, minimum_libvirt_version):
    # Always force the required version if it's after the version which
    # has getLibVersion
    if force_version or minimum_libvirt_version >= 7004:
        default_ret = 0
    else:
        default_ret = 100000000000

    if not uriutil.is_uri_remote(uri, conn=conn):
        return _local_lib_ver()

    if not _has_command("getLibVersion", obj=conn):
        return default_ret

    if not _try_command(getattr(conn, "getLibVersion"), ()):
        return default_ret

    return conn.getLibVersion()
Ejemplo n.º 4
0
def _daemon_lib_ver(conn, uri, force_version, minimum_libvirt_version):
    # Always force the required version if it's after the version which
    # has getLibVersion
    if force_version or minimum_libvirt_version >= 7004:
        default_ret = 0
    else:
        default_ret = 100000000000

    if not uriutil.is_uri_remote(uri, conn=conn):
        return _local_lib_ver()

    if not _has_command("getLibVersion", obj=conn):
        return default_ret

    if not _try_command(getattr(conn, "getLibVersion"), ()):
        return default_ret

    return conn.getLibVersion()
Ejemplo n.º 5
0
 def set_conn(self, val):
     if not isinstance(val, libvirt.virConnect):
         raise ValueError(_("'conn' must be a virConnect instance."))
     self._conn = val
     self._conn_uri = self._conn.getURI()
     self.__remote = uriutil.is_uri_remote(self._conn_uri, conn=self._conn)
Ejemplo n.º 6
0
 def is_remote(self):
     return uriutil.is_uri_remote(self.get_uri())
Ejemplo n.º 7
0
 def is_remote(self):
     return uriutil.is_uri_remote(self.get_uri())
Ejemplo n.º 8
0
 def set_conn(self, val):
     if not isinstance(val, libvirt.virConnect):
         raise ValueError(_("'conn' must be a virConnect instance."))
     self._conn = val
     self._conn_uri = self._conn.getURI()
     self.__remote = uriutil.is_uri_remote(self._conn_uri, conn=self._conn)