]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Access correct key for template name
authorPaul Michali <pcm@cisco.com>
Fri, 12 Sep 2014 18:16:35 +0000 (14:16 -0400)
committerPaul Michali <pcm@cisco.com>
Tue, 16 Sep 2014 10:56:30 +0000 (06:56 -0400)
When an exception occurs while loading the config agent driver, the
handler tries to log a message, but accesses the wrong key to get the
template name. This causes another exception, which masks the original
exception.

This change accesses the correct key and performs logging inside a
with block to (defensively) preserve the exception context.

Change-Id: I3991bc4c509bbd8d68f7a1c8c8314404f2e0eafa
Closes-Bug: #1368900

neutron/plugins/cisco/cfg_agent/device_drivers/driver_mgr.py

index c04c96b391f0c5941a7e51091cd9ca5dbcf5ac49..7ca0ac61061dcd7c88e40c8d7b38c2f3f797dc78 100644 (file)
@@ -77,11 +77,12 @@ class DeviceDriverManager(object):
                 self._drivers[resource_id] = driver
             return driver
         except ImportError:
-            LOG.exception(_("Error loading cfg agent driver %(driver)s for "
-                            "hosting device template %(t_name)s(%(t_id)s)"),
-                          {'driver': driver_class, 't_id': hd_id,
-                           't_name': hosting_device['name']})
             with excutils.save_and_reraise_exception(reraise=False):
+                LOG.exception(_("Error loading cfg agent driver %(driver)s "
+                                "for hosting device template "
+                                "%(t_name)s(%(t_id)s)"),
+                              {'driver': driver_class, 't_id': hd_id,
+                               't_name': resource['name']})
                 raise cfg_exceptions.DriverNotExist(driver=driver_class)
         except KeyError as e:
             with excutils.save_and_reraise_exception(reraise=False):