[PATCH 3/8] write ifname=eth#:MAC to kernel cmdline in grub.conf for dracut

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

 



---
 booty/bootloaderInfo.py |    2 +-
 network.py              |   75 ++++++++++++++++++++++++++++------------------
 2 files changed, 47 insertions(+), 30 deletions(-)

diff --git a/booty/bootloaderInfo.py b/booty/bootloaderInfo.py
index cb1e16f..c004461 100644
--- a/booty/bootloaderInfo.py
+++ b/booty/bootloaderInfo.py
@@ -97,7 +97,7 @@ class KernelArguments:
                 import storage
                 if isinstance(d, storage.devices.NetworkStorageDevice):
                     args += " "
-                    args += self.id.network.dracutSetupString(d.host_address)
+                    args += self.id.network.dracutSetupString(d)
 
         args += self.id.instLanguage.dracutSetupString()
         args += self.id.keyboard.dracutSetupString()
diff --git a/network.py b/network.py
index 104e420..e9f6ad8 100644
--- a/network.py
+++ b/network.py
@@ -587,7 +587,7 @@ class Network:
             if anaconda is not None:
                 import storage
                 rootdev = anaconda.id.storage.rootDevice
-                # FIXME: use device.host_address to only add "NM_CONTROLLED=no"
+                # FIXME: use d.host_address to only add "NM_CONTROLLED=no"
                 # for interfaces actually used enroute to the device
                 for d in anaconda.id.storage.devices:
                     if isinstance(d, storage.devices.NetworkStorageDevice) and\
@@ -785,39 +785,56 @@ class Network:
         return False
 
     # get a kernel cmdline string for dracut needed for access to host host
-    def dracutSetupString(self, host):
-        if not host:
-            return ""
+    def dracutSetupString(self, networkStorageDevice):
+        netargs=""
 
-        # First of all find out which interface leads to host
-        route = iutil.execWithCapture("ip", [ "route", "get", "to", host ])
-        if not route:
-            log.error("Could net get interface for route to %s" % host)
+        if networkStorageDevice.nic:
+            # Storage bound to a specific nic (ie FCoE)
+            nic = networkStorageDevice.nic
+        else:
+            # Storage bound through ip, find out which interface leads to host
+            host = networkStorageDevice.host_address
+            route = iutil.execWithCapture("ip", [ "route", "get", "to", host ])
+            if not route:
+                log.error("Could net get interface for route to %s" % host)
+                return ""
+
+            routeInfo = route.split()
+            if routeInfo[0] != host or len(routeInfo) < 5:
+                log.error('Unexpected "ip route get to %s" reply: %s' %
+                          (host, routeInfo))
+                return ""
+
+            nic = routeInfo[2]
+
+        if nic not in self.netdevices.keys():
+            log.error('Unknown network interface: %s' % nic)
             return ""
 
-        routeInfo = route.split()
-        if routeInfo[0] != host or len(routeInfo) < 5:
-            log.error('Unexpected "ip route get to %s" reply: %s' %
-                      (host, routeInfo))
-            return ""
+        dev = self.netdevices[nic]
 
-        if routeInfo[2] not in self.netdevices.keys():
-            log.error('Unknown network interface: %s' % routeInfo[2])
-            return ""
+        if networkStorageDevice.host_address:
+            if dev.get('bootproto').lower() == 'dhcp':
+                netargs += "ip=%s:dhcp" % nic
+            else:
+                if dev.get('GATEWAY'):
+                    gateway = dev.get('GATEWAY')
+                else:
+                    gateway = ""
 
-        dev = self.netdevices[routeInfo[2]]
-        if dev.get('bootproto').lower() == 'dhcp':
-            return "ip=%s:dhcp" % routeInfo[2]
+                if self.hostname:
+                    hostname = self.hostname
+                else:
+                    hostname = ""
 
-        if dev.get('GATEWAY'):
-            gateway = dev.get('GATEWAY')
-        else:
-            gateway = ""
+                netargs += "ip=%s::%s:%s:%s:%s:none" % (dev.get('ipaddr'),
+                           gateway, dev.get('netmask'), hostname, nic)
 
-        if self.hostname:
-            hostname = self.hostname
-        else:
-            hostname = ""
+        hwaddr = dev.get("HWADDR")
+        if hwaddr:
+            if netargs != "":
+                netargs += " "
+
+            netargs += "ifname=%s:%s" % (nic, hwaddr.lower())
 
-        return "ip=%s::%s:%s:%s:%s:none" % (dev.get('ipaddr'), gateway,
-               dev.get('netmask'), hostname, routeInfo[2])
+        return netargs
-- 
1.6.4.2

_______________________________________________
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