Commits

Anonymous committed 0b095c5

Fixed a bug when calling the logout function more than once in a row.

Comments (0)

Files changed (2)

psphere/__init__.py

         :type properties: list or None (default). If None, flush entire cache.
 
         """
-        if properties is None:
-            del(self._cache)
-        else:
-            for prop in properties:
-                if prop in self._cache:
-                    del(self._cache[prop])
+        if hasattr(self, '_cache'):
+            if properties is None:
+                del(self._cache)
+            else:
+                for prop in properties:
+                    if prop in self._cache:
+                        del(self._cache[prop])
 
     def update(self, properties=None):
         """Updates the properties being held for this instance.

psphere/client.py

 
     def logout(self):
         """Logout of a vSphere server."""
-        self.si.flush_cache()
-        self.sc.sessionManager.Logout()
-        self._logged_in = False
+        if self._logged_in is True:
+            self.si.flush_cache()
+            self.sc.sessionManager.Logout()
+            self._logged_in = False
 
     def invoke(self, method, _this, **kwargs):
         """Invoke a method on the server.