Network interfaces are read from NetworkManager via DBus but not all interfaces must be registered when anaconda starts. This could result in reading non-existing configuration file in initialization of Network spoke.
This fix will dump configuration files for every new interface in every refresh of the Network spoke.
Resolves: rhbz#1197960
From: Jiri Konecny jkonecny@redhat.com
Network interfaces are read from NetworkManager via DBus but not all interfaces must be registered when anaconda starts. This could result in reading non-existing configuration file in initialization of Network spoke.
This fix will dump configuration files for every new interface in every refresh of the Network spoke.
Resolves: rhbz#1197960 --- pyanaconda/ui/tui/spokes/network.py | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/pyanaconda/ui/tui/spokes/network.py b/pyanaconda/ui/tui/spokes/network.py index 6c71dee..6674ede 100644 --- a/pyanaconda/ui/tui/spokes/network.py +++ b/pyanaconda/ui/tui/spokes/network.py @@ -33,6 +33,9 @@ from pyanaconda.regexes import IPV4_PATTERN_WITHOUT_ANCHORS from pyanaconda.constants_text import INPUT_PROCESSED
+import logging +log = logging.getLogger("anaconda") + import re
__all__ = ["NetworkSpoke"] @@ -51,16 +54,29 @@ def __init__(self, app, data, storage, payload, instclass): self.errors = []
def initialize(self): - for name in nm.nm_devices(): + self._load_new_devices() + + EditTUISpoke.initialize(self) + + def _load_new_devices(self): + """ Register new devices to supported devices list. """ + devices = nm.nm_devices() + intf_dumped = network.dumpMissingDefaultIfcfgs() + if intf_dumped: + log.debug("Dumped interfaces: {0}".format(intf_dumped)) + + for name in devices: + if name in self.supported_devices: + # this device is already registered + continue if nm.nm_device_type_is_ethernet(name): # ignore slaves if nm.nm_device_setting_value(name, "connection", "slave-type"): continue self.supported_devices.append(name)
- EditTUISpoke.initialize(self) if not self.data.network.seen: - self._update_network_data() + self._update_network_data(devices)
@property def completed(self): @@ -126,6 +142,7 @@ def _activated_device_msg(self, devname):
def refresh(self, args=None): """ Refresh screen. """ + self._load_new_devices() EditTUISpoke.refresh(self, args)
# on refresh check if we haven't got hostname from NM on activated @@ -213,13 +230,13 @@ def input(self, args, key):
def apply(self): " Apply all of our settings.""" - self._update_network_data() + self._update_network_data(self.supported_devices)
- def _update_network_data(self): + def _update_network_data(self, devices): hostname = self.data.network.hostname
self.data.network.network = [] - for name in nm.nm_devices(): + for name in devices: nd = network.ksdata_from_ifcfg(name) if not nd: continue
Added label: master.
@@ -51,16 +54,29 @@ def __init__(self, app, data, storage, payload, instclass): self.errors = []
def initialize(self):
for name in nm.nm_devices():
self._load_new_devices()EditTUISpoke.initialize(self)- def _load_new_devices(self):
""" Register new devices to supported devices list. """devices = nm.nm_devices()intf_dumped = network.dumpMissingDefaultIfcfgs()if intf_dumped:log.debug("Dumped interfaces: {0}".format(intf_dumped))
I think we can drop using .format() for simple things like this. I used to encourage it because at one time it looked like py3 was going to deprecate % but in the end it really is cleaner for just printing something.
So use ``%`` instead of ``.format()``.
Ok, no problem with that. I'll change it before the push.
So use % instead of .format().
Ok, no problem with that. I'll change it before the push.
Actually, in this particular case, you should use neither ``%`` nor ``.format()`` as the ``log.*()`` functions behave like ``printf()`` in *C* with some lazy evaluation of the arguments (don't know the details, but we have a pylint check for not using ``%`` inside ``log.*()`` calls).
Oh I see. So this is the right way? ``log.debug("Dumped interfaces:", intf_dumped)``
Oh I see. So this is the right way? log.debug("Dumped interfaces:", intf_dumped)
No, you have to tell it where tu do the substitution ;) I.e.: ``log.debug("Dumped interfaces: ``**%s**``", intf_dumped)``
Nice, thank you both for help :) I'm still changing it before push If nothing else is wrong
@@ -51,16 +54,29 @@ def __init__(self, app, data, storage, payload, instclass): self.errors = []
def initialize(self):
for name in nm.nm_devices():
self._load_new_devices()EditTUISpoke.initialize(self)- def _load_new_devices(self):
""" Register new devices to supported devices list. """devices = nm.nm_devices()intf_dumped = network.dumpMissingDefaultIfcfgs()if intf_dumped:log.debug("Dumped interfaces: {0}".format(intf_dumped))for name in devices:if name in self.supported_devices:# this device is already registeredcontinue if nm.nm_device_type_is_ethernet(name): # ignore slaves if nm.nm_device_setting_value(name, "connection", "slave-type"): continue self.supported_devices.append(name)
EditTUISpoke.initialize(self) if not self.data.network.seen:self._update_network_data()
self._update_network_data(devices)
I think we can keep doing _update_network_data() only in initialize and apply (not in every _load_new_devices / refresh)? So I'd keep it in initialize after _load_new_devices().
@@ -213,13 +230,13 @@ def input(self, args, key):
def apply(self): " Apply all of our settings."""
self._update_network_data()
self._update_network_data(self.supported_devices)
We need to update network data not only for self.supported_devices (ie devices for which we support text ui configuration) but also for other devices configured by other means eg via boot options or kickstart (bond, vlan, ...). _update_network_data actually always recreates the data.network.network from scratch (although the name of the function doesn't suggest so :/). So in the end we don't seem to need to parametrize the function with devices argument.
I will create new pull request with the changes.
Closed.
anaconda-patches@lists.fedorahosted.org