def create(self, sr_uuid, vdi_uuid, size): VDIs = util._getVDIs(self.sr) self.sr._loadvdis() smallest = 0 for vdi in VDIs: if not vdi['managed'] \ and long(vdi['virtual_size']) >= long(size) \ and self.sr.vdis.has_key(vdi['uuid']): if not smallest: smallest = long(vdi['virtual_size']) v = vdi elif long(vdi['virtual_size']) < smallest: smallest = long(vdi['virtual_size']) v = vdi if smallest > 0: self.managed = True self.sr.session.xenapi.VDI.set_managed(v['vdi_ref'], self.managed) return super(RAWVDI, self.sr.vdis[v['uuid']]).get_params() raise xs_errors.XenError('SRNoSpace')
def create(self, sr_uuid, vdi_uuid, size): VDIs = util._getVDIs(self.sr) self.sr._loadvdis() smallest = 0 for vdi in VDIs: if not vdi['managed'] \ and long(vdi['virtual_size']) >= long(size) \ and vdi['uuid'] in self.sr.vdis: if not smallest: smallest = long(vdi['virtual_size']) v = vdi elif long(vdi['virtual_size']) < smallest: smallest = long(vdi['virtual_size']) v = vdi if smallest > 0: self.managed = True self.sr.session.xenapi.VDI.set_managed(v['vdi_ref'], self.managed) return super(RAWVDI, self.sr.vdis[v['uuid']]).get_params() raise xs_errors.XenError('SRNoSpace')