From: Ananda Baitharu Date: Wed, 16 Nov 2016 14:20:16 +0000 (-0500) Subject: RIFT-14308 Meaningful logs while initalizing Openstack driver X-Git-Tag: v1.1.0~52^2 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F78%2F678%2F1;p=osm%2FSO.git RIFT-14308 Meaningful logs while initalizing Openstack driver Signed-off-by: Ananda Baitharu --- diff --git a/common/python/rift/mano/cloud/accounts.py b/common/python/rift/mano/cloud/accounts.py index 57ca55fb..d3aa860e 100644 --- a/common/python/rift/mano/cloud/accounts.py +++ b/common/python/rift/mano/cloud/accounts.py @@ -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, diff --git a/rwcal/plugins/vala/rwcal_openstack/rift/rwcal/openstack/openstack_drv.py b/rwcal/plugins/vala/rwcal_openstack/rift/rwcal/openstack/openstack_drv.py index 2505da3d..a720b8a5 100644 --- a/rwcal/plugins/vala/rwcal_openstack/rift/rwcal/openstack/openstack_drv.py +++ b/rwcal/plugins/vala/rwcal_openstack/rift/rwcal/openstack/openstack_drv.py @@ -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 diff --git a/rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py b/rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py index 19eea3b3..8a2d275a 100644 --- a/rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py +++ b/rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py @@ -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"