コード例 #1
0
    def resize_online(self, sr_uuid, vdi_uuid, size):
        if not self.exists:
            raise xs_errors.XenError('VDIUnavailable', \
                  opterr='VDI %s unavailable %s' % (vdi_uuid, self.path))

        if self.vdi_type != vhdutil.VDI_TYPE_VHD:
            raise xs_errors.XenError('Unimplemented')

        if self.hidden:
            raise xs_errors.XenError('VDIUnavailable', opterr='hidden VDI')

        if size < self.size:
            util.SMlog('vdi_resize: shrinking not supported: ' + \
                    '(current size: %d, new size: %d)' % (self.size, size))
            raise xs_errors.XenError('VDISize', opterr='shrinking not allowed')

        if size == self.size:
            return VDI.VDI.get_params(self)

        # We already checked it is a VDI_TYPE_VHD
        size = util.roundup(VHD_SIZE_INC, long(size))
        overhead = vhdutil.calcOverheadFull(long(size))

        # Check we are within the limits
        mb = 1024L * 1024L
        if size < mb or (size / mb) >= MAX_VHD_SIZE:
            raise xs_errors.XenError('VDISize',
                                     opterr='VDI size ' +
                                     'must be between 1 MB and %d MB' %
                                     (MAX_VHD_SIZE))

        # Test the amount of actual disk space
        if ENFORCE_VIRT_ALLOC:
            self.sr._loadvdis()
            reserved = self.sr.virtual_allocation
            sr_size = self.sr._getsize()
            delta = long(size - self.size)
            if (sr_size - reserved) < delta:
                raise xs_errors.XenError('SRNoSpace')
        jFile = JOURNAL_FILE_PREFIX + self.uuid
        try:
            vhdutil.setSizeVirt(self.path, size, jFile)
        except:
            # Revert the operation
            vhdutil.revert(self.path, jFile)
            raise xs_errors.XenError('VDISize',
                                     opterr='resize operation failed')

        old_size = self.size
        self.size = vhdutil.getSizeVirt(self.path)
        st = util.ioretry(lambda: os.stat(self.path))
        self.utilisation = long(st.st_size)

        self._db_update()
        self.sr._update(self.sr.uuid, self.size - old_size)
        return VDI.VDI.get_params(self)
コード例 #2
0
ファイル: FileSR.py プロジェクト: falaa/sm
    def resize_online(self, sr_uuid, vdi_uuid, size):
        if not self.exists:
            raise xs_errors.XenError('VDIUnavailable', \
                  opterr='VDI %s unavailable %s' % (vdi_uuid, self.path))

        if self.vdi_type != vhdutil.VDI_TYPE_VHD:
            raise xs_errors.XenError('Unimplemented')

        if self.hidden:
            raise xs_errors.XenError('VDIUnavailable', opterr='hidden VDI')
        
        if size < self.size:
            util.SMlog('vdi_resize: shrinking not supported: ' + \
                    '(current size: %d, new size: %d)' % (self.size, size))
            raise xs_errors.XenError('VDISize', opterr='shrinking not allowed')
        
        if size == self.size:
            return VDI.VDI.get_params(self)

        # We already checked it is a VDI_TYPE_VHD
        size = util.roundup(VHD_SIZE_INC, long(size))
        overhead = vhdutil.calcOverheadFull(long(size))

        # Check we are within the limits
        mb = 1024L * 1024L
        if size < mb or (size / mb) >= MAX_VHD_SIZE:
            raise xs_errors.XenError('VDISize', opterr='VDI size ' +
                      'must be between 1 MB and %d MB' %(MAX_VHD_SIZE))

        # Test the amount of actual disk space
        if ENFORCE_VIRT_ALLOC:
            self.sr._loadvdis()
            reserved = self.sr.virtual_allocation
            sr_size = self.sr._getsize()
            delta = long(size - self.size)
            if (sr_size - reserved) < delta:
                raise xs_errors.XenError('SRNoSpace')
        jFile = JOURNAL_FILE_PREFIX + self.uuid
        try:
            vhdutil.setSizeVirt(self.path, size, jFile)
        except:
            # Revert the operation
            vhdutil.revert(self.path, jFile)
            raise xs_errors.XenError('VDISize', opterr='resize operation failed')
        
        old_size = self.size
        self.size = vhdutil.getSizeVirt(self.path)
        st = util.ioretry(lambda: os.stat(self.path))
        self.utilisation = long(st.st_size)
        
        self._db_update()
        self.sr._update(self.sr.uuid, self.size - old_size)
        return VDI.VDI.get_params(self)
コード例 #3
0
ファイル: VDILUNSR.py プロジェクト: cloudops/ReLVHDoISCSISR
    def introduce(self, sr_uuid, vdi_uuid):
        log("Calling VDI introduce")

        self.attach(sr_uuid, vdi_uuid)

        if not self.vdiExists(self.path):
            self.detach(sr_uuid, vdi_uuid)
            raise xs_errors.XenError("VDIMissing")

        self.size = vhdutil.getSizeVirt(self.path)
        self.detach(sr_uuid, vdi_uuid)
        self.introduce_vdi(vdi_uuid)

        return VDI.VDI.get_params(self)
