def _init_hbadict(self): if not hasattr(self, "hbas"): dict = devscan.adapters(filterstr=self.type) self.hbadict = dict['devs'] self.hbas = dict['adt'] if len(self.hbas.iterkeys()): self.attached = True self.devs = scsiutil.cacheSCSIidentifiers()
def test_exotic_adapter_with_security_device(self, context, match_hbadevs): adapter = context.add_adapter(testlib.AdapterWithNonBlockDevice()) adapter.add_disk() match_hbadevs.return_value = 'lpfc' result = devscan.adapters() self.assertEquals({'devs': {}, 'adt': {'host0': 'lpfc'}}, result)
def _init_hbadict(self): if not hasattr(self, "hbas"): dict = devscan.adapters(filterstr=self.type) self.hbadict = dict['devs'] self.hbas = dict['adt'] if len(self.hbas): self.attached = True self.devs = scsiutil.cacheSCSIidentifiers()
def attach(self, sr_uuid, vdi_uuid): # Perform a device scan for all paths, to check for any LUN resize scsi_id = self.sm_config['SCSIid'] devices = scsiutil._genReverseSCSIidmap(scsi_id) xapi_session = self.session.xenapi # At the vdi attach stage if devices are not found against the scsi_id, # the two reasons would be 1. The machine is slave on which a bus scan # was not performed, perform a bus scan to rectify the same. 2. Genuine # HBA bus error, throw an error back. if len(devices) == 0: devscan.adapters() devices = scsiutil._genReverseSCSIidmap(scsi_id) # If no devices are found after a bus rescan, flag an error if len(devices) == 0: raise xs_errors.XenError('InvalidDev', \ opterr=('No HBA Device detected with SCSI Id[%s]') % scsi_id) # Run a query on devices against the scsi id to refresh the size dev_lun_info = scsiutil.cacheSCSIidentifiers() for dev in devices: self._query(dev, dev_lun_info[dev][4], vdi_uuid) #Update xapi with the new size vdi_ref = self.sr.session.xenapi.VDI.get_by_uuid(vdi_uuid) self.sr.session.xenapi.VDI.set_virtual_size(vdi_ref, str(self.size)) # Multipath enable if self.sr.mpath == "true": self.sr.mpathmodule.refresh(scsi_id, len(devices)) self.path = self.sr.mpathmodule.path(scsi_id) # The SCSIid is already stored inside SR sm_config. # We need only to trigger mpathcount try: cmd = ['/opt/xensource/sm/mpathcount.py', scsi_id] util.pread2(cmd) except: util.SMlog("RawHBA: something wrong with mpathcount") ret = VDI.VDI.attach(self, sr_uuid, vdi_uuid) self.sr.update_stats(self.size) return ret
def attach(self, sr_uuid, vdi_uuid): # Perform a device scan for all paths, to check for any LUN resize scsi_id = self.sm_config['SCSIid'] devices = scsiutil._genReverseSCSIidmap(scsi_id) xapi_session = self.session.xenapi # At the vdi attach stage if devices are not found against the scsi_id, # the two reasons would be 1. The machine is slave on which a bus scan # was not performed, perform a bus scan to rectify the same. 2. Genuine # HBA bus error, throw an error back. if len(devices) == 0: devscan.adapters() devices = scsiutil._genReverseSCSIidmap(scsi_id) # If no devices are found after a bus rescan, flag an error if len(devices) == 0: raise xs_errors.XenError('InvalidDev', \ opterr=('No HBA Device detected with SCSI Id[%s]') % scsi_id) # Run a query on devices against the scsi id to refresh the size dev_lun_info = scsiutil.cacheSCSIidentifiers() for dev in devices: self._query(dev, dev_lun_info[dev][4], vdi_uuid) #Update xapi with the new size vdi_ref = self.sr.session.xenapi.VDI.get_by_uuid(vdi_uuid) self.sr.session.xenapi.VDI.set_virtual_size(vdi_ref, str(self.size)) # Multipath enable if self.sr.mpath == "true": self.sr.mpathmodule.refresh(scsi_id, len(devices)) self.path = self.sr.mpathmodule.path(scsi_id) # The SCSIid is already stored inside SR sm_config. # We need only to trigger mpathcount try: cmd = [os.path.join(constants.SM_DEST, 'mpathcount.py'), scsi_id] util.pread2(cmd) except: util.SMlog("RawHBA: something wrong with mpathcount") ret = VDI.VDI.attach(self, sr_uuid, vdi_uuid) self.sr.update_stats(self.size) return ret
def test_exotic_adapter_with_security_device(self, context, match_hbadevs): adapter = context.add_adapter(testlib.AdapterWithNonBlockDevice()) adapter.add_disk() match_hbadevs.return_value = 'lpfc' result = devscan.adapters() self.assertEquals( { 'devs': {}, 'adt': { 'host0': 'lpfc' } }, result)
def test_adapter_and_disk_added(self, context): adapter = context.add_adapter(testlib.SCSIAdapter()) adapter.add_disk() result = devscan.adapters() self.assertEquals( { 'devs': { 'sda': { 'procname': 'Unknown', 'host': '0', 'target': '0' } }, 'adt': { 'host0': 'Unknown' } }, result)
#!/usr/bin/env python # this script is used for refresh # the attached adapters on the host # using storage manager utilities. import sys if '/opt/xensource/sm' not in sys.path: sys.path = ['/opt/xensource/sm'] + sys.path import devscan if __name__ == "__main__": devscan.adapters() sys.exit(0)
def test_no_adapters(self, context): result = devscan.adapters() self.assertEquals({'devs': {}, 'adt': {}}, result)
#!/usr/bin/env python # this script is used for refresh # the attached adapters on the host # using storage manager utilities. import sys if "/opt/xensource/sm" not in sys.path: sys.path = ["/opt/xensource/sm"] + sys.path import devscan if __name__ == "__main__": devscan.adapters() sys.exit(0)