]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
csr1kv_hd_driver: Improve exception handling
authorAKamyshnikova <akamyshnikova@mirantis.com>
Fri, 19 Dec 2014 10:24:11 +0000 (13:24 +0300)
committerAnn Kamyshnikova <akamyshnikova@mirantis.com>
Wed, 24 Dec 2014 12:06:01 +0000 (15:06 +0300)
When logging exceptions the exception handling should make use
of save_and_reraise.

Partial-bug: #1305032

Change-Id: I316417f3c9cbb28ea0cf2cd24a1f5b2b803b5a95

neutron/plugins/cisco/l3/hosting_device_drivers/csr1kv_hd_driver.py

index 189f5e2771082b9ea371f64afa929e9ddddb6195..5ec76b79f52327b2c69746e02f811fbf72b2c322 100644 (file)
@@ -15,6 +15,7 @@
 import netaddr
 
 from oslo.config import cfg
+from oslo.utils import excutils
 
 from neutron.i18n import _LE
 from neutron import manager
@@ -64,10 +65,10 @@ class CSR1kvHostingDeviceDriver(hosting_device_drivers.HostingDeviceDriver):
                     vm_cfg_data += line
             return {'iosxe_config.txt': vm_cfg_data}
         except IOError:
-            LOG.exception(_LE('Failed to create config file. Trying to '
-                              'clean up.'))
-            self.delete_configdrive_files(context, mgmtport)
-            raise
+            with excutils.save_and_reraise_exception():
+                LOG.exception(_LE('Failed to create config file. Trying to '
+                                  'clean up.'))
+                self.delete_configdrive_files(context, mgmtport)
 
     @property
     def _core_plugin(self):