From a2ef082cb0b25d14595a8810adb16df3f9661e43 Mon Sep 17 00:00:00 2001 From: Paul Michali Date: Fri, 12 Sep 2014 14:16:35 -0400 Subject: [PATCH] Access correct key for template name 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 --- .../plugins/cisco/cfg_agent/device_drivers/driver_mgr.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/neutron/plugins/cisco/cfg_agent/device_drivers/driver_mgr.py b/neutron/plugins/cisco/cfg_agent/device_drivers/driver_mgr.py index c04c96b39..7ca0ac610 100644 --- a/neutron/plugins/cisco/cfg_agent/device_drivers/driver_mgr.py +++ b/neutron/plugins/cisco/cfg_agent/device_drivers/driver_mgr.py @@ -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): -- 2.45.2