[PATCH master] Fix crash on LiveCD if network is configured before installing (#1002373)
Radek Vykydal
rvykydal at redhat.com
Thu Sep 5 15:00:11 UTC 2013
On LiveCD if network is configured before starting installation, the connection
is saved into ifcfg file (ifcfg-Wired_connection_1) and
1) instead of ignoring it, the file was updated with our id and onboot value
in dumpMissingDefaultIfcfgs
in (frequent) case of only one wired device
2) the ifcfg file for the device was expected to be named using device name
eg ifcfg-ens3 in setNetworkOnbootDefault => traceback
This is a moderate fix for Alpha.
I am going to come with bigger patch cleaning up ifcfg files handling.
---
pyanaconda/installclasses/fedora.py | 14 ++++++++---
pyanaconda/network.py | 47 ++++++++++++++-----------------------
2 files changed, 29 insertions(+), 32 deletions(-)
diff --git a/pyanaconda/installclasses/fedora.py b/pyanaconda/installclasses/fedora.py
index 5b59c35..00eae33 100644
--- a/pyanaconda/installclasses/fedora.py
+++ b/pyanaconda/installclasses/fedora.py
@@ -45,8 +45,13 @@ class InstallClass(BaseInstallClass):
def setNetworkOnbootDefault(self, ksdata):
# if something's already enabled, we can just leave the config alone
for devName in nm.nm_devices():
- if not nm.nm_device_type_is_wifi(devName) and \
- network.get_ifcfg_value(devName, "ONBOOT", ROOT_PATH) == "yes":
+ if nm.nm_device_type_is_wifi(devName):
+ continue
+ try:
+ onboot = nm.nm_device_setting_value(devName, "connection", "autoconnect")
+ except nm.DeviceSettingsNotFoundError:
+ continue
+ if not onboot == False:
return
# the default otherwise: bring up the first wired netdev with link
@@ -59,7 +64,10 @@ class InstallClass(BaseInstallClass):
continue
if link_up:
dev = network.NetworkDevice(ROOT_PATH + network.netscriptsDir, devName)
- dev.loadIfcfgFile()
+ try:
+ dev.loadIfcfgFile()
+ except IOError as e:
+ continue
dev.set(('ONBOOT', 'yes'))
dev.writeIfcfgFile()
for nd in ksdata.network.network:
diff --git a/pyanaconda/network.py b/pyanaconda/network.py
index 35942ba..f70c0a2 100644
--- a/pyanaconda/network.py
+++ b/pyanaconda/network.py
@@ -307,7 +307,6 @@ class NetworkDevice(IfcfgFile):
f.close()
return content
-
def dumpMissingDefaultIfcfgs():
"""
Dump missing default ifcfg file for wired devices.
@@ -327,9 +326,12 @@ def dumpMissingDefaultIfcfgs():
if not nm.nm_device_type_is_ethernet(devname):
continue
- # if there is no ifcfg file for the device
- device_cfg = NetworkDevice(netscriptsDir, devname)
- if os.access(device_cfg.path, os.R_OK):
+ # check that device has connection without ifcfg file
+ try:
+ con_uuid = nm.nm_device_setting_value(devname, "connection", "uuid")
+ except nm.DeviceSettingsNotFoundError:
+ continue
+ if get_ifcfg_name([("UUID", con_uuid)], root_path=""):
continue
try:
@@ -613,26 +615,23 @@ def kickstartNetworkData(ifcfg=None, hostname=None):
# pylint: disable-msg=E1101
return handler.NetworkData(**kwargs)
-def get_bond_master_ifcfg_name(devname):
- """Name of ifcfg file of bond device devname"""
-
- for filename in _ifcfg_files(netscriptsDir):
+def get_ifcfg_name(values, root_path=""):
+ for filename in _ifcfg_files(os.path.normpath(root_path+netscriptsDir)):
ifcfg = NetworkDevice(netscriptsDir, filename[6:])
ifcfg.loadIfcfgFile()
- # FIXME: dracut has only BOND_OPTS
- if ifcfg.get("BONDING_MASTER") == "yes" or ifcfg.get("TYPE") == "Bond":
- if ifcfg.get("DEVICE") == devname:
- return filename
+ for key, value in values:
+ if ifcfg.get(key) != value:
+ break
+ else:
+ return filename
+
+def get_bond_master_ifcfg_name(devname):
+ """Name of ifcfg file of bond device devname"""
+ return get_ifcfg_name([("TYPE", "Bond"), ("DEVICE", devname)])
def get_vlan_ifcfg_name(devname):
"""Name of ifcfg file of vlan device devname"""
-
- for filename in _ifcfg_files(netscriptsDir):
- ifcfg = NetworkDevice(netscriptsDir, filename[6:])
- ifcfg.loadIfcfgFile()
- if ifcfg.get("VLAN") == "yes" or ifcfg.get("TYPE") == "Vlan":
- if ifcfg.get("DEVICE") == devname:
- return filename
+ return get_ifcfg_name([("TYPE", "Vlan"), ("DEVICE", devname)])
def get_bond_slaves_from_ifcfgs(master_specs):
"""List of slave device names of master specified by master_specs.
@@ -751,16 +750,6 @@ def get_ksdevice_name(ksspec=""):
return ksdevice
-# note that NetworkDevice.get returns "" if key is not found
-def get_ifcfg_value(iface, key, root_path=""):
- dev = NetworkDevice(os.path.normpath(root_path + netscriptsDir), iface)
- try:
- dev.loadIfcfgFile()
- except IOError as e:
- log.debug("get_ifcfg_value %s %s: %s", iface, key, e)
- return ""
- return dev.get(key)
-
def set_hostname(hn):
if flags.imageInstall:
log.info("image install -- not setting hostname")
--
1.7.11.7
More information about the anaconda-patches
mailing list