22195615 sysconfig temporary directory not always cleaned up s11u3-sru
authorsaurabh.vyas@oracle.com
Tue, 15 Dec 2015 00:08:40 -0800
branchs11u3-sru
changeset 5411 27ae522d32d7
parent 5410 2fe121cb8570
child 5412 8566c7ab4a73
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
@@ -1364,7 +1364,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:
@@ -1372,13 +1372,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']
@@ -1479,6 +1475,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']
@@ -1499,6 +1497,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(