Coverage for drivers/devscan : 51%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
#!/usr/bin/env python # # Copyright (C) Citrix Systems Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published # by the Free Software Foundation; version 2.1 only. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
else: return "Unknown"
fcoe_eth_info = fcoelib.parse_fcoe_eth_info()
continue
#Special casing for fcoe 'fc_host', a, 'port_name') continue 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
else: os.path.join(SYSFS_PATH2, "%s:*" % id)]:
continue else: sysfs = SYSFS_PATH2 continue else: dir = os.path.join(sysfs, lun, "device") # for new qlogic sysfs layout (rport under device, then target) 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 (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) continue
port_name = 0 try: f = open(port_name_path, 'r') try: line = f.readline()[:-1] if not line in ['<NULL>', '(NULL)', '']: port_name = int(line, 16) util.SMlog("Port Name in sysfs is %d" % port_name) finally: f.close() except IOError: pass return port_name
driver_name = 'fnic' driver_name = 'lpfc' driver_name = 'qla2xxx' try: f = open(namepath, 'r') line = f.readline()[:-1] f.close() if not line in ['<NULL>', '(NULL)', '']: driver_name = line except IOError: pass try: f = open(ueventpath, 'r') for line in f: if line.startswith('PHYSDEVDRIVER='): driver_name = line.replace('PHYSDEVDRIVER=', '').strip() f.close() except IOError: pass
id = str.split() val = "%s:%s:%s" % (id[1], id[3], id[5]) return val.replace(',', '')
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
and (filterstr == "any" or filterstr == "fcoe" or \ match_filterstr(filterstr, driver_name)): else: return ""
return re.search("^%s" % filterstr, driver_name)
"""Returns the name of the block device from sysfs e.g. 'sda'"""
# sub-directory of form block:sdx/ # remove 'block:' from entry and return else: # Anything 3.0 and later should have the same ABI.
# prune path to extract the device name else:
"""Returns device name and creates dictionary entry for it"""
parameters): """Adds additional information about the adapter to the the adapter node"""
# Test for root dev or existing PBD if len(obj.SCSIid) and len(systemrootID) and util.match_scsiID(obj.SCSIid, systemrootID): util.SMlog("Ignoring root device %s" % realpath) continue elif util.test_SCSIid(srobj.session, None, obj.SCSIid): util.SMlog("SCSIid in use, ignoring (%s)" % obj.SCSIid) continue elif realpath not in devs: continue
ids = devs[realpath] obj.adapter = ids[1] obj.channel = ids[2] obj.id = ids[3] obj.lun = ids[4] obj.hba = hba['procname'] if 'eth' in hba and hba['eth']: obj.eth = hba['eth'] obj.numpaths = 1 if obj.SCSIid in vdis: vdis[obj.SCSIid].numpaths += 1 vdis[obj.SCSIid].path += " [%s]" % key elif obj.hba == 'mpp': mppdict = _genMPPHBA(obj.adapter) if key in mppdict: item = mppdict[key] adapters = '' for i in item: if len(adapters): adapters += ', ' obj.numpaths += 1 adapters += i if len(adapters): obj.mpp = adapters vdis[obj.SCSIid] = obj else: vdis[obj.SCSIid] = obj
obj = vdis[key] d = dom.createElement("BlockDevice") e.appendChild(d)
for attr in ['path', 'numpaths', 'SCSIid', 'vendor', 'serial', 'size', 'adapter', 'channel', 'id', 'lun', 'hba', 'mpp', 'eth']: try: aval = getattr(obj, attr) except AttributeError: if attr in ['mpp'] or attr in ['eth']: continue raise xs_errors.XenError('InvalidArg', \ opterr='Missing required field [%s]' % attr) entry = dom.createElement(attr) d.appendChild(entry) textnode = dom.createTextNode(str(aval)) entry.appendChild(textnode)
['node_name', 'port_name', 'port_state', 'speed', 'supported_speeds']) ['hwaddress', 'initiatorname', 'ipaddress', 'port_speed', 'port_state'])
ret = False str = "host%s" % adapter try: filename = os.path.join('/sys/class/scsi_host', str, 'proc_name') f = open(filename, 'r') if f.readline().find("iscsi_tcp") != -1: ret = True except: pass return ret
regex = re.compile("-part[0-9]") if not regex.search(s, 0): return True |