From 1dac6edbe4281a3d91087d0986a1458dc542b9c7 Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Fri, 9 Sep 2016 09:34:12 -0400 Subject: [PATCH] minor update to catch expection if trying close a non existent session This will prevent the junos shared module from throwing an exception if the session is trying to be closed when it doesn't exist --- lib/ansible/module_utils/junos.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/junos.py b/lib/ansible/module_utils/junos.py index 786e415c48..16f2057866 100644 --- a/lib/ansible/module_utils/junos.py +++ b/lib/ansible/module_utils/junos.py @@ -105,8 +105,10 @@ class Netconf(object): self._connected = True def disconnect(self): - if self.device: + try: self.device.close() + except AttributeError: + pass self._connected = False ### Command methods ###