diff --git a/slapos/grid/SlapObject.py b/slapos/grid/SlapObject.py index af6abb39ae26dd265855f3735d925bfeff3a3d8e..b5b31ba0f4ffd6dbd46d25dbf2393d31127f9551 100644 --- a/slapos/grid/SlapObject.py +++ b/slapos/grid/SlapObject.py @@ -173,11 +173,17 @@ class Software(object): finally: shutil.rmtree(extends_cache) - def remove(self): - """Removes the part that was installed. - """ + def destroy(self): + """Removes software release.""" + def retry(func, path, exc): + # inspired on slapos.buildout hard remover + if func == os.path.islink: + os.unlink(path) + else: + os.chmod (path, 0600) + func(path) try: - shutil.rmtree(self.software_path) + shutil.rmtree(self.software_path, onerror=retry) except IOError as error: error_string = "I/O error while removing software (%s): %s" % (self.url, error) diff --git a/slapos/grid/slapgrid.py b/slapos/grid/slapgrid.py index 30e3289e24dbc0c552be4b5fe232633dd571c92d..74fba0bae97c662db47f09db336cb246ff8fb79e 100644 --- a/slapos/grid/slapgrid.py +++ b/slapos/grid/slapgrid.py @@ -427,10 +427,11 @@ class Slapgrid(object): logger.info("Processing software releases...") clean_run = True for software_release in self.computer.getSoftwareReleaseList(): + state = software_release.getState() try: - software_release.building() software_release_uri = software_release.getURI() - Software(url=software_release_uri, software_root=self.software_root, + software = Software(url=software_release_uri, + software_root=self.software_root, console=self.console, buildout=self.buildout, signature_private_key_file=self.signature_private_key_file, signature_certificate_list=self.signature_certificate_list, @@ -443,7 +444,12 @@ class Slapgrid(object): shacache_cert_file=self.shacache_cert_file, shacache_key_file=self.shacache_key_file, shadir_cert_file=self.shadir_cert_file, - shadir_key_file=self.shadir_key_file).install() + shadir_key_file=self.shadir_key_file) + if state == 'available': + software_release.building() + software.install() + elif state == 'destroyed': + software.destroy() except (SystemExit, KeyboardInterrupt): exception = traceback.format_exc() software_release.error(exception) @@ -454,7 +460,10 @@ class Slapgrid(object): software_release.error(exception) clean_run = False else: - software_release.available() + if state == 'available': + software_release.available() + elif state == 'destroyed': + software_release.destroyed() logger.info("Finished software releases...") return clean_run