diff --git a/slapos/slap/standalone.py b/slapos/slap/standalone.py index fa85b2bd88b14f0e9f44f9ded63e91760caca0f9..24de7bf9c4490266b11666b429b7095aa53f0de2 100644 --- a/slapos/slap/standalone.py +++ b/slapos/slap/standalone.py @@ -60,7 +60,7 @@ from .interface.slap import IRequester from ..grid.slapgrid import SLAPGRID_PROMISE_FAIL from .slap import slap -from ..util import dumps +from ..util import dumps, rmtree from ..grid.svcbackend import getSupervisorRPC @@ -548,7 +548,7 @@ class StandaloneSlapOS(object): self._logger.debug( "removing partition no longer part of format spec %s", part) # remove partition directory - shutil.rmtree(part) + rmtree(part) # remove partition supervisor config, if it was not removed cleanly supervisor_conf = os.path.join( self._instance_root, diff --git a/slapos/tests/test_standalone.py b/slapos/tests/test_standalone.py index a2585d7d96c17df7dff722db9b2b34b83c54808f..2673d3d1737da3231f389f19336bfdda6eb53c33 100644 --- a/slapos/tests/test_standalone.py +++ b/slapos/tests/test_standalone.py @@ -111,6 +111,23 @@ class TestSlapOSStandaloneSetup(unittest.TestCase): ['slappart0'], [cp.getId() for cp in standalone.computer.getComputerPartitionList()]) + def test_reformat_less_chmod_files(self): + working_dir = tempfile.mkdtemp(prefix=__name__) + self.addCleanup(shutil.rmtree, working_dir) + standalone = StandaloneSlapOS( + working_dir, SLAPOS_TEST_IPV4, SLAPOS_TEST_PORT) + self.addCleanup(standalone.stop) + standalone.format(2, SLAPOS_TEST_IPV4, SLAPOS_TEST_IPV6) + # removing this directory should not be a problem + chmoded_dir_path = os.path.join(standalone.instance_directory, 'slappart1', 'directory') + os.mkdir(chmoded_dir_path) + os.chmod(chmoded_dir_path, 0o000) + standalone.format(1, SLAPOS_TEST_IPV4, SLAPOS_TEST_IPV6) + self.assertFalse(os.path.exists(chmoded_dir_path)) + self.assertEqual( + ['slappart0'], + [cp.getId() for cp in standalone.computer.getComputerPartitionList()]) + def test_reformat_different_base_name(self): working_dir = tempfile.mkdtemp(prefix=__name__) self.addCleanup(shutil.rmtree, working_dir)