[PATCH 13/15] Use HAL to probe for available network devices.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Description support is sort of tacked on, but should work for most
device classes.
---
 network.py |   69 +++++++++++++++++------------------------------------------
 1 files changed, 20 insertions(+), 49 deletions(-)

diff --git a/network.py b/network.py
index 3e16214..36c2168 100644
--- a/network.py
+++ b/network.py
@@ -256,66 +256,37 @@ class Network:
 	    if not oneactive:
 		self.netdevices[self.firstnetdevice].set(("onboot", "yes"))
 
-	    # assign description to each device based on kudzu information
-	    probedevs = kudzu.probe(kudzu.CLASS_NETWORK, kudzu.BUS_UNSPEC, kudzu.PROBE_LOADED)
-	    for netdev in probedevs:
-		device = netdev.device
-		if device in self.netdevices.keys():
-		    desc = netdev.desc
-		    if desc is not None and len(desc) > 0:
-			self.netdevices[device].set(("desc", desc))
-
-                    # hwaddr for qeth doesn't make sense (#135023)
-                    if netdev.driver == "qeth":
-                        continue
-                    # add hwaddr
-                    hwaddr = isys.getMacAddress(device)
-                    if hwaddr and hwaddr != "00:00:00:00:00:00" and hwaddr != "ff:ff:ff:ff:ff:ff":
-                        self.netdevices[device].set(("hwaddr", hwaddr))
-
     def getDevice(self, device):
 	return self.netdevices[device]
 
     def getFirstDeviceName(self):
 	return self.firstnetdevice
 
-    def _sysfsDeviceIsUsable(self, dev):
-        if os.path.exists("/sys/class/net/%s/bridge" % dev):
-            return False
-        try:
-            f = open("/sys/class/net/%s/type" % dev)
-            lines = f.readlines()
-            f.close()
-
-            return lines[0].startswith("1")
-        except:
-            return False
-
     def available(self):
+        import dbus
+
+        bus = dbus.SystemBus()
+
+        halobj = bus.get_object("org.freedesktop.Hal","/org/freedesktop/Hal/Manager")
+        hal = dbus.Interface(halobj, "org.freedesktop.Hal.Manager")
+
+        for device in halobj.FindDeviceByCapability("net"):
+            haldev = dbus.Interface(bus.get_object("org.freedesktop.Hal", device), 'org.freedesktop.Hal.Device')
+            dev = haldev.GetProperty('net.interface')
+            if haldev.GetProperty('net.arp_proto_hw_id') == 1:
+                self.netdevices[dev] = NetworkDevice(dev);
+                if self.firstnetdevice is None:
+                    self.firstnetdevice = dev
+                self.netdevices[dev].set(('hwaddr',haldev.GetProperty('net.address')))
+                parent = haldev.GetProperty('net.physical_device')
+                pdev = dbus.Interface(bus.get_object("org.freedesktop.Hal", parent), 'org.freedesktop.Hal.Device')
+                desc = '%s %s' % (pdev.GetProperty('info.vendor'), pdev.GetProperty('info.product'))
+                self.netdevices[dev].set(('desc',desc))
+
         ksdevice = None
         if flags.cmdline.has_key("ksdevice"):
             ksdevice = flags.cmdline["ksdevice"]
 
-        f = open("/proc/net/dev")
-        lines = f.readlines()
-        f.close()
-        # skip first two lines, they are header
-        lines = lines[2:]
-        for line in lines:
-            dev = string.strip(line[0:6])
-            if dev != "lo" and dev[0:3] != "sit" and not self.netdevices.has_key(dev) and self._sysfsDeviceIsUsable(dev):
-		if self.firstnetdevice is None:
-		    self.firstnetdevice = dev
-
-                self.netdevices[dev] = NetworkDevice(dev)
-
-                try:
-                    hwaddr = isys.getMacAddress(dev)
-                    if rhpl.getArch() != "s390" and hwaddr and hwaddr != "00:00:00:00:00:00" and hwaddr != "ff:ff:ff:ff:ff:ff":
-                        self.netdevices[dev].set(("hwaddr", hwaddr))
-                except Exception, e:
-                    log.error("exception getting mac addr: %s" %(e,))
-
         if ksdevice and self.netdevices.has_key(ksdevice):
             self.firstnetdevice = ksdevice
 
-- 
1.5.3.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux