RIFT-14308 Meaningful logs while initalizing Openstack driver 35/735/1
authorPhilip Joseph <philip.joseph@riftio.com>
Wed, 16 Nov 2016 14:20:16 +0000 (09:20 -0500)
committerPhilip Joseph <philip.joseph@riftio.com>
Mon, 28 Nov 2016 19:36:57 +0000 (01:06 +0530)
Original fix by: Ananda Baitharu <ananda.baitharu@riftio.com>
Signed-off-by: Philip Joseph <philip.joseph@riftio.com>
common/python/rift/mano/cloud/accounts.py
rwcal/plugins/vala/rwcal_openstack/rift/rwcal/openstack/openstack_drv.py
rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py

index 57ca55f..d3aa860 100644 (file)
@@ -21,6 +21,7 @@ from gi import require_version
 require_version('RwcalYang', '1.0')
 require_version('RwTypes', '1.0')
 require_version('RwCloudYang', '1.0')
+require_version('RwCal', '1.0')
 
 from gi.repository import (
         RwTypes,
index 2505da3..a720b8a 100644 (file)
@@ -123,6 +123,8 @@ class KeystoneDriver(object):
         try:
             ksconn = self._get_keystone_connection()
             service_endpoint  = ksconn.service_catalog.url_for(**endpoint_kwargs)
+        except (KeystoneExceptions.Unauthorized, KeystoneExceptions.AuthorizationFailure) as e:
+            raise
         except Exception as e:
             logger.error("OpenstackDriver: Service Catalog discovery operation failed for service_type: %s, endpoint_type: %s. Exception: %s" %(service_type, endpoint_type, str(e)))
             raise
@@ -1652,6 +1654,8 @@ class OpenstackDriver(object):
             try:
                 ntconn   = self.neutron_drv._get_neutron_connection()
                 networks = ntconn.list_networks()
+            except (KeystoneExceptions.Unauthorized, KeystoneExceptions.AuthorizationFailure) as e:
+                raise
             except Exception as e:
                 logger.error("OpenstackDriver: List Network operation failed. Exception: %s" %(str(e)))
                 raise
index ddf665a..a83d610 100644 (file)
@@ -26,6 +26,7 @@ import rw_status
 import rift.cal.rwcal_status as rwcal_status
 import rwlogger
 import neutronclient.common.exceptions as NeutronException
+import keystoneclient.exceptions as KeystoneExceptions
 
 from gi.repository import (
     GObject,
@@ -88,6 +89,9 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud):
                                          tenant_name   = account.openstack.tenant,
                                          mgmt_network  = account.openstack.mgmt_network,
                                          cert_validate = account.openstack.cert_validate )
+            except (KeystoneExceptions.Unauthorized, KeystoneExceptions.AuthorizationFailure,
+                        NeutronException.NotFound) as e:
+                raise
             except Exception as e:
                 self.log.error("RwcalOpenstackPlugin: OpenstackDriver init failed. Exception: %s" %(str(e)))
                 raise
@@ -118,11 +122,27 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud):
             Validation Code and Details String
         """
         status = RwcalYang.CloudConnectionStatus()
-
         try:
             with self._use_driver(account) as drv:
                 drv.validate_account_creds()
 
+        except KeystoneExceptions.Unauthorized as e:
+            self.log.error("Invalid credentials given for VIM account %s" %account.name)
+            status.status = "failure"
+            status.details = "Invalid Credentials: %s" % str(e)
+
+        except KeystoneExceptions.AuthorizationFailure as e:
+            self.log.error("Bad authentication URL given for VIM account %s. Given auth url: %s" % (
+            account.name, account.openstack.auth_url))
+            status.status = "failure"
+            status.details = "Invalid auth url: %s" % str(e)
+
+        except NeutronException.NotFound as e:
+            self.log.error("Given management network %s could not be found for VIM account %s" % (
+                        account.openstack.mgmt_network, account.name))
+            status.status = "failure"
+            status.details = "mgmt network does not exist: %s" % str(e)
+
         except openstack_drv.ValidationError as e:
             self.log.error("RwcalOpenstackPlugin: OpenstackDriver credential validation failed. Exception: %s", str(e))
             status.status = "failure"