|
|
aa1b57 |
From 60dd21358c94c7bae08410100af99cd5eb34ecc6 Mon Sep 17 00:00:00 2001
|
|
|
aa1b57 |
From: Fernando Fernandez Mancera <ffmancera@riseup.net>
|
|
|
aa1b57 |
Date: Mon, 2 Mar 2020 14:30:09 +0100
|
|
|
aa1b57 |
Subject: [PATCH] ActiveConnection: Handle uninitialized device
|
|
|
aa1b57 |
|
|
|
aa1b57 |
Handle `ActiveConnection._nmdev` being None. This should fix a Traceback
|
|
|
aa1b57 |
when the openvswitch service is not running:
|
|
|
aa1b57 |
|
|
|
aa1b57 |
Traceback (most recent call last):
|
|
|
aa1b57 |
File "/usr/lib/python3.6/site-packages/libnmstate/nm/connection.py", line 226, in _active_connection_callback
|
|
|
aa1b57 |
ac.devname, ac.reason
|
|
|
aa1b57 |
File "/usr/lib/python3.6/site-packages/libnmstate/nm/active_connection.py", line 171, in devname
|
|
|
aa1b57 |
return self._nmdev.get_iface()
|
|
|
aa1b57 |
AttributeError: 'NoneType' object has no attribute 'get_iface'
|
|
|
aa1b57 |
|
|
|
aa1b57 |
Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
|
|
|
aa1b57 |
---
|
|
|
aa1b57 |
libnmstate/nm/active_connection.py | 16 +++++++++-------
|
|
|
aa1b57 |
libnmstate/nm/connection.py | 2 +-
|
|
|
aa1b57 |
2 files changed, 10 insertions(+), 8 deletions(-)
|
|
|
aa1b57 |
|
|
|
aa1b57 |
diff --git a/libnmstate/nm/active_connection.py b/libnmstate/nm/active_connection.py
|
|
|
aa1b57 |
index 7b70b2a..c81ee2b 100644
|
|
|
aa1b57 |
--- a/libnmstate/nm/active_connection.py
|
|
|
aa1b57 |
+++ b/libnmstate/nm/active_connection.py
|
|
|
aa1b57 |
@@ -1,5 +1,5 @@
|
|
|
aa1b57 |
#
|
|
|
aa1b57 |
-# Copyright (c) 2019 Red Hat, Inc.
|
|
|
aa1b57 |
+# Copyright (c) 2019-2020 Red Hat, Inc.
|
|
|
aa1b57 |
#
|
|
|
aa1b57 |
# This file is part of nmstate
|
|
|
aa1b57 |
#
|
|
|
aa1b57 |
@@ -86,7 +86,7 @@ class ActiveConnection:
|
|
|
aa1b57 |
if self._mainloop.is_action_canceled(e):
|
|
|
aa1b57 |
logging.debug(
|
|
|
aa1b57 |
"Connection deactivation aborted on %s: error=%s",
|
|
|
aa1b57 |
- self._nmdev.get_iface(),
|
|
|
aa1b57 |
+ self.devname,
|
|
|
aa1b57 |
e,
|
|
|
aa1b57 |
)
|
|
|
aa1b57 |
else:
|
|
|
aa1b57 |
@@ -105,20 +105,19 @@ class ActiveConnection:
|
|
|
aa1b57 |
else:
|
|
|
aa1b57 |
self._mainloop.quit(
|
|
|
aa1b57 |
"Connection deactivation failed on {}: "
|
|
|
aa1b57 |
- "error={}".format(self._nmdev.get_iface(), e)
|
|
|
aa1b57 |
+ "error={}".format(self.devname, e)
|
|
|
aa1b57 |
)
|
|
|
aa1b57 |
return
|
|
|
aa1b57 |
|
|
|
aa1b57 |
if success:
|
|
|
aa1b57 |
logging.debug(
|
|
|
aa1b57 |
- "Connection deactivation succeeded on %s",
|
|
|
aa1b57 |
- self._nmdev.get_iface(),
|
|
|
aa1b57 |
+ "Connection deactivation succeeded on %s", self.devname,
|
|
|
aa1b57 |
)
|
|
|
aa1b57 |
self._mainloop.execute_next_action()
|
|
|
aa1b57 |
else:
|
|
|
aa1b57 |
self._mainloop.quit(
|
|
|
aa1b57 |
"Connection deactivation failed on %s: error=unknown"
|
|
|
aa1b57 |
- % self._nmdev.get_iface()
|
|
|
aa1b57 |
+ % self.devname
|
|
|
aa1b57 |
)
|
|
|
aa1b57 |
|
|
|
aa1b57 |
@property
|
|
|
aa1b57 |
@@ -168,7 +167,10 @@ class ActiveConnection:
|
|
|
aa1b57 |
|
|
|
aa1b57 |
@property
|
|
|
aa1b57 |
def devname(self):
|
|
|
aa1b57 |
- return self._nmdev.get_iface()
|
|
|
aa1b57 |
+ if self._nmdev:
|
|
|
aa1b57 |
+ return self._nmdev.get_iface()
|
|
|
aa1b57 |
+ else:
|
|
|
aa1b57 |
+ return None
|
|
|
aa1b57 |
|
|
|
aa1b57 |
@property
|
|
|
aa1b57 |
def nmdevice(self):
|
|
|
aa1b57 |
diff --git a/libnmstate/nm/connection.py b/libnmstate/nm/connection.py
|
|
|
aa1b57 |
index 3dc1ee1..2076734 100644
|
|
|
aa1b57 |
--- a/libnmstate/nm/connection.py
|
|
|
aa1b57 |
+++ b/libnmstate/nm/connection.py
|
|
|
aa1b57 |
@@ -223,7 +223,7 @@ class ConnectionProfile:
|
|
|
aa1b57 |
else:
|
|
|
aa1b57 |
self._mainloop.quit(
|
|
|
aa1b57 |
"Connection activation failed on {}: reason={}".format(
|
|
|
aa1b57 |
- ac.devname, ac.reason
|
|
|
aa1b57 |
+ devname, ac.reason
|
|
|
aa1b57 |
)
|
|
|
aa1b57 |
)
|
|
|
aa1b57 |
|
|
|
aa1b57 |
--
|
|
|
aa1b57 |
2.24.1
|
|
|
aa1b57 |
|