Esempio n. 1
0
    def llPrepare(self, rw=False, setrw=False):
        """
        Make volume accessible as readonly (internal) or readwrite (leaf)
        """
        def copyUserModeToGroup(path):
            # Volumes leaves created in 2.2 did not have group writeable bit
            # set. We have to set it here if we want qemu-kvm to write to old
            # NFS volumes.
            mode = self.oop.os.stat(path).st_mode
            usrmode = (mode & 0700) >> 3
            grpmode = mode & 0070
            if usrmode & grpmode != usrmode:
                mode |= usrmode
                self.oop.os.chmod(path, mode)

        volPath = self.getVolumePath()

        copyUserModeToGroup(volPath)

        if setrw:
            self.setrw(rw=rw)
        if rw:
            if not self.oop.os.access(volPath, os.R_OK | os.W_OK):
                raise se.VolumeAccessError(volPath)
        else:
            if not self.oop.os.access(volPath, os.R_OK):
                raise se.VolumeAccessError(volPath)
Esempio n. 2
0
 def getVolumePath(self):
     """
     Get the path of the volume file/link
     """
     if not self._volumePath:
         raise se.VolumeAccessError(self.volUUID)
     return self._volumePath
Esempio n. 3
0
    def llPrepare(self, rw=False, setrw=False):
        """
        Make volume accessible as readonly (internal) or readwrite (leaf)
        """
        volPath = self.getVolumePath()

        # Volumes leaves created in 2.2 did not have group writeable bit
        # set. We have to set it here if we want qemu-kvm to write to old
        # NFS volumes.
        self.oop.fileUtils.copyUserModeToGroup(volPath)

        if setrw:
            self.setrw(rw=rw)
        if rw:
            if not self.oop.os.access(volPath, os.R_OK | os.W_OK):
                raise se.VolumeAccessError(volPath)
        else:
            if not self.oop.os.access(volPath, os.R_OK):
                raise se.VolumeAccessError(volPath)