def introduce(self, sr_uuid, vdi_uuid): self.sm_config = self.sr.srcmd.params['vdi_sm_config'] vdi_path = self.sr._getLUNbySMconfig(self.sm_config) self._query(vdi_path, self.sm_config['LUNid']) vdi_uuid = self.uuid self.sr.vdis[vdi_uuid] = self try: util._getVDI(self.sr, vdi_uuid) self.sr.vdis[vdi_uuid]._db_update() # For reasons I don't understand, VDI._db_update() doesn't set the # managed flag, so we do that ourselves here. vdi_ref = self.sr.session.xenapi.VDI.get_by_uuid(vdi_uuid) self.sr.session.xenapi.VDI.set_managed(vdi_ref, self.managed) except: self.sr.vdis[vdi_uuid]._db_introduce() return super(RAWVDI, self).get_params()
def delete(self, sr_uuid, vdi_uuid): try: vdi = util._getVDI(self.sr, vdi_uuid) if not vdi['managed']: return sm_config = vdi['sm_config'] self.sr.session.xenapi.VDI.set_managed(vdi['vdi_ref'], False) except: pass
def _set_managed(self, vdi_uuid, managed): try: vdi = util._getVDI(self.sr, vdi_uuid) self.sr.session.xenapi.VDI.set_managed(vdi['vdi_ref'], managed) except: raise xs_errors.XenError('VDIUnavailable')