def _clean(self, image_rootdir): # TODO: revise method, rewrite if needed LOG.info('Performing image cleanup') LOG.debug('Truncating log files') logs_path = os.path.join(image_rootdir, 'var/log') if os.path.exists(logs_path): for basename in os.listdir(logs_path): filename = os.path.join(logs_path, basename) if os.path.isfile(filename): try: coreutils.truncate(filename) except OSError, e: LOG.error("Cannot truncate file '%s'. %s", filename, e) shutil.rmtree(os.path.join(logs_path, 'scalarizr/scripting'))
def cleanup_image(self, rootdir): LOG.info('Performing image cleanup') # Truncate logs LOG.debug('Cleanuping image') LOG.debug('Truncating log files') logs_path = os.path.join(rootdir, 'var/log') if os.path.exists(logs_path): for basename in os.listdir(logs_path): filename = os.path.join(logs_path, basename) if os.path.isfile(filename): try: coreutils.truncate(filename) except OSError, e: self._logger.error("Cannot truncate file '%s'. %s", filename, e) shutil.rmtree(os.path.join(logs_path, 'scalarizr/scripting'))
def cleanup_image(self, rootdir): LOG.info('Perforing image cleanup') # Truncate logs LOG.debug('Cleanuping image') LOG.debug('Truncating log files') logs_path = os.path.join(rootdir, 'var/log') if os.path.exists(logs_path): for basename in os.listdir(logs_path): filename = os.path.join(logs_path, basename) if os.path.isfile(filename): try: coreutils.truncate(filename) except OSError, e: self._logger.error("Cannot truncate file '%s'. %s", filename, e) shutil.rmtree(os.path.join(logs_path, 'scalarizr/scripting'))