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 _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 _init_adapters(self): # Generate a list of active adapters ids = scsiutil._genHostList(ISCSI_PROCNAME) util.SMlog(ids) self._adapter = {} for host in ids: try: targetIQN = iscsilib.get_targetIQN(host) if targetIQN != self.targetIQN: continue (addr, port) = iscsilib.get_targetIP_and_port(host) entry = "%s:%s" % (addr, port) self._adapter[entry] = host except: pass self._devs = scsiutil.cacheSCSIidentifiers()
def _init_adapters(self): # Generate a list of active adapters ids = scsiutil._genHostList(ISCSI_PROCNAME) util.SMlog(ids) self.adapter = {} for host in ids: try: targetIQN = iscsilib.get_targetIQN(host) if targetIQN != self.targetIQN: continue (addr, port) = iscsilib.get_targetIP_and_port(host) entry = "%s:%s" % (addr,port) self.adapter[entry] = host except: pass 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 _init_adapters(self): # Generate a list of active adapters ids = scsiutil._genHostList(ISCSI_PROCNAME) util.SMlog(ids) self.adapter = {} for host in ids: try: targetIQN = util.get_single_entry(glob.glob(\ '/sys/class/iscsi_host/host%s/device/session*/iscsi_session*/targetname' % host)[0]) if targetIQN != self.targetIQN: continue addr = util.get_single_entry(glob.glob(\ '/sys/class/iscsi_host/host%s/device/session*/connection*/iscsi_connection*/persistent_address' % host)[0]) port = util.get_single_entry(glob.glob(\ '/sys/class/iscsi_host/host%s/device/session*/connection*/iscsi_connection*/persistent_port' % host)[0]) entry = "%s:%s" % (addr,port) self.adapter[entry] = host except: pass self.devs = scsiutil.cacheSCSIidentifiers()
def _init_adapters(self): # Generate a list of active adapters ids = scsiutil._genHostList(ISCSI_PROCNAME) util.SMlog(ids) self.adapter = {} for host in ids: try: targetIQN = util.get_single_entry(glob.glob(\ '/sys/class/iscsi_host/host%s/device/session*/iscsi_session*/targetname' % host)[0]) if targetIQN != self.targetIQN: continue addr = util.get_single_entry(glob.glob(\ '/sys/class/iscsi_host/host%s/device/session*/connection*/iscsi_connection*/persistent_address' % host)[0]) port = util.get_single_entry(glob.glob(\ '/sys/class/iscsi_host/host%s/device/session*/connection*/iscsi_connection*/persistent_port' % host)[0]) entry = "%s:%s" % (addr, port) self.adapter[entry] = host except: pass self.devs = scsiutil.cacheSCSIidentifiers()
def _genMPPHBA(id): devs = scsiutil.cacheSCSIidentifiers() mppdict = {} for dev in devs: item = devs[dev] if item[1] == id: arr = scsiutil._genArrayIdentifier(dev) if not len(arr): continue try: cmd = ['/usr/sbin/mppUtil', '-a'] for line in util.doexec(cmd)[1].split('\n'): if line.find(arr) != -1: rec = line.split()[0] cmd2 = ['/usr/sbin/mppUtil', '-g',rec] li = [] for newline in util.doexec(cmd2)[1].split('\n'): if newline.find('hostId') != -1: li.append(_parseHostId(newline)) mppdict[dev.split('/')[-1]] = li except: continue return mppdict