Exemple #1
0
 def selftest(self):
     """
     Run internal self test
     """
     try:
         self.oop.os.statvfs(self.domaindir)
     except OSError as e:
         if e.errno == errno.ESTALE:
             # In case it is "Stale NFS handle" we are taking preventive
             # measures and unmounting this NFS resource. Chances are
             # that is the most intelligent thing we can do in this
             # situation anyway.
             self.log.info("Unmounting stale file system %s",
                           self.mountpoint)
             mount.getMountFromTarget(self.mountpoint).umount()
             raise se.FileStorageDomainStaleNFSHandle()
         raise
Exemple #2
0
 def selftest(self):
     """
     Run internal self test
     """
     try:
         self.oop.os.statvfs(self.domaindir)
     except OSError as e:
         if e.errno == errno.ESTALE:
             # In case it is "Stale NFS handle" we are taking preventive
             # measures and unmounting this NFS resource. Chances are
             # that is the most intelligent thing we can do in this
             # situation anyway.
             self.log.info("Unmounting stale file system %s",
                           self.mountpoint)
             mount.getMountFromTarget(self.mountpoint).umount()
             raise se.FileStorageDomainStaleNFSHandle()
         raise
Exemple #3
0
def mountMetaVolume(metaVolumeName):
    def _metaVolumeFstabUpdate(metaVolumeName):
        try:
            fs_spec = "127.0.0.1:" + metaVolumeName
            fstab.FsTab().add(fs_spec,
                              META_VOL_MOUNT_POINT,
                              FS_TYPE,
                              mntOpts=['defaults', '_netdev'])
        except IOError as e:
            raise ge.GlusterMetaVolumeFstabUpdateFailedException(
                err=["fstab update failed", str(e)])
        except ge.GlusterHostStorageDeviceFsTabFoundException as e:
            logging.warn(e.message)

    _metaVolumeFstabUpdate(metaVolumeName)

    if os.path.ismount(META_VOL_MOUNT_POINT):
        try:
            fs_spec = mount.getMountFromTarget(
                os.path.realpath(META_VOL_MOUNT_POINT)).fs_spec
            if fs_spec.endswith(META_VOLUME):
                logging.warn("Meta Volume %s already mounted at %s" %
                             (META_VOLUME, META_VOL_MOUNT_POINT))
                return True
            else:
                raise ge.GlusterMetaVolumeMountFailedException(err=[
                    "%s already mounted at %s" %
                    (fs_spec, META_VOL_MOUNT_POINT)
                ])
        except OSError as e:
            raise ge.GlusterMetaVolumeMountFailedException(
                err=["Failed to check if volume is already mounted",
                     str(e)])
    else:
        try:
            os.makedirs(META_VOL_MOUNT_POINT, 0o755)
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise ge.GlusterMetaVolumeMountFailedException(
                    err=['Mount Point creation failed',
                         str(e)])

    command = [constants.EXT_MOUNT, META_VOL_MOUNT_POINT]
    try:
        out = commands.run(command)
    except cmdutils.Error as e:
        raise ge.GlusterMetaVolumeMountFailedException(e.rc, out, e.err)
    return True
Exemple #4
0
def mountMetaVolume(metaVolumeName):
    def _metaVolumeFstabUpdate(metaVolumeName):
        try:
            fs_spec = "127.0.0.1:" + metaVolumeName
            fstab.FsTab().add(fs_spec, META_VOL_MOUNT_POINT, FS_TYPE,
                              mntOpts=['defaults', '_netdev'])
        except IOError as e:
            raise ge.GlusterMetaVolumeFstabUpdateFailedException(
                err=["fstab update failed", str(e)])
        except ge.GlusterHostStorageDeviceFsTabFoundException as e:
            logging.warn(e.message)

    _metaVolumeFstabUpdate(metaVolumeName)

    if os.path.ismount(META_VOL_MOUNT_POINT):
        try:
            fs_spec = mount.getMountFromTarget(
                os.path.realpath(META_VOL_MOUNT_POINT)).fs_spec
            if fs_spec.endswith(META_VOLUME):
                logging.warn("Meta Volume %s already mounted at %s" % (
                    META_VOLUME, META_VOL_MOUNT_POINT))
                return True
            else:
                raise ge.GlusterMetaVolumeMountFailedException(
                    err=["%s already mounted at %s" % (
                        fs_spec, META_VOL_MOUNT_POINT)])
        except OSError as e:
            raise ge.GlusterMetaVolumeMountFailedException(
                err=["Failed to check if volume is already mounted",
                     str(e)])
    else:
        try:
            os.makedirs(META_VOL_MOUNT_POINT, 0o755)
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise ge.GlusterMetaVolumeMountFailedException(
                    err=['Mount Point creation failed', str(e)])

    command = [constants.EXT_MOUNT, META_VOL_MOUNT_POINT]
    rc, out, err = commands.execCmd(command)
    if rc:
        raise ge.GlusterMetaVolumeMountFailedException(
            rc, out, err)
    return True
Exemple #5
0
 def getRealPath(self):
     try:
         return mount.getMountFromTarget(self.mountpoint).fs_spec
     except mount.MountError:
         return ""
Exemple #6
0
 def getRealPath(self):
     try:
         return mount.getMountFromTarget(self.mountpoint).fs_spec
     except mount.MountError:
         return ""