22195615 sysconfig temporary directory not always cleaned up
authordavid.comay@oracle.com
Tue, 15 Dec 2015 00:08:40 -0800
changeset 5193 3120ba36a435
parent 5192 f5359fbbaadd
child 5194 e5ea1fd7704a
22195615 sysconfig temporary directory not always cleaned up
components/openstack/nova/files/solariszones/driver.py
--- a/components/openstack/nova/files/solariszones/driver.py	Tue Dec 15 00:08:40 2015 -0800
+++ b/components/openstack/nova/files/solariszones/driver.py	Tue Dec 15 00:08:40 2015 -0800
@@ -1516,7 +1516,7 @@
             options.extend(['-c', sc_dir])
 
         try:
-            LOG.debug(_("installing instance '%s' (%s)") %
+            LOG.debug(_("Installing instance '%s' (%s)") %
                       (name, instance['display_name']))
             zone.install(options=options)
         except Exception as reason:
@@ -1524,13 +1524,9 @@
                         "via zonemgr(3RAD): %s") % (name, reason))
             raise
 
-        LOG.debug(_("installation of instance '%s' (%s) complete") %
+        LOG.debug(_("Installation of instance '%s' (%s) complete") %
                   (name, instance['display_name']))
 
-        if os.listdir(sc_dir):
-            # remove the sc_profile temp directory
-            shutil.rmtree(sc_dir)
-
     def _power_on(self, instance):
         """Power on a Solaris Zone."""
         name = instance['name']
@@ -1631,6 +1627,8 @@
             LOG.error(_("Unable to attach root zpool volume '%s' to instance "
                         "%s: %s") % (volume['id'], instance['name'], reason))
             self._volume_api.delete(context, volume_id)
+            # remove the sc_profile temp directory
+            shutil.rmtree(sc_dir)
             raise
 
         name = instance['name']
@@ -1652,6 +1650,9 @@
                 self._volume_api.delete(context, volume_id)
             self._delete_config(instance)
             raise
+        finally:
+            # remove the sc_profile temp directory
+            shutil.rmtree(sc_dir)
 
         if connection_info:
             bdm = objects.BlockDeviceMapping(