From: Christos Sfakianakis <csfakian(a)redhat.com>
Add a __delattr__ method to catch deletion of RemoteDevice
objects from the self._objects dictionary. The objects need
to have already been marked for deletion, or the call is routed
to the superclass.
Signed-off-by: Christos Sfakianakis <csfakian(a)redhat.com>
---
lnst/Controller/Namespace.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/lnst/Controller/Namespace.py b/lnst/Controller/Namespace.py
index 88f82eb..db09156 100644
--- a/lnst/Controller/Namespace.py
+++ b/lnst/Controller/Namespace.py
@@ -195,6 +195,13 @@ class Namespace(object):
if not self._custom_setattr(name, value):
super(Namespace, self).__setattr__(name, value)
+ def __delattr__(self, name):
+ if name in self._objects and isinstance(self._objects[name], RemoteDevice):
+ if self._objects[name].deleted:
+ del self._objects[name]
+ else:
+ super(Namespace, self).__delattr__(name)
+
def _unset(self, value):
k_to_del = None
for k, v in self._objects.items():
--
2.17.1