コード例 #1
0
def getNetDevDesc(dev):
    from baseudev import udev_get_device
    desc = "Network Interface"

    if dev == '' or dev is None:
        return desc

    bus = dbus.SystemBus()
    nm = bus.get_object(NM_SERVICE, NM_MANAGER_PATH)
    devlist = nm.get_dbus_method("GetDevices")()

    for path in devlist:
        device = bus.get_object(NM_SERVICE, path)
        device_iface = dbus.Interface(device, DBUS_PROPS_IFACE)
        device_props = device_iface.get_dbus_method("GetAll")(NM_DEVICE_IFACE)

        if dev == device_props['Interface']:
            # This is the sysfs path (for now).
            udev_path = device_props['Udi']
            dev = udev_get_device(udev_path[4:])

            if dev is None:
                log.debug("weird, we have a None dev with path %s" % path)
            elif dev.has_key("ID_VENDOR_ENC") and dev.has_key("ID_MODEL_ENC"):
                desc = "%s %s" % (dev["ID_VENDOR_ENC"], dev["ID_MODEL_ENC"])
            elif dev.has_key("ID_VENDOR_FROM_DATABASE") and dev.has_key("ID_MODEL_FROM_DATABASE"):
                desc = "%s %s" % (dev["ID_VENDOR_FROM_DATABASE"], dev["ID_MODEL_FROM_DATABASE"])

            return desc

    return desc
コード例 #2
0
ファイル: isys.py プロジェクト: sun7shines/Anaconda
def getNetDevDesc(dev):
    from baseudev import udev_get_device
    desc = "Network Interface"

    if dev == '' or dev is None:
        return desc

    bus = dbus.SystemBus()
    nm = bus.get_object(NM_SERVICE, NM_MANAGER_PATH)
    devlist = nm.get_dbus_method("GetDevices")()

    for path in devlist:
        device = bus.get_object(NM_SERVICE, path)
        device_iface = dbus.Interface(device, DBUS_PROPS_IFACE)
        device_props = device_iface.get_dbus_method("GetAll")(NM_DEVICE_IFACE)

        if dev == device_props['Interface']:
            # This is the sysfs path (for now).
            udev_path = device_props['Udi']
            dev = udev_get_device(udev_path[4:])

            if dev is None:
                log.debug("weird, we have a None dev with path %s" % path)
            elif dev.has_key("ID_VENDOR_ENC") and dev.has_key("ID_MODEL_ENC"):
                desc = "%s %s" % (dev["ID_VENDOR_ENC"], dev["ID_MODEL_ENC"])
            elif dev.has_key("ID_VENDOR_FROM_DATABASE") and dev.has_key("ID_MODEL_FROM_DATABASE"):
                desc = "%s %s" % (dev["ID_VENDOR_FROM_DATABASE"], dev["ID_MODEL_FROM_DATABASE"])

            return desc

    return desc
コード例 #3
0
ファイル: __init__.py プロジェクト: icomfort/anaconda
    def majorminor(self):
        """A string suitable for using as a pseudo-unique ID in kickstart."""

        # If this is a device-mapper device, we have to get the DM node and
        # build the sysfs path from that.
        try:
            device = dm_node_from_name(self.device)
        except DMError:
            device = self.device

        sysfs_path = get_sysfs_path_by_name(device)
        dev = udev_get_device(sysfs_path[4:])
        return "%03d%03d" % (udev_device_get_major(dev),
                             udev_device_get_minor(dev))
コード例 #4
0
    def majorminor(self):
        """A string suitable for using as a pseudo-unique ID in kickstart."""
        if not self._majorminor:
            # If this is a device-mapper device, we have to get the DM node and
            # build the sysfs path from that.
            try:
                device = dm_node_from_name(self.device)
            except DMError:
                device = self.device

            try:
                sysfs_path = get_sysfs_path_by_name(device)
            except RuntimeError:
                raise StorageError("DeviceFormat.majorminor: "
                                   "can not get majorminor for '%s'" % device)

            dev = udev_get_device(sysfs_path[4:])
            self._majorminor = "%03d%03d" %\
                (udev_device_get_major(dev), udev_device_get_minor(dev))
        return self._majorminor