Resolves: rhbz#1062417
NM changed handling of devices without carrier in
commit 9d0022944730b6f97ab27c18895502346e2c2245
Basically they are in DISCONNECTED state instead of UNAVAILABLE now.
---
pyanaconda/nm.py | 9 +++++++++
pyanaconda/ui/gui/spokes/network.py | 11 ++++++-----
pyanaconda/ui/tui/spokes/network.py | 4 ++--
3 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/pyanaconda/nm.py b/pyanaconda/nm.py
index ceeb8fb..3bfbaa9 100644
--- a/pyanaconda/nm.py
+++ b/pyanaconda/nm.py
@@ -68,6 +68,12 @@ class UnknownMethodGetError(Exception):
def __str__(self):
return self.__repr__()
+# bug #1062417 e.g. for ethernet device without link
+class UnknownConnectionError(Exception):
+ """Connection is not available for the device"""
+ def __str__(self):
+ return self.__repr__()
+
def _get_proxy(bus_type=Gio.BusType.SYSTEM,
flags=Gio.DBusProxyFlags.NONE,
info=None,
@@ -653,6 +659,7 @@ def nm_activate_device_connection(dev_name, con_uuid):
:raise UnmanagedDeviceError: if device is not managed by NM
or unavailable
:raise SettingsNotFoundError: if conneciton with given uuid was not found
+ :raise UnknownConnectionError: if connection is not available for the device
"""
if dev_name is None:
@@ -677,6 +684,8 @@ def nm_activate_device_connection(dev_name, con_uuid):
except GLib.GError as e:
if "org.freedesktop.NetworkManager.UnmanagedDevice" in e.message:
raise UnmanagedDeviceError(dev_name, e)
+ elif "org.freedesktop.NetworkManager.UnknownConnection" in e.message:
+ raise UnknownConnectionError(dev_name, e)
raise
def nm_add_connection(values):
diff --git a/pyanaconda/ui/gui/spokes/network.py b/pyanaconda/ui/gui/spokes/network.py
index 96a1bc5..c7c6ce1 100644
--- a/pyanaconda/ui/gui/spokes/network.py
+++ b/pyanaconda/ui/gui/spokes/network.py
@@ -97,13 +97,14 @@ def localized_string_of_device_state(device, state):
str = _("Unavailable")
elif device.get_firmware_missing():
str = _("Firmware missing")
- elif (device.get_device_type() == NetworkManager.DeviceType.ETHERNET
- and not device.get_carrier()):
- str = _("Cable unplugged")
else:
str = _("Unavailable")
elif state == NetworkManager.DeviceState.DISCONNECTED:
- str = _("Disconnected")
+ if (device.get_device_type() == NetworkManager.DeviceType.ETHERNET
+ and not device.get_carrier()):
+ str = _("Cable unplugged")
+ else:
+ str = _("Disconnected")
elif state in (NetworkManager.DeviceState.PREPARE,
NetworkManager.DeviceState.CONFIG,
NetworkManager.DeviceState.IP_CONFIG,
@@ -591,7 +592,7 @@ class NetworkControlBox(GObject.GObject):
return
try:
nm.nm_activate_device_connection(dev_name, dev_cfg.con_uuid)
- except (nm.UnmanagedDeviceError, nm.UnknownDeviceError) as e:
+ except (nm.UnmanagedDeviceError, nm.UnknownDeviceError,
nm.UnknownConnectionError) as e:
log.debug("network: on_device_off_toggled: %s" % e)
else:
try:
diff --git a/pyanaconda/ui/tui/spokes/network.py b/pyanaconda/ui/tui/spokes/network.py
index 20ad2af..c0d11ab 100644
--- a/pyanaconda/ui/tui/spokes/network.py
+++ b/pyanaconda/ui/tui/spokes/network.py
@@ -27,7 +27,7 @@ from pyanaconda.ui.tui.spokes import EditTUISpokeEntry as Entry
from pyanaconda.ui.tui.simpleline import TextWidget, ColumnWidget
from pyanaconda.i18n import N_, _
from pyanaconda import network
-from pyanaconda.nm import nm_activated_devices, nm_state, nm_devices,
nm_device_type_is_ethernet, nm_device_ip_config, nm_activate_device_connection,
nm_device_setting_value, UnmanagedDeviceError
+from pyanaconda.nm import nm_activated_devices, nm_state, nm_devices,
nm_device_type_is_ethernet, nm_device_ip_config, nm_activate_device_connection,
nm_device_setting_value, UnmanagedDeviceError, UnknownConnectionError
# pylint: disable-msg=E0611
from gi.repository import NetworkManager
@@ -195,7 +195,7 @@ class NetworkSpoke(EditTUISpoke):
uuid = nm_device_setting_value(devname, "connection",
"uuid")
try:
nm_activate_device_connection(devname, uuid)
- except UnmanagedDeviceError:
+ except (UnmanagedDeviceError, UnknownConnectionError):
self.errors.append(_("Can't apply configuration, device
activation failed."))
self.apply()
--
1.7.11.7