def cleanup(self): """ Clean up the host env. Umount NFS from the mount point. If there has some change for exported file system in host when setup, also clean up that. """ utils_misc.umount(self.mount_src, self.mount_dir, "nfs") if self.nfs_setup and self.unexportfs_in_clean: self.exportfs.reset_export()
def file_exists(params, filename_path): sg_uri = create_gluster_uri(params, stripped=True) g_uri = create_gluster_uri(params, stripped=False) # Using directly /tmp dir because directory should be really temporary and # should be deleted immediately when no longer needed and # created directory don't file tmp dir by any data. tmpdir = "gmount-%s" % (utils_misc.generate_random_string(6)) tmpdir_path = os.path.join("/tmp", tmpdir) while os.path.exists(tmpdir_path): tmpdir = "gmount-%s" % (utils_misc.generate_random_string(6)) tmpdir_path = os.path.join("/tmp", tmpdir) ret = False try: try: os.mkdir(tmpdir_path) glusterfs_mount(sg_uri, tmpdir_path) mount_filename_path = os.path.join(tmpdir_path, filename_path[len(g_uri):]) if os.path.exists(mount_filename_path): ret = True except Exception, e: logging.error("Failed to mount gluster volume %s to" " mount dir %s: %s" % (sg_uri, tmpdir_path, e)) finally: if utils_misc.umount(sg_uri, tmpdir_path, "glusterfs", False, "fuse.glusterfs"): try: os.rmdir(tmpdir_path) except OSError: pass else: logging.warning("Unable to unmount tmp directory %s with glusterfs" " mount.", tmpdir_path) return ret