[PATCH rhel7-branch] network: don't crash, just log for unrecognized bond options (#1039006)
Vratislav Podzimek
vpodzime at redhat.com
Mon Sep 1 12:06:02 UTC 2014
On Mon, 2014-09-01 at 11:21 +0200, Radek Vykydal wrote:
> Resolves: rhbz#1039006
> ---
> pyanaconda/network.py | 6 +++++-
> pyanaconda/nm.py | 14 +++++++++++++-
> 2 files changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/pyanaconda/network.py b/pyanaconda/network.py
> index 144548d..3419704 100644
> --- a/pyanaconda/network.py
> +++ b/pyanaconda/network.py
> @@ -549,7 +549,11 @@ def add_connection_for_ksdata(networkdata, devname):
> values.append(['802-3-ethernet', 'mac-address', mac, 'ay'])
> dev_spec = devname
>
> - nm.nm_add_connection(values)
> + try:
> + nm.nm_add_connection(values)
> + except nm.AddConnectionError as e:
> + log.error(e)
> + return []
> added_connections.insert(0, (con_uuid, dev_spec))
> return added_connections
>
> diff --git a/pyanaconda/nm.py b/pyanaconda/nm.py
> index b958b9c..a288105 100644
> --- a/pyanaconda/nm.py
> +++ b/pyanaconda/nm.py
> @@ -74,6 +74,13 @@ class UnknownConnectionError(Exception):
> def __str__(self):
> return self.__repr__()
>
> +# bug #1039006
> +class AddConnectionError(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,
> @@ -716,7 +723,12 @@ def nm_add_connection(values):
>
> proxy = _get_proxy(object_path="/org/freedesktop/NetworkManager/Settings",
> interface_name="org.freedesktop.NetworkManager.Settings")
> - connection = proxy.AddConnection('(a{sa{sv}})', settings)
> + try:
> + connection = proxy.AddConnection('(a{sa{sv}})', settings)
> + except GLib.GError as e:
> + if "bond.options: invalid option" in e.message:
> + raise AddConnectionError(e)
Looking at these lines I feel like it should be something like
"BondOptionsError", maybe a subclass of AddConnectionError. I think in
future we will want to catch and log+ingore more edge cases, but for now
the block of code trying to add the connection looks weird with no
information about what could raise such exception.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list