[PATCH 06/15] remove Network(): ksdevice attribute

Radek Vykydal rvykydal at redhat.com
Thu Jul 19 10:02:39 UTC 2012


It is used only in kickstart.py in newui
---
 pyanaconda/iw/network_gui.py       |    2 +-
 pyanaconda/kickstart.py            |    4 +-
 pyanaconda/network.py              |   55 +++++++++++++++++++----------------
 pyanaconda/textw/netconfig_text.py |    2 +-
 4 files changed, 34 insertions(+), 29 deletions(-)

diff --git a/pyanaconda/iw/network_gui.py b/pyanaconda/iw/network_gui.py
index f1eee76f..cf20c39 100644
--- a/pyanaconda/iw/network_gui.py
+++ b/pyanaconda/iw/network_gui.py
@@ -155,7 +155,7 @@ def selectInstallNetDeviceDialog(network, devices = None):
     store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
     combo.set_model(store)
 
-    ksdevice = network.ksdevice
+    ksdevice = network.get_ksdevice_name()
     preselected = None
 
     for dev in devices:
diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py
index 8238c88..37a37bc 100644
--- a/pyanaconda/kickstart.py
+++ b/pyanaconda/kickstart.py
@@ -662,9 +662,9 @@ class NetworkData(commands.network.F16_NetworkData):
         devices = self.anaconda.network.netdevices
 
         if not self.device:
-            if self.anaconda.network.ksdevice:
+            if "ksdevice" in flags.cmdline:
                 msg = "ksdevice boot parameter"
-                device = self.anaconda.network.ksdevice
+                device = network.get_ksdevice_name(flags.cmdline["ksdevice"])
             elif network.hasActiveNetDev():
                 # device activated in stage 1 by network kickstart command
                 msg = "first active device"
diff --git a/pyanaconda/network.py b/pyanaconda/network.py
index 837e437..c7f11b7 100644
--- a/pyanaconda/network.py
+++ b/pyanaconda/network.py
@@ -444,7 +444,6 @@ class Network:
         ifcfglog.debug("Network.update() called")
 
         self.netdevices = {}
-        self.ksdevice = None
 
         if flags.imageInstall:
             return
@@ -470,30 +469,6 @@ class Network:
 
             self.netdevices[iface] = device
 
-
-        ksdevice = flags.cmdline.get('ksdevice', None)
-        if ksdevice:
-            bootif_mac = None
-            if ksdevice == 'bootif' and "BOOTIF" in flags.cmdline:
-                bootif_mac = flags.cmdline["BOOTIF"][3:].replace("-", ":").upper()
-            # sort for ksdevice=link (to select the same device as in initrd))
-            for dev in sorted(self.netdevices):
-                mac = self.netdevices[dev].get('HWADDR').upper()
-                if ksdevice == 'link' and isys.getLinkStatus(dev):
-                    self.ksdevice = dev
-                    break
-                elif ksdevice == 'bootif':
-                    if bootif_mac == mac:
-                        self.ksdevice = dev
-                        break
-                elif ksdevice == dev:
-                    self.ksdevice = dev
-                    break
-                elif ':' in ksdevice:
-                    if ksdevice.upper() == mac:
-                        self.ksdevice = dev
-                        break
-
     @property
     def gateway(self):
         """GATEWAY - last device in list wins"""
@@ -953,3 +928,33 @@ def copyConfigToPath(destPath):
 
     _copyFileToPath(ipv6ConfFile, destPath,
                          overwrite=flags.livecdInstall)
+
+def get_ksdevice_name(ksspec=""):
+
+    if not ksspec:
+        ksspec = flags.cmdline.get('ksdevice', "")
+    ksdevice = ksspec
+
+    bootif_mac = None
+    if ksdevice == 'bootif' and "BOOTIF" in flags.cmdline:
+        bootif_mac = flags.cmdline["BOOTIF"][3:].replace("-", ":").upper()
+    for dev in sorted(getDevices()):
+        # "eth0"
+        if ksdevice == dev:
+            break
+        # "link"
+        elif ksdevice == 'link' and isys.getLinkStatus(dev):
+            ksdevice = dev
+            break
+        # "XX:XX:XX:XX:XX:XX" (mac address)
+        elif ':' in ksdevice:
+            if ksdevice.upper() == isys.getMacAddress(dev):
+                ksdevice = dev
+                break
+        # "bootif" and BOOTIF==XX:XX:XX:XX:XX:XX
+        elif ksdevice == 'bootif':
+            if bootif_mac == isys.getMacAddress(dev):
+                ksdevice = dev
+                break
+
+    return ksdevice
diff --git a/pyanaconda/textw/netconfig_text.py b/pyanaconda/textw/netconfig_text.py
index 40a31cb..6be52f3 100644
--- a/pyanaconda/textw/netconfig_text.py
+++ b/pyanaconda/textw/netconfig_text.py
@@ -72,7 +72,7 @@ class NetworkConfiguratorText:
         devnames.sort()
 
         # Preselect device set in kickstart
-        ksdevice = self.anaconda.ksdevice
+        ksdevice = network.get_ksdevice_name()
 
         for devname in devnames:
             hwaddr = self.netdevs[devname].get("HWADDR")
-- 
1.7.4



More information about the anaconda-patches mailing list