def _LUNprint(self, sr_uuid): if self.iscsi.attached: # Force a rescan on the bus. self.iscsi.refresh() # time.sleep(5) # Now call attach (handles the refcounting + session activa) self.iscsi.attach(sr_uuid) util.SMlog("LUNprint: waiting for path: %s" % self.iscsi.path) if util.wait_for_path("%s/LUN*" % self.iscsi.path, ISCSISR.MAX_TIMEOUT): try: adapter = self.iscsi.adapter[self.iscsi.address] util.SMlog("adapter=%s" % adapter) # find a scsi device on which to issue a report luns command: devs = glob.glob("%s/LUN*" % self.iscsi.path) sgdevs = [] for i in devs: sgdevs.append(int(i.split("LUN")[1])) sgdevs.sort() sgdev = "%s/LUN%d" % (self.iscsi.path, sgdevs[0]) # issue a report luns: luns = util.pread2(["/usr/bin/sg_luns", "-q", sgdev]).split('\n') nluns = len( luns) - 1 # remove the line relating to the final \n # check if the LUNs are MPP-RDAC Luns scsi_id = scsiutil.getSCSIid(sgdev) mpp_lun = False if (mpp_luncheck.is_RdacLun(scsi_id)): mpp_lun = True link = glob.glob('/dev/disk/by-scsibus/%s-*' % scsi_id) mpp_adapter = link[0].split('/')[-1].split('-')[-1].split( ':')[0] # make sure we've got that many sg devices present for i in range(0, 30): luns = scsiutil._dosgscan() sgdevs = filter(lambda r: r[1] == adapter, luns) if mpp_lun: sgdevs.extend( filter(lambda r: r[1] == mpp_adapter, luns)) if len(sgdevs) >= nluns: util.SMlog("Got all %d sg devices" % nluns) break else: util.SMlog("Got %d sg devices - expecting %d" % (len(sgdevs), nluns)) time.sleep(1) util.pread2(["/sbin/udevsettle"]) except: pass # Make sure we don't break the probe... self.iscsi.print_LUNs() self.iscsi.detach(sr_uuid)
def _LUNprint(self, sr_uuid): if self.iscsi.attached: # Force a rescan on the bus. self.iscsi.refresh() # time.sleep(5) # Now call attach (handles the refcounting + session activa) self.iscsi.attach(sr_uuid) util.SMlog("LUNprint: waiting for path: %s" % self.iscsi.path) if util.wait_for_path("%s/LUN*" % self.iscsi.path, ISCSISR.MAX_TIMEOUT): try: adapter=self.iscsi.adapter[self.iscsi.address] util.SMlog("adapter=%s" % adapter) # find a scsi device on which to issue a report luns command: devs=glob.glob("%s/LUN*" % self.iscsi.path) sgdevs = [] for i in devs: sgdevs.append(int(i.split("LUN")[1])) sgdevs.sort() sgdev = "%s/LUN%d" % (self.iscsi.path,sgdevs[0]) # issue a report luns: luns=util.pread2(["/usr/bin/sg_luns","-q",sgdev]).split('\n') nluns=len(luns)-1 # remove the line relating to the final \n # check if the LUNs are MPP-RDAC Luns scsi_id = scsiutil.getSCSIid(sgdev) mpp_lun = False if (mpp_luncheck.is_RdacLun(scsi_id)): mpp_lun = True link=glob.glob('/dev/disk/by-scsibus/%s-*' % scsi_id) mpp_adapter = link[0].split('/')[-1].split('-')[-1].split(':')[0] # make sure we've got that many sg devices present for i in range(0,30): luns=scsiutil._dosgscan() sgdevs=filter(lambda r: r[1]==adapter, luns) if mpp_lun: sgdevs.extend(filter(lambda r: r[1]==mpp_adapter, luns)) if len(sgdevs)>=nluns: util.SMlog("Got all %d sg devices" % nluns) break else: util.SMlog("Got %d sg devices - expecting %d" % (len(sgdevs),nluns)) time.sleep(1) if os.path.exists("/sbin/udevsettle"): util.pread2(["/sbin/udevsettle"]) else: util.pread2(["/sbin/udevadm","settle"]) except: util.SMlog("Generic exception caught. Pass") pass # Make sure we don't break the probe... self.iscsi.print_LUNs() self.iscsi.detach(sr_uuid)
def _LUNprint(self, sr_uuid): if self.iscsi.attached: # Force a rescan on the bus. self.iscsi.refresh() # time.sleep(5) # Now call attach (handles the refcounting + session activa) self.iscsi.attach(sr_uuid) util.SMlog("LUNprint: waiting for path: %s" % self.iscsi.path) if util.wait_for_path("%s/LUN*" % self.iscsi.path, BaseISCSI.MAX_TIMEOUT): try: adapter=self.iscsi.adapter[self.iscsi.address] util.SMlog("adapter=%s" % adapter) # find a scsi device on which to issue a report luns command: devs=glob.glob("%s/LUN*" % self.iscsi.path) sgdevs = [] for i in devs: sgdevs.append(int(i.split("LUN")[1])) sgdevs.sort() sgdev = "%s/LUN%d" % (self.iscsi.path,sgdevs[0]) # issue a report luns: luns=util.pread2(["/usr/bin/sg_luns","-q",sgdev]).split('\n') nluns=len(luns)-1 # remove the line relating to the final \n # check if the LUNs are MPP-RDAC Luns scsi_id = scsiutil.getSCSIid(sgdev) # make sure we've got that many sg devices present for i in range(0,30): luns=scsiutil._dosgscan() sgdevs=filter(lambda r: r[1]==adapter, luns) if len(sgdevs)>=nluns: util.SMlog("Got all %d sg devices" % nluns) break else: util.SMlog("Got %d sg devices - expecting %d" % (len(sgdevs),nluns)) time.sleep(1) util.pread2(["/sbin/udevsettle"]) except: pass # Make sure we don't break the probe... self.iscsi.print_LUNs() self.iscsi.detach(sr_uuid)