summaryrefslogtreecommitdiffstats
path: root/network.py
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2009-08-04 11:12:14 +0200
committerHans de Goede <hdegoede@redhat.com>2009-08-04 11:12:14 +0200
commitdc8c30f746c0d8b794917fe6d45f5130e47d1427 (patch)
tree97883aba0ea0767794aa77509686a35abc22022c /network.py
parent99cd89c17ccbd633399bdd3e2b3fd77fbd8c3707 (diff)
downloadanaconda-dc8c30f746c0d8b794917fe6d45f5130e47d1427.tar.gz
anaconda-dc8c30f746c0d8b794917fe6d45f5130e47d1427.tar.xz
anaconda-dc8c30f746c0d8b794917fe6d45f5130e47d1427.zip
Add a dracutSetupString method to network.py
Add a dracutSetupString method to network.py, this can be used to ask the Network class to get a dracut setup string to setup the interface needed for a connection to a certain host. This patch also adds code to booty to use this to get kernel cmdline dracut setup commands for any NIC's needed to connect to devices needed for /
Diffstat (limited to 'network.py')
-rw-r--r--network.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/network.py b/network.py
index 9a8d7d2bb..db1fab1e3 100644
--- a/network.py
+++ b/network.py
@@ -779,3 +779,37 @@ class Network:
return True
return False
+
+ # get a kernel cmdline string for dracut needed for access to host host
+ def dracutSetupString(self, host):
+ if not host:
+ return ""
+
+ # 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)
+ 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 ""
+
+ if routeInfo[2] not in self.netdevices.keys():
+ log.error('Unknown network interface: %s' % routeInfo[2])
+ return ""
+
+ 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 = ""
+
+ ip = "ip=%s::%s:%s:%s:none" % (dev.get('ipaddr'),
+ dev.get('GATEWAY', ''), dev.get('netmask'), hostname,
+ routeInfo[2])