diff options
author | Radek Vykydal <rvykydal@redhat.com> | 2012-11-16 09:09:59 +0100 |
---|---|---|
committer | Radek Vykydal <rvykydal@redhat.com> | 2012-12-05 10:47:06 +0100 |
commit | c3c90d6eeab5393a1ad7ce13eaa819f4b2040118 (patch) | |
tree | 0392349853d32e62f9b97f5580e5daaa529ed8c0 /pyanaconda/network.py | |
parent | 6d22647772d57a3817f1d482e2c8d4f2109c6dff (diff) | |
download | anaconda-c3c90d6eeab5393a1ad7ce13eaa819f4b2040118.tar.gz anaconda-c3c90d6eeab5393a1ad7ce13eaa819f4b2040118.tar.xz anaconda-c3c90d6eeab5393a1ad7ce13eaa819f4b2040118.zip |
Fix network command --onboot and --activate options.
In dracut we set ONBOOT=yes for --activate so that NM activates
the device upon its start, in anaconda we set the real value
of ONBOOT.
Diffstat (limited to 'pyanaconda/network.py')
-rw-r--r-- | pyanaconda/network.py | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/pyanaconda/network.py b/pyanaconda/network.py index 1b22966a9..5b14bca62 100644 --- a/pyanaconda/network.py +++ b/pyanaconda/network.py @@ -959,6 +959,72 @@ def update_hostname(ksdata): nd = kickstartNetworkData(hostname=hostname) ksdata.network.network.append(nd) +def get_device_name(devspec): + + devices = getDevices() + devname = None + + if not devspec: + if "ksdevice" in flags.cmdline: + msg = "ksdevice boot parameter" + devname = get_ksdevice_name(flags.cmdline["ksdevice"]) + elif hasActiveNetDev(): + # device activated in stage 1 by network kickstart command + msg = "first active device" + devname = getActiveNetDevs()[0] + else: + msg = "first device found" + devname = min(devices) + log.info("unspecified network --device in kickstart, using %s (%s)" % + (devname, msg)) + else: + if devspec.lower() == "ibft": + devname = "" + if devspec.lower() == "link": + for dev in sorted(devices): + if isys.getLinkStatus(dev): + devname = dev + break + else: + log.error("Kickstart: No network device with link found") + elif devspec.lower() == "bootif": + if "BOOTIF" in flags.cmdline: + # MAC address like 01-aa-bb-cc-dd-ee-ff + devname = flags.cmdline["BOOTIF"][3:] + devname = devname.replace("-",":") + else: + log.error("Using --device=bootif without BOOTIF= boot option supplied") + else: devname = devspec + + if devname not in devices: + for d in devices: + if isys.getMacAddress(d).lower() == devname.lower(): + devname = d + break + + return devname + +def setOnboot(ksdata): + for network_data in ksdata.network.network: + + devname = get_device_name(network_data.device) + if not devname: + log.error("Kickstart: The provided network interface %s does not exist" % devname) + continue + + dev = NetworkDevice(netscriptsDir, devname) + try: + dev.loadIfcfgFile() + except IOError as e: + log.info("Can't load ifcfg file %s, %s" % (dev.path, e)) + continue + + if network_data.onboot: + dev.set (("ONBOOT", "yes")) + else: + dev.set (("ONBOOT", "no")) + dev.writeIfcfgFile() + # networking initialization and ksdata object update def networkInitialize(ksdata): from pyanaconda.kickstart import NetworkData @@ -967,6 +1033,11 @@ def networkInitialize(ksdata): # XXX: this should go to anaconda dracut createMissingDefaultIfcfgs() + # we set ONBOOT value using network --activate activate in dracut + # to get devices activated by NM, so set proper ONBOOT value + # based on --onboot here + setOnboot(ksdata) + if ksdata.network.hostname is None: update_hostname(ksdata) |