Bug 575 Fix token refresh for VCD VIMconnector 15/6815/1
authorRavi Chamarty <ravi.chamarty@riftio.com>
Tue, 30 Oct 2018 19:51:23 +0000 (19:51 +0000)
committerRavi Chamarty <ravi.chamarty@riftio.com>
Wed, 31 Oct 2018 14:11:48 +0000 (14:11 +0000)
Change-Id: I10ba41f3e4361410eba050a028ce7d8e015ef673
Signed-off-by: Ravi Chamarty <ravi.chamarty@riftio.com>
osm_ro/vimconn_vmware.py

index 30c9908..c65482b 100644 (file)
@@ -6327,12 +6327,18 @@ class vimconnector(vimconn.vimconnector):
 
             Returns org and vdc object
         """
-        org = Org(self.client, resource=self.client.get_org())
-        vdc = org.get_vdc(self.tenant_name)
+        vdc = None
+        try:
+            org = Org(self.client, resource=self.client.get_org())
+            vdc = org.get_vdc(self.tenant_name)
+        except Exception as e:
+            # pyvcloud not giving a specific exception, Refresh nevertheless
+            self.logger.debug("Received exception {}, refreshing token ".format(str(e)))
 
         #Retry once, if failed by refreshing token
         if vdc is None:
             self.get_token()
+            org = Org(self.client, resource=self.client.get_org())
             vdc = org.get_vdc(self.tenant_name)
 
         return org, vdc