def pathListIter(filterGuids=()): filterLen = len(filterGuids) if filterGuids else -1 devsFound = 0 knownSessions = {} svdsm = supervdsm.getProxy() pathStatuses = devicemapper.getPathsStatus() for dmId, guid in getMPDevsIter(): if devsFound == filterLen: break if filterGuids and guid not in filterGuids: continue devsFound += 1 devInfo = { "guid": guid, "dm": dmId, "capacity": str(getDeviceSize(dmId)), "serial": svdsm.getScsiSerial(dmId), "paths": [], "connections": [], "devtypes": [], "devtype": "", "vendor": "", "product": "", "fwrev": "", "logicalblocksize": "", "physicalblocksize": "", "discard_max_bytes": getDeviceDiscardMaxBytes(dmId), "discard_zeroes_data": getDeviceDiscardZeroesData(dmId), } for slave in devicemapper.getSlaves(dmId): if not devicemapper.isBlockDevice(slave): log.warning("No such physdev '%s' is ignored" % slave) continue if not devInfo["vendor"]: try: devInfo["vendor"] = getVendor(slave) except Exception: log.warn("Problem getting vendor from device `%s`", slave, exc_info=True) if not devInfo["product"]: try: devInfo["product"] = getModel(slave) except Exception: log.warn("Problem getting model name from device `%s`", slave, exc_info=True) if not devInfo["fwrev"]: try: devInfo["fwrev"] = getFwRev(slave) except Exception: log.warn("Problem getting fwrev from device `%s`", slave, exc_info=True) if (not devInfo["logicalblocksize"] or not devInfo["physicalblocksize"]): try: logBlkSize, phyBlkSize = getDeviceBlockSizes(slave) devInfo["logicalblocksize"] = str(logBlkSize) devInfo["physicalblocksize"] = str(phyBlkSize) except Exception: log.warn("Problem getting blocksize from device `%s`", slave, exc_info=True) pathInfo = {} pathInfo["physdev"] = slave pathInfo["state"] = pathStatuses.get(slave, "failed") pathInfo["capacity"] = str(getDeviceSize(slave)) try: hbtl = getHBTL(slave) except OSError as e: if e.errno == errno.ENOENT: log.warn("Device has no hbtl: %s", slave) pathInfo["lun"] = 0 else: log.error("Error: %s while trying to get hbtl of device: " "%s", str(e.message), slave) raise else: pathInfo["lun"] = hbtl.lun if iscsi.devIsiSCSI(slave): devInfo["devtypes"].append(DEV_ISCSI) pathInfo["type"] = DEV_ISCSI sessionID = iscsi.getiScsiSession(slave) if sessionID not in knownSessions: # FIXME: This entire part is for BC. It should be moved to # hsm and not preserved for new APIs. New APIs should keep # numeric types and sane field names. sess = iscsi.getSessionInfo(sessionID) sessionInfo = { "connection": sess.target.portal.hostname, "port": str(sess.target.portal.port), "iqn": sess.target.iqn, "portal": str(sess.target.tpgt), "initiatorname": sess.iface.name } # Note that credentials must be sent back in order for # the engine to tell vdsm how to reconnect later if sess.credentials: cred = sess.credentials sessionInfo['user'] = cred.username sessionInfo['password'] = cred.password knownSessions[sessionID] = sessionInfo devInfo["connections"].append(knownSessions[sessionID]) else: devInfo["devtypes"].append(DEV_FCP) pathInfo["type"] = DEV_FCP if devInfo["devtype"] == "": devInfo["devtype"] = pathInfo["type"] elif (devInfo["devtype"] != DEV_MIXED and devInfo["devtype"] != pathInfo["type"]): devInfo["devtype"] == DEV_MIXED devInfo["paths"].append(pathInfo) yield devInfo
def pathListIter(filterGuids=None): filteringOn = filterGuids is not None filterLen = len(filterGuids) if filteringOn else -1 devsFound = 0 knownSessions = {} svdsm = supervdsm.getProxy() pathStatuses = devicemapper.getPathsStatus() for dmId, guid in getMPDevsIter(): if devsFound == filterLen: break if filteringOn and guid not in filterGuids: continue devsFound += 1 devInfo = { "guid" : guid, "dm" : dmId, "capacity" : str(getDeviceSize(dmId)), "serial" : svdsm.getScsiSerial(dmId), "paths" : [], "connections" : [], "devtypes" : [], "devtype" : "", "vendor" : "", "product" :"", "fwrev" : "", "logicalblocksize" : "", "physicalblocksize" : "", } for slave in devicemapper.getSlaves(dmId): if not devicemapper.isBlockDevice(slave): log.warning("No such physdev '%s' is ignored" % slave) continue if not devInfo["vendor"]: try: devInfo["vendor"] = getVendor(slave) except Exception: log.warn("Problem getting vendor from device `%s`", slave, exc_info=True) if not devInfo["product"]: try: devInfo["product"] = getModel(slave) except Exception: log.warn("Problem getting model name from device `%s`", slave, exc_info=True) if not devInfo["fwrev"]: try: devInfo["fwrev"] = getFwRev(slave) except Exception: log.warn("Problem getting fwrev from device `%s`", slave, exc_info=True) if not devInfo["logicalblocksize"] or not devInfo["physicalblocksize"]: try: logBlkSize, phyBlkSize = getDeviceBlockSizes(slave) devInfo["logicalblocksize"] = str(logBlkSize) devInfo["physicalblocksize"] = str(phyBlkSize) except Exception: log.warn("Problem getting blocksize from device `%s`", slave, exc_info=True) pathInfo = {} pathInfo["physdev"] = slave pathInfo["state"] = pathStatuses.get(slave, "failed") try: pathInfo["hbtl"] = getHBTL(slave) except Exception: log.warn("Problem getting hbtl from device `%s`", slave, exc_info=True) pathInfo["devnum"] = DeviceNumber(*devicemapper.getDevNum(slave)) if iscsi.devIsiSCSI(slave): devInfo["devtypes"].append(DEV_ISCSI) pathInfo["type"] = DEV_ISCSI sessionID = iscsi.getiScsiSession(slave) if sessionID not in knownSessions: knownSessions[sessionID] = svdsm.getdeviSCSIinfo(slave) devInfo["connections"].append(knownSessions[sessionID]) else: devInfo["devtypes"].append(DEV_FCP) pathInfo["type"] = DEV_FCP if devInfo["devtype"] == "": devInfo["devtype"] = pathInfo["type"] elif devInfo["devtype"] != DEV_MIXED and devInfo["devtype"] != pathInfo["type"]: devInfo["devtype"] == DEV_MIXED devInfo["paths"].append(pathInfo) yield devInfo
def pathListIter(filterGuids=None): filteringOn = filterGuids is not None filterLen = len(filterGuids) if filteringOn else -1 devsFound = 0 knownSessions = {} svdsm = supervdsm.getProxy() pathStatuses = devicemapper.getPathsStatus() for dmId, guid in getMPDevsIter(): if devsFound == filterLen: break if filteringOn and guid not in filterGuids: continue devsFound += 1 devInfo = { "guid": guid, "dm": dmId, "capacity": str(getDeviceSize(dmId)), "serial": svdsm.getScsiSerial(dmId), "paths": [], "connections": [], "devtypes": [], "devtype": "", "vendor": "", "product": "", "fwrev": "", "logicalblocksize": "", "physicalblocksize": "", } for slave in devicemapper.getSlaves(dmId): if not devicemapper.isBlockDevice(slave): log.warning("No such physdev '%s' is ignored" % slave) continue if not devInfo["vendor"]: try: devInfo["vendor"] = getVendor(slave) except Exception: log.warn("Problem getting vendor from device `%s`", slave, exc_info=True) if not devInfo["product"]: try: devInfo["product"] = getModel(slave) except Exception: log.warn("Problem getting model name from device `%s`", slave, exc_info=True) if not devInfo["fwrev"]: try: devInfo["fwrev"] = getFwRev(slave) except Exception: log.warn("Problem getting fwrev from device `%s`", slave, exc_info=True) if not devInfo["logicalblocksize"] or not devInfo[ "physicalblocksize"]: try: logBlkSize, phyBlkSize = getDeviceBlockSizes(slave) devInfo["logicalblocksize"] = str(logBlkSize) devInfo["physicalblocksize"] = str(phyBlkSize) except Exception: log.warn("Problem getting blocksize from device `%s`", slave, exc_info=True) pathInfo = {} pathInfo["physdev"] = slave pathInfo["state"] = pathStatuses.get(slave, "failed") try: pathInfo["hbtl"] = getHBTL(slave) except Exception: log.warn("Problem getting hbtl from device `%s`", slave, exc_info=True) pathInfo["devnum"] = DeviceNumber(*devicemapper.getDevNum(slave)) if iscsi.devIsiSCSI(slave): devInfo["devtypes"].append(DEV_ISCSI) pathInfo["type"] = DEV_ISCSI sessionID = iscsi.getiScsiSession(slave) if sessionID not in knownSessions: knownSessions[sessionID] = svdsm.getdeviSCSIinfo(slave) devInfo["connections"].append(knownSessions[sessionID]) else: devInfo["devtypes"].append(DEV_FCP) pathInfo["type"] = DEV_FCP if devInfo["devtype"] == "": devInfo["devtype"] = pathInfo["type"] elif devInfo["devtype"] != DEV_MIXED and devInfo[ "devtype"] != pathInfo["type"]: devInfo["devtype"] == DEV_MIXED devInfo["paths"].append(pathInfo) yield devInfo
def pathListIter(filterGuids=()): filterLen = len(filterGuids) if filterGuids else -1 devsFound = 0 knownSessions = {} svdsm = supervdsm.getProxy() pathStatuses = devicemapper.getPathsStatus() for dmId, guid in getMPDevsIter(): if devsFound == filterLen: break if filterGuids and guid not in filterGuids: continue devsFound += 1 devInfo = { "guid": guid, "dm": dmId, "capacity": str(getDeviceSize(dmId)), "serial": svdsm.getScsiSerial(dmId), "paths": [], "connections": [], "devtypes": [], "devtype": "", "vendor": "", "product": "", "fwrev": "", "logicalblocksize": "", "physicalblocksize": "", } for slave in devicemapper.getSlaves(dmId): if not devicemapper.isBlockDevice(slave): log.warning("No such physdev '%s' is ignored" % slave) continue if not devInfo["vendor"]: try: devInfo["vendor"] = getVendor(slave) except Exception: log.warn("Problem getting vendor from device `%s`", slave, exc_info=True) if not devInfo["product"]: try: devInfo["product"] = getModel(slave) except Exception: log.warn("Problem getting model name from device `%s`", slave, exc_info=True) if not devInfo["fwrev"]: try: devInfo["fwrev"] = getFwRev(slave) except Exception: log.warn("Problem getting fwrev from device `%s`", slave, exc_info=True) if (not devInfo["logicalblocksize"] or not devInfo["physicalblocksize"]): try: logBlkSize, phyBlkSize = getDeviceBlockSizes(slave) devInfo["logicalblocksize"] = str(logBlkSize) devInfo["physicalblocksize"] = str(phyBlkSize) except Exception: log.warn("Problem getting blocksize from device `%s`", slave, exc_info=True) pathInfo = {} pathInfo["physdev"] = slave pathInfo["state"] = pathStatuses.get(slave, "failed") pathInfo["capacity"] = str(getDeviceSize(slave)) try: hbtl = getHBTL(slave) except OSError as e: if e.errno == errno.ENOENT: log.warn("Device has no hbtl: %s", slave) pathInfo["lun"] = 0 else: log.error("Error: %s while trying to get hbtl of device: " "%s", str(e.message), slave) raise else: pathInfo["lun"] = hbtl.lun if iscsi.devIsiSCSI(slave): devInfo["devtypes"].append(DEV_ISCSI) pathInfo["type"] = DEV_ISCSI sessionID = iscsi.getiScsiSession(slave) if sessionID not in knownSessions: # FIXME: This entire part is for BC. It should be moved to # hsm and not preserved for new APIs. New APIs should keep # numeric types and sane field names. sess = iscsi.getSessionInfo(sessionID) sessionInfo = { "connection": sess.target.portal.hostname, "port": str(sess.target.portal.port), "iqn": sess.target.iqn, "portal": str(sess.target.tpgt), "initiatorname": sess.iface.name } # Note that credentials must be sent back in order for # the engine to tell vdsm how to reconnect later if sess.credentials: cred = sess.credentials sessionInfo['user'] = cred.username sessionInfo['password'] = cred.password knownSessions[sessionID] = sessionInfo devInfo["connections"].append(knownSessions[sessionID]) else: devInfo["devtypes"].append(DEV_FCP) pathInfo["type"] = DEV_FCP if devInfo["devtype"] == "": devInfo["devtype"] = pathInfo["type"] elif (devInfo["devtype"] != DEV_MIXED and devInfo["devtype"] != pathInfo["type"]): devInfo["devtype"] == DEV_MIXED devInfo["paths"].append(pathInfo) yield devInfo
def pathListIter(filterGuids=None): filteringOn = filterGuids is not None filterLen = len(filterGuids) if filteringOn else -1 devsFound = 0 knownSessions = {} svdsm = supervdsm.getProxy() pathStatuses = devicemapper.getPathsStatus() for dmId, guid in getMPDevsIter(): if devsFound == filterLen: break if filteringOn and guid not in filterGuids: continue devsFound += 1 devInfo = { "guid" : guid, "dm" : dmId, "capacity" : str(getDeviceSize(dmId)), "serial" : svdsm.getScsiSerial(dmId), "paths" : [], "connections" : [], "devtypes" : [], "devtype" : "", "vendor" : "", "product" :"", "fwrev" : "", "logicalblocksize" : "", "physicalblocksize" : "", } for slave in devicemapper.getSlaves(dmId): if not devicemapper.isBlockDevice(slave): log.warning("No such physdev '%s' is ignored" % slave) continue if not devInfo["vendor"]: try: devInfo["vendor"] = getVendor(slave) except Exception: log.warn("Problem getting vendor from device `%s`", slave, exc_info=True) if not devInfo["product"]: try: devInfo["product"] = getModel(slave) except Exception: log.warn("Problem getting model name from device `%s`", slave, exc_info=True) if not devInfo["fwrev"]: try: devInfo["fwrev"] = getFwRev(slave) except Exception: log.warn("Problem getting fwrev from device `%s`", slave, exc_info=True) if not devInfo["logicalblocksize"] or not devInfo["physicalblocksize"]: try: logBlkSize, phyBlkSize = getDeviceBlockSizes(slave) devInfo["logicalblocksize"] = str(logBlkSize) devInfo["physicalblocksize"] = str(phyBlkSize) except Exception: log.warn("Problem getting blocksize from device `%s`", slave, exc_info=True) pathInfo = {} pathInfo["physdev"] = slave pathInfo["state"] = pathStatuses.get(slave, "failed") try: pathInfo["hbtl"] = getHBTL(slave) except Exception: log.warn("Problem getting hbtl from device `%s`", slave, exc_info=True) pathInfo["devnum"] = DeviceNumber(*devicemapper.getDevNum(slave)) if iscsi.devIsiSCSI(slave): devInfo["devtypes"].append(DEV_ISCSI) pathInfo["type"] = DEV_ISCSI sessionID = iscsi.getiScsiSession(slave) if sessionID not in knownSessions: # FIXME: This entire part is for BC. It should be moved to # hsm and not preserved for new APIs. New APIs should keep # numeric types and sane field names. sess = iscsi.getSessionInfo(sessionID) sessionInfo = { "connection": sess.target.portal.hostname, "port": str(sess.target.portal.port), "iqn": sess.target.iqn, "portal": str(sess.target.tpgt), "initiatorname": sess.iface.name } # FIXME: When updating the API remember not to send back credential information if sess.credentials: cred = sess.credentials sessionInfo['username'] = cred.username sessionInfo['password'] = cred.password knownSessions[sessionID] = sessionInfo devInfo["connections"].append(knownSessions[sessionID]) else: devInfo["devtypes"].append(DEV_FCP) pathInfo["type"] = DEV_FCP if devInfo["devtype"] == "": devInfo["devtype"] = pathInfo["type"] elif devInfo["devtype"] != DEV_MIXED and devInfo["devtype"] != pathInfo["type"]: devInfo["devtype"] == DEV_MIXED devInfo["paths"].append(pathInfo) yield devInfo