def _attach_LUN_bylunid(self, lunid): if not self.attached: raise xs_errors.XenError('SRUnavailable') connected = [] for val in self.adapter: if not self.pathdict.has_key(val): continue rec = self.pathdict[val] path = os.path.join(rec['path'],"LUN%s" % lunid) util.SMlog("path: %s" % path) realpath = os.path.realpath(path) util.SMlog("realpath: %s" % realpath) host = self.adapter[val] if not self.devs.has_key(realpath): l = [realpath, host, 0, 0, lunid] scsiutil.scsi_dev_ctrl(l,"add") if not util.wait_for_path(path, MAX_LUNID_TIMEOUT): util.SMlog("Unable to detect LUN attached to host on path [%s]" % path) continue else: # Verify that we are not seeing a stale LUN map try: real_SCSIid = scsiutil.getSCSIid(realpath) cur_scsibuspath = glob.glob('/dev/disk/by-scsibus/*-%s:0:0:%s' % (host,lunid)) cur_SCSIid = os.path.basename(cur_scsibuspath[0]).split("-")[0] assert(cur_SCSIid == real_SCSIid) except: scsiutil.rescan([host]) if not os.path.exists('/dev/disk/by-scsibus/%s-%s:0:0:%s' % \ (real_SCSIid,host,lunid)): util.SMlog("Unable to detect LUN attached to host after bus re-probe") continue connected.append(path) return connected
def attach(self, sr_uuid): try: connected = False for i in self.iscsiSRs: try: i.attach(sr_uuid) except SR.SROSError, inst: # Some iscsi objects can fail login but not all. Storing exception if inst.errno == 141: util.SMlog( "Connection failed for target %s, continuing.." % i.target) stored_exception = inst continue else: raise else: connected = True # Check if at least on iscsi succeeded if not connected: raise stored_exception if not i._attach_LUN_bySCSIid(self.SCSIid): raise xs_errors.XenError('InvalidDev') if self.dconf.has_key('multiSession'): # Force a manual bus refresh for a in self.iscsi.adapter: scsiutil.rescan([self.iscsi.adapter[a]]) self._pathrefresh(OCFSoISCSISR) OCFSSR.OCFSSR.attach(self, sr_uuid)
def attach(self, sr_uuid): try: connected = False for i in self.iscsiSRs: try: i.attach(sr_uuid) except SR.SROSError, inst: # Some iscsi objects can fail login but not all. Storing exception if inst.errno == 141: util.SMlog("Connection failed for target %s, continuing.." %i.target) stored_exception = inst continue else: raise else: connected = True # Check if at least on iscsi succeeded if not connected: raise stored_exception if not i._attach_LUN_bySCSIid(self.SCSIid): raise xs_errors.XenError('InvalidDev') if self.dconf.has_key('multiSession'): # Force a manual bus refresh for a in self.iscsi.adapter: scsiutil.rescan([self.iscsi.adapter[a]]) self._pathrefresh(OCFSoISCSISR) OCFSSR.OCFSSR.attach(self, sr_uuid)
def attach(self, sr_uuid): if "allocation" in self.sm_config and self.sm_config["allocation"] == "xlvhd": self._write_vginfo(sr_uuid) try: connected = False for i in self.iscsiSRs: try: i.attach(sr_uuid) except SR.SROSError, inst: # Some iscsi objects can fail login but not all. Storing exception if inst.errno == 141: util.SMlog("Connection failed for target %s, continuing.." % i.target) stored_exception = inst continue else: raise else: connected = True # Check if at least on iscsi succeeded if not connected: raise stored_exception if not i._attach_LUN_bySCSIid(self.SCSIid): raise xs_errors.XenError("InvalidDev") if self.dconf.has_key("multiSession"): # Force a manual bus refresh for a in self.iscsi.adapter: scsiutil.rescan([self.iscsi.adapter[a]]) self._start_xenvmd(sr_uuid) self._pathrefresh(LVHDoISCSISR) LVHDSR.LVHDSR.attach(self, sr_uuid) self._symlink_xenvm_conf()
def refresh(sid, npaths): # Refresh the multipath status util.SMlog("Refreshing LUN %s" % sid) if len(sid): path = DEVBYIDPATH + "/scsi-" + sid if not os.path.exists(path): scsiutil.rescan(scsiutil._genHostList("")) if not util.wait_for_path(path, 60): raise xs_errors.XenError('Device not appeared yet') _refresh_DMP(sid, npaths) else: raise xs_errors.XenError('MPath not written yet')
def refresh(sid,npaths): # Refresh the multipath status util.SMlog("Refreshing LUN %s" % sid) if len(sid): path = DEVBYIDPATH + "/scsi-" + sid if not os.path.exists(path): scsiutil.rescan(scsiutil._genHostList("")) if not util.wait_for_path(path,60): raise xs_errors.XenError('Device not appeared yet') if not (mpp_luncheck.is_RdacLun(sid)): _refresh_DMP(sid,npaths) else: _refresh_MPP(sid,npaths) else: raise xs_errors.XenError('MPath not written yet')
def attach(self, sr_uuid): try: for i in self.iscsiSRs: i.attach(sr_uuid) if self.dconf.has_key('multiSession'): # Force a manual bus refresh for a in i.adapter: scsiutil.rescan([i.adapter[a]]) if not i._attach_LUN_bySCSIid(self.SCSIid): raise xs_errors.XenError('InvalidDev') self._pathrefresh(LVHDoISCSISR) LVHDSR.LVHDSR.attach(self, sr_uuid) except Exception, inst: for i in self.iscsiSRs: i.detach(sr_uuid) raise xs_errors.XenError("SRUnavailable", opterr=inst)
def refresh(sid,npaths): # Fix udev bug (?): make sure it updates /dev/disk/by-id # Trigger the old way, if possible if os.path.exists("/sbin/udevtrigger"): util.pread2(["/sbin/udevtrigger"]) else: util.pread2(["/sbin/udevadm","trigger"]) # Refresh the multipath status util.SMlog("Refreshing LUN %s" % sid) if len(sid): path = DEVBYIDPATH + "/scsi-" + sid if not os.path.exists(path): scsiutil.rescan(scsiutil._genHostList("")) if not util.wait_for_path(path,60): raise xs_errors.XenError('Device not appeared yet') if not (mpp_luncheck.is_RdacLun(sid)): _refresh_DMP(sid,npaths) else: _refresh_MPP(sid,npaths) else: raise xs_errors.XenError('MPath not written yet')
def refresh(sid, npaths): # Fix udev bug (?): make sure it updates /dev/disk/by-id # Trigger the old way, if possible if os.path.exists("/sbin/udevtrigger"): util.pread2(["/sbin/udevtrigger"]) else: util.pread2(["/sbin/udevadm", "trigger"]) # Refresh the multipath status util.SMlog("Refreshing LUN %s" % sid) if len(sid): path = DEVBYIDPATH + "/scsi-" + sid if not os.path.exists(path): scsiutil.rescan(scsiutil._genHostList("")) if not util.wait_for_path(path, 60): raise xs_errors.XenError('Device not appeared yet') if not (mpp_luncheck.is_RdacLun(sid)): _refresh_DMP(sid, npaths) else: _refresh_MPP(sid, npaths) else: raise xs_errors.XenError('MPath not written yet')
def attach(self, sr_uuid): try: connected = False for i in self.iscsiSRs: try: i.attach(sr_uuid) except SR.SROSError as inst: # Some iscsi objects can fail login but not all. Storing exception if inst.errno == 141: util.SMlog( "Connection failed for target %s, continuing.." % i.target) stored_exception = inst continue else: raise else: connected = True if not i._attach_LUN_bySCSIid(self.SCSIid): raise xs_errors.XenError('InvalidDev') # Check if at least one iscsi succeeded if not connected: raise stored_exception if 'multiSession' in self.dconf: # Force a manual bus refresh for a in self.iscsi.adapter: scsiutil.rescan([self.iscsi.adapter[a]]) self._pathrefresh(LVHDoISCSISR) LVHDSR.LVHDSR.attach(self, sr_uuid) except Exception as inst: for i in self.iscsiSRs: i.detach(sr_uuid) raise xs_errors.XenError("SRUnavailable", opterr=inst) self._setMultipathableFlag(SCSIid=self.SCSIid)
def attach(self, sr_uuid): if ('allocation' in self.sm_config and self.sm_config['allocation'] == 'xlvhd'): self._write_vginfo(sr_uuid) try: connected = False for i in self.iscsiSRs: try: i.attach(sr_uuid) except SR.SROSError, inst: # Some iscsi objects can fail login but not all. Storing exception if inst.errno == 141: util.SMlog( "Connection failed for target %s, continuing.." % i.target) stored_exception = inst continue else: raise else: connected = True # Check if at least on iscsi succeeded if not connected: raise stored_exception if not i._attach_LUN_bySCSIid(self.SCSIid): raise xs_errors.XenError('InvalidDev') if self.dconf.has_key('multiSession'): # Force a manual bus refresh for a in self.iscsi.adapter: scsiutil.rescan([self.iscsi.adapter[a]]) self._start_xenvmd(sr_uuid) self._pathrefresh(LVHDoISCSISR) LVHDSR.LVHDSR.attach(self, sr_uuid) self._symlink_xenvm_conf()
def adapters(filterstr="any"): dict = {} devs = {} adt = {} QL = gen_QLadt() BC = gen_brocadt() CS = gen_palo() for a in os.listdir(SYSFS_PATH1): if a in QL: proc = "qlogic" elif a in BC: proc = "brocade" elif a in CS: proc = "palo" else: proc = match_hbadevs(a, filterstr) if not proc: continue adt[a] = proc id = a.replace("host", "") scsiutil.rescan([id]) emulex = False paths = [] if proc == "lpfc": emulex = True paths.append(SYSFS_PATH3) else: for p in [os.path.join(SYSFS_PATH1,a,"device","session*"),os.path.join(SYSFS_PATH1,a,"device"),\ os.path.join(SYSFS_PATH2,"%s:*"%id)]: paths += glob.glob(p) if not len(paths): continue for path in paths: for i in filter(match_targets, os.listdir(path)): tgt = i.replace('target', '') if emulex: sysfs = os.path.join(SYSFS_PATH3, i, "device") else: sysfs = SYSFS_PATH2 for lun in os.listdir(sysfs): if not match_LUNs(lun, tgt): continue if emulex: dir = os.path.join(sysfs, lun) else: dir = os.path.join(sysfs, lun, "device") for dev in filter(match_dev, os.listdir(dir)): key = dev.replace("block:", "") entry = {} entry['procname'] = proc entry['host'] = id entry['target'] = lun devs[key] = entry # for new qlogic sysfs layout (rport under device, then target) for i in filter(match_rport, os.listdir(path)): newpath = os.path.join(path, i) for j in filter(match_targets, os.listdir(newpath)): tgt = j.replace('target', '') sysfs = SYSFS_PATH2 for lun in os.listdir(sysfs): if not match_LUNs(lun, tgt): continue dir = os.path.join(sysfs, lun, "device") for dev in filter(match_dev, os.listdir(dir)): key = dev.replace("block:", "") entry = {} entry['procname'] = proc entry['host'] = id entry['target'] = lun devs[key] = entry # for new mptsas sysfs entries, check for phy* node for i in filter(match_phy, os.listdir(path)): (target, lunid) = i.replace('phy-', '').split(':') tgt = "%s:0:0:%s" % (target, lunid) sysfs = SYSFS_PATH2 for lun in os.listdir(sysfs): if not match_LUNs(lun, tgt): continue dir = os.path.join(sysfs, lun, "device") for dev in filter(match_dev, os.listdir(dir)): key = dev.replace("block:", "") entry = {} entry['procname'] = proc entry['host'] = id entry['target'] = lun devs[key] = entry if path.startswith(SYSFS_PATH2): key = os.path.basename(\ glob.glob(os.path.join(path,"device","block:*"))[0]).split(':')[1] if devs.has_key(key): continue hbtl = os.path.basename(path) (h, b, t, l) = hbtl.split(':') entry = {'procname': proc, 'host': id, 'target': l} devs[key] = entry dict['devs'] = devs dict['adt'] = adt return dict
def adapters(filterstr="any"): dict = {} devs = {} adt = {} for a in os.listdir(SYSFS_PATH1): proc = match_hbadevs(a, filterstr) if not proc: continue adt[a] = proc id = a.replace("host","") scsiutil.rescan([id]) emulex = False paths = [] if proc == "lpfc": emulex = True paths.append(SYSFS_PATH3) else: for p in [os.path.join(SYSFS_PATH1,a,"device","session*"),os.path.join(SYSFS_PATH1,a,"device"),\ os.path.join(SYSFS_PATH2,"%s:*"%id)]: paths += glob.glob(p) if not len(paths): continue for path in paths: for i in filter(match_targets,os.listdir(path)): tgt = i.replace('target','') if emulex: sysfs = os.path.join(SYSFS_PATH3,i,"device") else: sysfs = SYSFS_PATH2 for lun in os.listdir(sysfs): if not match_LUNs(lun,tgt): continue if emulex: dir = os.path.join(sysfs,lun) else: dir = os.path.join(sysfs,lun,"device") (dev, entry) = _extract_dev(dir, proc, id, lun) update_devs_dict(devs, dev, entry) # for new qlogic sysfs layout (rport under device, then target) for i in filter(match_rport,os.listdir(path)): newpath = os.path.join(path, i) for j in filter(match_targets,os.listdir(newpath)): tgt = j.replace('target','') sysfs = SYSFS_PATH2 for lun in os.listdir(sysfs): if not match_LUNs(lun,tgt): continue dir = os.path.join(sysfs,lun,"device") (dev, entry) = _extract_dev(dir, proc, id, lun) update_devs_dict(devs, dev, entry) # for new mptsas sysfs entries, check for phy* node for i in filter(match_phy,os.listdir(path)): (target,lunid) = i.replace('phy-','').split(':') tgt = "%s:0:0:%s" % (target,lunid) sysfs = SYSFS_PATH2 for lun in os.listdir(sysfs): if not match_LUNs(lun,tgt): continue dir = os.path.join(sysfs,lun,"device") (dev, entry) = _extract_dev(dir, proc, id, lun) update_devs_dict(devs, dev, entry) if path.startswith(SYSFS_PATH2): os.path.join(path,"device","block:*") dev = _extract_dev_name(os.path.join(path, 'device')) if devs.has_key(dev): continue hbtl = os.path.basename(path) (h,b,t,l) = hbtl.split(':') entry = {'procname':proc, 'host':id, 'target':l} update_devs_dict(devs, dev, entry) dict['devs'] = devs dict['adt'] = adt return dict
def adapters(filterstr="any"): dict = {} devs = {} adt = {} QL = gen_QLadt() BC = gen_brocadt() CS = gen_palo() for a in os.listdir(SYSFS_PATH1): if a in QL: proc = "qlogic" elif a in BC: proc = "brocade" elif a in CS: proc = "palo" else: proc = match_hbadevs(a, filterstr) if not proc: continue adt[a] = proc id = a.replace("host", "") scsiutil.rescan([id]) emulex = False paths = [] if proc == "lpfc": emulex = True paths.append(SYSFS_PATH3) else: for p in [ os.path.join(SYSFS_PATH1, a, "device", "session*"), os.path.join(SYSFS_PATH1, a, "device"), os.path.join(SYSFS_PATH2, "%s:*" % id), ]: paths += glob.glob(p) if not len(paths): continue for path in paths: for i in filter(match_targets, os.listdir(path)): tgt = i.replace("target", "") if emulex: sysfs = os.path.join(SYSFS_PATH3, i, "device") else: sysfs = SYSFS_PATH2 for lun in os.listdir(sysfs): if not match_LUNs(lun, tgt): continue if emulex: dir = os.path.join(sysfs, lun) else: dir = os.path.join(sysfs, lun, "device") (dev, entry) = _extract_dev(dir, proc, id, lun) devs[dev] = entry # for new qlogic sysfs layout (rport under device, then target) for i in filter(match_rport, os.listdir(path)): newpath = os.path.join(path, i) for j in filter(match_targets, os.listdir(newpath)): tgt = j.replace("target", "") sysfs = SYSFS_PATH2 for lun in os.listdir(sysfs): if not match_LUNs(lun, tgt): continue dir = os.path.join(sysfs, lun, "device") (dev, entry) = _extract_dev(dir, proc, id, lun) devs[dev] = entry # for new mptsas sysfs entries, check for phy* node for i in filter(match_phy, os.listdir(path)): (target, lunid) = i.replace("phy-", "").split(":") tgt = "%s:0:0:%s" % (target, lunid) sysfs = SYSFS_PATH2 for lun in os.listdir(sysfs): if not match_LUNs(lun, tgt): continue dir = os.path.join(sysfs, lun, "device") (dev, entry) = _extract_dev(dir, proc, id, lun) devs[dev] = entry if path.startswith(SYSFS_PATH2): os.path.join(path, "device", "block:*") dev = _extract_dev_name(os.path.join(path, "device")) if devs.has_key(dev): continue hbtl = os.path.basename(path) (h, b, t, l) = hbtl.split(":") entry = {"procname": proc, "host": id, "target": l} devs[dev] = entry dict["devs"] = devs dict["adt"] = adt return dict
def adapters(filterstr="any"): dict = {} devs = {} adt = {} QL = gen_QLadt() for a in os.listdir(SYSFS_PATH1): if not a in QL: proc = match_hbadevs(a, filterstr) if not proc: continue else: proc = "qlogic" adt[a] = proc id = a.replace("host","") scsiutil.rescan([id]) emulex = False paths = [] if proc == "lpfc": emulex = True paths.append(SYSFS_PATH3) else: for p in [os.path.join(SYSFS_PATH1,a,"device","session*"),os.path.join(SYSFS_PATH1,a,"device")]: paths += glob.glob(p) if not len(paths): continue for path in paths: for i in filter(match_targets,os.listdir(path)): tgt = i.replace('target','') if emulex: sysfs = os.path.join(SYSFS_PATH3,i,"device") else: sysfs = SYSFS_PATH2 for lun in os.listdir(sysfs): if not match_LUNs(lun,tgt): continue if emulex: dir = os.path.join(sysfs,lun) else: dir = os.path.join(sysfs,lun,"device") for dev in filter(match_dev,os.listdir(dir)): key = dev.replace("block:","") entry = {} entry['procname'] = proc entry['host'] =id entry['target'] = lun devs[key] = entry # for new qlogic sysfs layout (rport under device, then target) for i in filter(match_rport,os.listdir(path)): newpath = os.path.join(path, i) for j in filter(match_targets,os.listdir(newpath)): tgt = j.replace('target','') sysfs = SYSFS_PATH2 for lun in os.listdir(sysfs): if not match_LUNs(lun,tgt): continue dir = os.path.join(sysfs,lun,"device") for dev in filter(match_dev,os.listdir(dir)): key = dev.replace("block:","") entry = {} entry['procname'] = proc entry['host'] = id entry['target'] = lun devs[key] = entry # for new mptsas sysfs entries, check for phy* node for i in filter(match_phy,os.listdir(path)): (target,lunid) = i.replace('phy-','').split(':') tgt = "%s:0:0:%s" % (target,lunid) sysfs = SYSFS_PATH2 for lun in os.listdir(sysfs): if not match_LUNs(lun,tgt): continue dir = os.path.join(sysfs,lun,"device") for dev in filter(match_dev,os.listdir(dir)): key = dev.replace("block:","") entry = {} entry['procname'] = proc entry['host'] = id entry['target'] = lun devs[key] = entry dict['devs'] = devs dict['adt'] = adt return dict
def adapters(filterstr="any"): dict = {} devs = {} adt = {} fcoe_eth_info = {} fcoe_port_info = [] fcoe_port_info = fcoelib.parse_fcoe_port_name_info() if filterstr == "fcoe": fcoe_eth_info = fcoelib.parse_fcoe_eth_info() for a in os.listdir(SYSFS_PATH1): proc = match_hbadevs(a, filterstr) if not proc: continue #Special casing for fcoe port_name_path = os.path.join(SYSFS_PATH1,a,'device',\ 'fc_host',a,'port_name') port_name_path_exists = os.path.exists(port_name_path) util.SMlog("Port name path exists %d" % port_name_path_exists) if filterstr == "fcoe" and not port_name_path_exists: continue if port_name_path_exists: port_name = _get_port_name(port_name_path) #If we are probing for fcoe luns/ adapters and if the port name #in /sys/class/scsi_host/a/device/fc_host/a/port_name does not match #one in the output of 'fcoeadm -i', then we shouldn't display that #lun/adapter. #On the other hand, if we are probing for hba luns, and if the #port name in /sys/class/scsi_host/a/device/fc_host/a/port_name #matches one in the output of 'fcoeadm -i', then we shouldn't #display that lun/adapter, because that would have been discovered #via the FCoE protocol. if (filterstr == "fcoe" and port_name not in fcoe_port_info) or \ (filterstr != "fcoe" and port_name in fcoe_port_info): continue adt[a] = proc id = a.replace("host","") scsiutil.rescan([id]) emulex = False paths = [] if proc == "lpfc": emulex = True paths.append(SYSFS_PATH3) else: for p in [os.path.join(SYSFS_PATH1,a,"device","session*"),os.path.join(SYSFS_PATH1,a,"device"),\ os.path.join(SYSFS_PATH2,"%s:*"%id)]: paths += glob.glob(p) if not len(paths): continue for path in paths: for i in filter(match_targets,os.listdir(path)): tgt = i.replace('target','') if emulex: sysfs = os.path.join(SYSFS_PATH3,i,"device") else: sysfs = SYSFS_PATH2 for lun in os.listdir(sysfs): if not match_LUNs(lun,tgt): continue if emulex: dir = os.path.join(sysfs,lun) else: dir = os.path.join(sysfs,lun,"device") (dev, entry) = _extract_dev(dir, proc, id, lun) update_devs_dict(devs, dev, entry) # for new qlogic sysfs layout (rport under device, then target) for i in filter(match_rport,os.listdir(path)): newpath = os.path.join(path, i) for j in filter(match_targets,os.listdir(newpath)): tgt = j.replace('target','') sysfs = SYSFS_PATH2 for lun in os.listdir(sysfs): if not match_LUNs(lun,tgt): continue #Special casing for fcoe, populating eth information eth = "" if i in fcoe_eth_info.keys(): eth = fcoe_eth_info[i] dir = os.path.join(sysfs,lun,"device") (dev, entry) = _extract_dev(dir, proc, id, lun, eth) update_devs_dict(devs, dev, entry) # for new mptsas sysfs entries, check for phy* node for i in filter(match_phy,os.listdir(path)): (target,lunid) = i.replace('phy-','').split(':') tgt = "%s:0:0:%s" % (target,lunid) sysfs = SYSFS_PATH2 for lun in os.listdir(sysfs): if not match_LUNs(lun,tgt): continue dir = os.path.join(sysfs,lun,"device") (dev, entry) = _extract_dev(dir, proc, id, lun) update_devs_dict(devs, dev, entry) if path.startswith(SYSFS_PATH2): os.path.join(path,"device","block:*") dev = _extract_dev_name(os.path.join(path, 'device')) if devs.has_key(dev): continue hbtl = os.path.basename(path) (h,b,t,l) = hbtl.split(':') entry = {'procname':proc, 'host':id, 'target':l} update_devs_dict(devs, dev, entry) dict['devs'] = devs dict['adt'] = adt return dict
def refresh(self): for val in self.adapter: util.SMlog("Rescanning host adapter %s" % self.adapter[val]) scsiutil.rescan([self.adapter[val]])
def adapters(filterstr="any"): dict = {} devs = {} adt = {} fcoe_eth_info = {} fcoe_port_info = [] fcoe_port_info = fcoelib.parse_fcoe_port_name_info() if filterstr == "fcoe": fcoe_eth_info = fcoelib.parse_fcoe_eth_info() for a in os.listdir(SYSFS_PATH1): proc = match_hbadevs(a, filterstr) if not proc: continue #Special casing for fcoe port_name_path = os.path.join(SYSFS_PATH1,a,'device',\ 'fc_host',a,'port_name') port_name_path_exists = os.path.exists(port_name_path) util.SMlog("Port name path exists %d" % port_name_path_exists) if filterstr == "fcoe" and not port_name_path_exists: continue if port_name_path_exists: port_name = _get_port_name(port_name_path) #If we are probing for fcoe luns/ adapters and if the port name #in /sys/class/scsi_host/a/device/fc_host/a/port_name does not match #one in the output of 'fcoeadm -i', then we shouldn't display that #lun/adapter. #On the other hand, if we are probing for hba luns, and if the #port name in /sys/class/scsi_host/a/device/fc_host/a/port_name #matches one in the output of 'fcoeadm -i', then we shouldn't #display that lun/adapter, because that would have been discovered #via the FCoE protocol. if (filterstr == "fcoe" and port_name not in fcoe_port_info) or \ (filterstr != "fcoe" and port_name in fcoe_port_info): continue adt[a] = proc id = a.replace("host", "") scsiutil.rescan([id]) emulex = False paths = [] if proc == "lpfc": emulex = True paths.append(SYSFS_PATH3) else: for p in [os.path.join(SYSFS_PATH1,a,"device","session*"),os.path.join(SYSFS_PATH1,a,"device"),\ os.path.join(SYSFS_PATH2,"%s:*"%id)]: paths += glob.glob(p) if not len(paths): continue for path in paths: for i in filter(match_targets, os.listdir(path)): tgt = i.replace('target', '') if emulex: sysfs = os.path.join(SYSFS_PATH3, i, "device") else: sysfs = SYSFS_PATH2 for lun in os.listdir(sysfs): if not match_LUNs(lun, tgt): continue if emulex: dir = os.path.join(sysfs, lun) else: dir = os.path.join(sysfs, lun, "device") (dev, entry) = _extract_dev(dir, proc, id, lun) update_devs_dict(devs, dev, entry) # for new qlogic sysfs layout (rport under device, then target) for i in filter(match_rport, os.listdir(path)): newpath = os.path.join(path, i) for j in filter(match_targets, os.listdir(newpath)): tgt = j.replace('target', '') sysfs = SYSFS_PATH2 for lun in os.listdir(sysfs): if not match_LUNs(lun, tgt): continue #Special casing for fcoe, populating eth information eth = "" if i in fcoe_eth_info.keys(): eth = fcoe_eth_info[i] dir = os.path.join(sysfs, lun, "device") (dev, entry) = _extract_dev(dir, proc, id, lun, eth) update_devs_dict(devs, dev, entry) # for new mptsas sysfs entries, check for phy* node for i in filter(match_phy, os.listdir(path)): (target, lunid) = i.replace('phy-', '').split(':') tgt = "%s:0:0:%s" % (target, lunid) sysfs = SYSFS_PATH2 for lun in os.listdir(sysfs): if not match_LUNs(lun, tgt): continue dir = os.path.join(sysfs, lun, "device") (dev, entry) = _extract_dev(dir, proc, id, lun) update_devs_dict(devs, dev, entry) if path.startswith(SYSFS_PATH2): os.path.join(path, "device", "block:*") dev = _extract_dev_name(os.path.join(path, 'device')) if dev in devs: continue hbtl = os.path.basename(path) (h, b, t, l) = hbtl.split(':') entry = {'procname': proc, 'host': id, 'target': l} update_devs_dict(devs, dev, entry) dict['devs'] = devs dict['adt'] = adt return dict