コード例 #4
0
ファイル: FileSR.py プロジェクト: MarkSymsCtx/sm
    def resize_online(self, sr_uuid, vdi_uuid, size):
        if not self.exists:
            raise xs_errors.XenError("VDIUnavailable", opterr="VDI %s unavailable %s" % (vdi_uuid, self.path))

        if self.vdi_type != vhdutil.VDI_TYPE_VHD:
            raise xs_errors.XenError("Unimplemented")

        if self.hidden:
            raise xs_errors.XenError("VDIUnavailable", opterr="hidden VDI")

        if size < self.size:
            util.SMlog("vdi_resize: shrinking not supported: " + "(current size: %d, new size: %d)" % (self.size, size))
            raise xs_errors.XenError("VDISize", opterr="shrinking not allowed")

        if size == self.size:
            return VDI.VDI.get_params(self)

        # We already checked it is a VDI_TYPE_VHD
        size = vhdutil.validate_and_round_vhd_size(long(size))
        overhead = vhdutil.calcOverheadFull(long(size))

        # Test the amount of actual disk space
        if ENFORCE_VIRT_ALLOC:
            self.sr._loadvdis()
            reserved = self.sr.virtual_allocation
            sr_size = self.sr._getsize()
            delta = long(size - self.size)
            if (sr_size - reserved) < delta:
                raise xs_errors.XenError("SRNoSpace")
        jFile = JOURNAL_FILE_PREFIX + self.uuid
        try:
            vhdutil.setSizeVirt(self.path, size, jFile)
        except:
            # Revert the operation
            vhdutil.revert(self.path, jFile)
            raise xs_errors.XenError("VDISize", opterr="resize operation failed")

        old_size = self.size
        self.size = vhdutil.getSizeVirt(self.path)
        st = util.ioretry(lambda: os.stat(self.path))
        self.utilisation = long(st.st_size)

        self._db_update()
        self.sr._update(self.sr.uuid, self.size - old_size)
        return VDI.VDI.get_params(self)
コード例 #5
0
ファイル: FileSR.py プロジェクト: redivy/xe-storage-plugins
    def resize_online(self, sr_uuid, vdi_uuid, size):
        if not self.exists:
            raise xs_errors.XenError('VDIUnavailable', \
                  opterr='VDI %s unavailable %s' % (vdi_uuid, self.path))
        
        if self.hidden:
            raise xs_errors.XenError('VDIUnavailable', opterr='hidden VDI')
        
        if size < self.size:
            util.SMlog('vdi_resize: shrinking not supported: ' + \
                    '(current size: %d, new size: %d)' % (self.size, size))
            raise xs_errors.XenError('VDISize', opterr='shrinking not allowed')
        
        if size == self.size:
            return VDI.VDI.get_params(self)

        size = util.roundup(VHD_SIZE_INC, long(size))
        # Test the amount of actual disk space
        if ENFORCE_VIRT_ALLOC:
            self.sr._loadvdis()
            reserved = self.sr.virtual_allocation
            sr_size = self.sr._getsize()
            delta = long(size - self.size)
            if (sr_size - reserved) < delta:
                raise xs_errors.XenError('SRNoSpace')
        jFile = JOURNAL_FILE_PREFIX + self.uuid
        try:
            vhdutil.setSizeVirt(self.path, size, jFile)
        except:
            # Revert the operation
            vhdutil.revert(self.path, jFile)
            raise xs_errors.XenError('VDISize', opterr='resize operation failed')
        
        old_size = self.size
        self.size = vhdutil.getSizeVirt(self.path)
        st = util.ioretry(lambda: os.stat(self.path))
        self.utilisation = long(st.st_size)
        
        self._db_update()
        self.sr._update(self.sr.uuid, self.size - old_size)
        return VDI.VDI.get_params(self)
コード例 #6
0
ファイル: VDILUNSR.py プロジェクト: cloudops/ReLVHDoISCSISR
    def resize(self, sr_uuid, vdi_uuid, size):
        # Updates the size in the DB
        log("Calling VDI RESIZE")

        util.SMlog("LUVDI.resize for %s" % self.uuid)

        if size / 1024 / 1024 > self.MAX_VDI_SIZE_MB:
            raise xs_errors.XenError('VDISize',
                                     opterr="VDI size cannot exceed %d MB" % \
                                            self.MAX_VDI_SIZE_MB)

        if size < self.size:
            util.SMlog('vdi_resize: shrinking not supported: ' + \
                       '(current size: %d, new size: %d)' % (self.size, size))
            raise xs_errors.XenError('VDISize', opterr='shrinking not allowed')

        if size == self.size:
            return VDI.VDI.get_params(self)

        size = util.roundup(self.VHD_SIZE_INC, size)
        old_size = self.size

        if not self.attached:
            self.attach(sr_uuid, vdi_uuid)

        vhdutil.setSizeVirtFast(self.path, size)
        self.size = vhdutil.getSizeVirt(self.path)
        self.utilisation = self.size

        vdi_ref = self.sr.srcmd.params['vdi_ref']
        self.session.xenapi.VDI.set_virtual_size(vdi_ref, str(self.size))
        self.session.xenapi.VDI.set_physical_utilisation(vdi_ref, str(self.size))
        self.sr._updateStats(self.sr.uuid, self.size - old_size)

        self.detach(sr_uuid, vdi_uuid)

        return VDI.VDI.get_params(self)