From: Christos Sfakianakis <csfakian(a)redhat.com>
Return None in case realdev has not been set or cannot be
found.
Signed-off-by: Christos Sfakianakis <csfakian(a)redhat.com>
---
lnst/Devices/VxlanDevice.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/lnst/Devices/VxlanDevice.py b/lnst/Devices/VxlanDevice.py
index c317913..183d3e1 100644
--- a/lnst/Devices/VxlanDevice.py
+++ b/lnst/Devices/VxlanDevice.py
@@ -13,7 +13,7 @@ olichtne(a)redhat.com (Ondrej Lichtner)
import pyroute2
import logging
from lnst.Common.Logs import log_exc_traceback
-from lnst.Common.DeviceError import DeviceError, DeviceConfigError
+from lnst.Common.DeviceError import DeviceError, DeviceConfigError, DeviceNotFound
from lnst.Common.IpAddress import ipaddress
from lnst.Devices.Device import Device
from lnst.Devices.SoftDevice import SoftDevice
@@ -43,9 +43,11 @@ class VxlanDevice(SoftDevice):
def realdev(self):
if self._nl_msg is None:
return None
-
- if_id = int(self._get_linkinfo_data_attr("IFLA_VXLAN_LINK"))
- return self._if_manager.get_device(if_id)
+ try:
+ if_id = int(self._get_linkinfo_data_attr("IFLA_VXLAN_LINK"))
+ return self._if_manager.get_device(if_id)
+ except (TypeError, DeviceNotFound):
+ return None
@realdev.setter
def realdev(self, val):
--
2.17.1