summaryrefslogtreecommitdiffstats
path: root/network.py
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2009-09-13 13:33:49 +0200
committerHans de Goede <hdegoede@redhat.com>2009-09-15 20:28:28 +0200
commitf581da5ed611c02e69a82c19aee94ce9c37f16eb (patch)
tree9c072836622804932ed31fa5919fdd86f8f78ce9 /network.py
parent13474a9228995815c2e1fa4eb02203634e5b1f7a (diff)
write ifname=eth#:MAC to kernel cmdline in grub.conf for dracut
Diffstat (limited to 'network.py')
-rw-r--r--network.py75
1 files changed, 46 insertions, 29 deletions
diff --git a/network.py b/network.py
index 104e420b1..e9f6ad8d2 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