summaryrefslogtreecommitdiffstats
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
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 /
-rw-r--r--booty/__init__.py16
-rw-r--r--booty/alpha.py4
-rw-r--r--booty/bootloaderInfo.py15
-rw-r--r--booty/ia64.py4
-rw-r--r--booty/ppc.py4
-rw-r--r--booty/s390.py4
-rw-r--r--booty/sparc.py4
-rw-r--r--booty/x86.py6
-rw-r--r--instdata.py2
-rw-r--r--network.py34
10 files changed, 66 insertions, 27 deletions
diff --git a/booty/__init__.py b/booty/__init__.py
index 9ee639864..8f2d6a794 100644
--- a/booty/__init__.py
+++ b/booty/__init__.py
@@ -28,25 +28,25 @@ class BootyNoKernelWarning:
return self.value
# return instance of the appropriate bootloader for our arch
-def getBootloader(storage):
+def getBootloader(storage, network):
"""Get the bootloader info object for your architecture"""
if iutil.isX86():
import x86
- return x86.x86BootloaderInfo(storage)
+ return x86.x86BootloaderInfo(storage, network)
elif iutil.isIA64():
import ia64
- return ia64.ia64BootloaderInfo(storage)
+ return ia64.ia64BootloaderInfo(storage, network)
elif iutil.isS390():
import s390
- return s390.s390BootloaderInfo(storage)
+ return s390.s390BootloaderInfo(storage, network)
elif iutil.isAlpha():
import alpha
- return alpha.alphaBootloaderInfo(storage)
+ return alpha.alphaBootloaderInfo(storage, network)
elif iutil.isPPC():
import ppc
- return ppc.ppcBootloaderInfo(storage)
+ return ppc.ppcBootloaderInfo(storage, network)
elif iutil.isSparc():
import sparc
- return sparc.sparcBootloaderInfo(storage)
+ return sparc.sparcBootloaderInfo(storage, network)
else:
- return bootloaderInfo(storage)
+ return bootloaderInfo(storage, network)
diff --git a/booty/alpha.py b/booty/alpha.py
index 33cef8234..9f7c7cf77 100644
--- a/booty/alpha.py
+++ b/booty/alpha.py
@@ -142,8 +142,8 @@ class alphaBootloaderInfo(bootloaderInfo):
return self.writeAboot(instRoot, bl, kernelList,
chainList, defaultDev, justConfig)
- def __init__(self, storage):
- bootloaderInfo.__init__(self, storage)
+ def __init__(self, storage, network):
+ bootloaderInfo.__init__(self, storage, network)
self.useGrubVal = 0
self.configfile = "/etc/aboot.conf"
# self.kernelLocation is already set to what we need.
diff --git a/booty/bootloaderInfo.py b/booty/bootloaderInfo.py
index 3c1ed06cf..7f226c360 100644
--- a/booty/bootloaderInfo.py
+++ b/booty/bootloaderInfo.py
@@ -94,6 +94,10 @@ class KernelArguments:
dracutSetupString = d.dracutSetupString()
if len(dracutSetupString):
args += " %s" % dracutSetupString
+ import storage
+ if isinstance(d, storage.devices.NetworkStorageDevice):
+ args += " "
+ args += self.network.dracutSetupString(d.host_address)
return args
@@ -115,7 +119,7 @@ class KernelArguments:
self.args = self.args + "%s" % (args,)
- def __init__(self, storage):
+ def __init__(self, storage, network):
newArgs = []
cfgFilename = "/tmp/install.cfg"
@@ -153,6 +157,7 @@ class KernelArguments:
self.args = " ".join(newArgs)
self.storage = storage
+ self.network = network
class BootImages:
@@ -476,8 +481,8 @@ class bootloaderInfo:
self._drivelist = val
drivelist = property(_getDriveList, _setDriveList)
- def __init__(self, storage):
- self.args = KernelArguments(storage)
+ def __init__(self, storage, network):
+ self.args = KernelArguments(storage, network)
self.images = BootImages()
self.device = None
self.defaultDevice = None # XXX hack, used by kickstart
@@ -614,9 +619,9 @@ class efiBootloaderInfo(bootloaderInfo):
return rc
return self.addNewEfiEntry(instRoot)
- def __init__(self, storage, initialize = True):
+ def __init__(self, storage, network, initialize = True):
if initialize:
- bootloaderInfo.__init__(self, storage)
+ bootloaderInfo.__init__(self, storage, network)
else:
self.storage = storage
diff --git a/booty/ia64.py b/booty/ia64.py
index 6c9cdc232..c5bd42e3c 100644
--- a/booty/ia64.py
+++ b/booty/ia64.py
@@ -36,7 +36,7 @@ class ia64BootloaderInfo(efiBootloaderInfo):
def makeInitrd(self, kernelTag):
return "/boot/efi/EFI/redhat/initrd%s.img" % kernelTag
- def __init__(self, storage):
- efiBootloaderInfo.__init__(self, storage)
+ def __init__(self, storage, network):
+ efiBootloaderInfo.__init__(self, storage, network)
self._configname = "elilo.conf"
self._bootloader = "elilo.efi"
diff --git a/booty/ppc.py b/booty/ppc.py
index e5320c343..2143c14c8 100644
--- a/booty/ppc.py
+++ b/booty/ppc.py
@@ -174,8 +174,8 @@ class ppcBootloaderInfo(bootloaderInfo):
return 0
- def __init__(self, storage):
- bootloaderInfo.__init__(self, storage)
+ def __init__(self, storage, network):
+ bootloaderInfo.__init__(self, storage, network)
self.useYabootVal = 1
self.kernelLocation = "/boot"
self.configfile = "/etc/yaboot.conf"
diff --git a/booty/s390.py b/booty/s390.py
index 9b6260054..8e46fab13 100644
--- a/booty/s390.py
+++ b/booty/s390.py
@@ -171,8 +171,8 @@ class s390BootloaderInfo(bootloaderInfo):
return self.writeChandevConf(bl, instRoot)
- def __init__(self, storage):
- bootloaderInfo.__init__(self, storage)
+ def __init__(self, storage, network):
+ bootloaderInfo.__init__(self, storage, network)
self.useZiplVal = 1 # only used on s390
self.kernelLocation = "/boot/"
self.configfile = "/etc/zipl.conf"
diff --git a/booty/sparc.py b/booty/sparc.py
index b12b20769..9154ac3c0 100644
--- a/booty/sparc.py
+++ b/booty/sparc.py
@@ -121,8 +121,8 @@ class sparcBootloaderInfo(bootloaderInfo):
else:
raise BootyNoKernelWarning
- def __init__(self, storage):
- bootloaderInfo.__init__(self, storage)
+ def __init__(self, storage, network):
+ bootloaderInfo.__init__(self, storage, network)
self.useSiloVal = 1
self.kernelLocation = "/boot"
self._configdir = "/etc"
diff --git a/booty/x86.py b/booty/x86.py
index f90cb86da..97354fc72 100644
--- a/booty/x86.py
+++ b/booty/x86.py
@@ -578,15 +578,15 @@ class x86BootloaderInfo(efiBootloaderInfo):
return args
- def __init__(self, storage):
- bootloaderInfo.__init__(self, storage)
+ def __init__(self, storage, network):
+ bootloaderInfo.__init__(self, storage, network)
# these have to be set /before/ efiBootloaderInfo.__init__(), or
# they'll be overwritten.
self._configdir = "/boot/grub"
self._configname = "grub.conf"
- efiBootloaderInfo.__init__(self, storage, initialize=False)
+ efiBootloaderInfo.__init__(self, storage, network, initialize=False)
# XXX use checkbootloader to determine what to default to
self.useGrubVal = 1
diff --git a/instdata.py b/instdata.py
index 6700528fd..b3497b329 100644
--- a/instdata.py
+++ b/instdata.py
@@ -74,7 +74,7 @@ class InstallData:
if flags.cmdline.has_key("preupgrade"):
self.upgrade = True
self.storage = storage.Storage(self.anaconda)
- self.bootloader = booty.getBootloader(self.storage)
+ self.bootloader = booty.getBootloader(self.storage, self.network)
self.upgradeRoot = None
self.rootParts = None
self.upgradeSwapInfo = None
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])