[PATCH rhel6-branch] Support bonding in %pre section (#971961)
Radek Vykydal
rvykydal at redhat.com
Tue Oct 1 10:12:46 UTC 2013
Based on patch by Masahiro Matsuya
Resolves: rhbz#971961
The bz does not have all acks yet but most probably it will get included.
I have also a patch for support in rhel7 (which works in cleaner
way - no need for sleeps and device activation using ifcfg files)
ready.
---
kickstart.py | 36 +++++++++++++++++++++++++++++++-----
network.py | 12 ++++++++++++
2 files changed, 43 insertions(+), 5 deletions(-)
diff --git a/kickstart.py b/kickstart.py
index 1e9b529..bbd72fd 100644
--- a/kickstart.py
+++ b/kickstart.py
@@ -684,13 +684,39 @@ class NetworkData(commands.network.RHEL6_NetworkData):
anaconda.id.network.setHostname(self.hostname)
anaconda.id.network.overrideDHCPhostname = True
+ activate_new_device = False
if not dev:
- if self.hostname:
+ if self.bondslaves:
+ if not self.activate:
+ log.info("bond %s not configured in stage 2, only activation supported, please use --activate option" % device)
+ return
+ activate_new_device = True
+ dev = anaconda.id.network.enableBondingDevice(device)
+ dev.set(("BONDING_OPTS", self.bondopts))
+ slaves = self.bondslaves.split(',')
+ for slave in slaves:
+ slavedev = devices.get(slave, None)
+ if slavedev:
+ mac = slavedev.get('HWADDR')
+ uuid = slavedev.get('UUID')
+ slavedev.clear()
+ slavedev.set(("DEVICE", slave))
+ if mac:
+ slavedev.set(("HWADDR", mac))
+ if uuid:
+ slavedev.set(("UUID", uuid))
+ slavedev.set(("SLAVE", "yes"))
+ slavedev.set(("MASTER", device))
+ slavedev.set(("ONBOOT", "yes"))
+ # disconnect the slave
+ slavedev.set(("NM_CONTROLLED", "no"))
+ slavedev.writeIfcfgFile()
+
+ slavedev.set(("NM_CONTROLLED", "yes"))
+ time.sleep(2)
+ elif self.hostname:
# Only set hostname
return
- elif self.bondslaves:
- log.info("bond %s not configured, only supported for devices activated during installation" % device)
- return
else:
raise KickstartValueError, formatErrorMsg(self.lineno, msg="The provided network interface %s does not exist" % device)
@@ -749,7 +775,7 @@ class NetworkData(commands.network.RHEL6_NetworkData):
anaconda.methodstr.startswith("nfs:")))
# First kickstart network command wins
# TODORV: document
- if needs_net and not network.hasActiveNetDev():
+ if (needs_net and not network.hasActiveNetDev()) or activate_new_device:
log.info("Bringing up network device %s in stage2 kickstart ..." %
dev.iface)
dev.set (("onboot", "yes"))
diff --git a/network.py b/network.py
index 523ef6b..6a21201 100644
--- a/network.py
+++ b/network.py
@@ -642,6 +642,18 @@ class Network:
log.warning("autoconnectFCoEDevices: %s file not found" %
device.path)
+ def enableBondingDevice(self, devName, instPath=''):
+ dev = NetworkDevice(instPath + netscriptsDir, devName)
+ self.netdevices[devName] = dev
+ dev.set(("DEVICE", devName))
+ dev.set(("TYPE", "Bond"))
+ dev.set(("NM_CONTROLLED", "yes"))
+ if not os.access(dev.path, os.R_OK):
+ f = open(dev.path, "w")
+ f.close()
+ dev.writeIfcfgFile()
+ return dev
+
def hasActiveIPoIBDevice(self):
active_devs = getActiveNetDevs()
for devName, device in self.netdevices.items():
--
1.7.11.7
More information about the anaconda-patches
mailing list