Ejemplo n.º 1
0
 def umount_filesystems(self, workdir):
     try:
         utils.umount_filesystems(workdir,
                                  timeout=self.config.bootstrap.timelimit)
     except commands.CommandTimeout as e:
         log.error("Can't umount filesystem, timeout reached")
         return False
     except commands.CommandFailed as e:
         log.error("Failed to umount filesystem: %s" % e)
         return False
     return True
Ejemplo n.º 2
0
def kill_and_remove_dir(directory):
    """
    Kill all processes running inside given directory and remove it.
    Used mostly for removing temporary directories.
    """
    found = True
    while found:
        for pid in directory_pids(directory):
            kill_pid(pid)
        else:
            found = False

    try:
        umount_filesystems(directory)
    except Exception as e:
        log.error("Error while unmounting filesystem inside "
                  "package: %s" % e)
    else:
        log.info("Removing directory: %s" % directory)
        shutil.rmtree(directory.encode('utf-8'))