Пример #1
0
    def _check_hardlinks(self):
        test_name = os.path.join(self.path, str(uuid4()))
        open(test_name, 'ab').close()

        link_name = '%s.new' % test_name
        try:
            # XSI-1100: Fail the link operation
            util.fistpoint.activate_custom_fn("FileSR_fail_hardlink",
                                              self._raise_hardlink_error)

            os.link(test_name, link_name)
            self.session.xenapi.SR.remove_from_sm_config(
                self.sr_ref, SharedFileSR.NO_HARDLINK_SUPPORT)
        except OSError:
            msg = "File system for SR %s does not support hardlinks, crash " \
                "consistency of snapshots cannot be assured" % self.uuid
            util.SMlog(msg, priority=util.LOG_WARNING)
            try:
                self.session.xenapi.SR.add_to_sm_config(
                    self.sr_ref, SharedFileSR.NO_HARDLINK_SUPPORT, 'True')
                self.session.xenapi.message.create(
                    "sr_does_not_support_hardlinks", 2, "SR", self.uuid, msg)
            except XenAPI.Failure:
                # Might already be set and checking has TOCTOU issues
                pass
        finally:
            util.force_unlink(link_name)
            util.force_unlink(test_name)
Пример #2
0
    def delete(self, sr_uuid, vdi_uuid, data_only = False):
        if not util.ioretry(lambda: util.pathexists(self.path)):
            return super(FileVDI, self).delete(sr_uuid, vdi_uuid, data_only)

        if self.attached:
            raise xs_errors.XenError('VDIInUse')

        try:
            util.force_unlink(self.path)
        except Exception, e:
            raise xs_errors.XenError(
                'VDIDelete',
                opterr='Failed to unlink file during deleting VDI: %s' % str(e))
Пример #3
0
    def delete(self, sr_uuid, vdi_uuid, data_only = False):
        if not util.ioretry(lambda: util.pathexists(self.path)):
            return super(FileVDI, self).delete(sr_uuid, vdi_uuid, data_only)

        if self.attached:
            raise xs_errors.XenError('VDIInUse')

        try:
            util.force_unlink(self.path)
        except Exception, e:
            raise xs_errors.XenError(
                'VDIDelete',
                opterr='Failed to unlink file during deleting VDI: %s' % str(e))
Пример #4
0
    def delete(self, sr_uuid, vdi_uuid, data_only=False):
        if not util.ioretry(lambda: util.pathexists(self.path)):
            return super(FileVDI, self).delete(sr_uuid, vdi_uuid, data_only)

        if self.attached:
            raise xs_errors.XenError('VDIInUse')

        try:
            util.force_unlink(self.path)
        except Exception as e:
            raise xs_errors.XenError(
                'VDIDelete',
                opterr='Failed to unlink file during deleting VDI: %s' %
                str(e))

        self.sr.deleted_vdi(vdi_uuid)
        # If this is a data_destroy call, don't remove from XAPI db
        if not data_only:
            self._db_forget()
        self.sr._update(self.sr.uuid, -self.size)
        self.sr.lock.cleanupAll(vdi_uuid)
        self.sr._kickGC()
        return super(FileVDI, self).delete(sr_uuid, vdi_uuid, data_only)