def print_header(ninf,pinf,desc,portIdx,failed,kind): if lib.args.verbosity >= 1 or failed or warnings: if desc: desc = " (%s) "%(IBA_describe.dstr(desc)); else: desc = ' '; if kind & KIND_PORT: print "Port check lid %u%sport %u:"%(pinf.LID,desc,portIdx), if kind & KIND_PERF: if portIdx == 0xFF: print "Error check lid %u%sall ports:"%(pinf.LID,desc), else: print "Error check lid %u%sport %u:"%(pinf.LID,desc,portIdx), if kind & KIND_CLEAR: if portIdx == 0xFF: print "Clear counters lid %u%sall ports:"%(pinf.LID,desc), else: print "Clear counters lid %u%sport %u:"%(pinf.LID,desc,portIdx), if kind & KIND_NODE: if ninf.nodeType == IBA.NODE_SWITCH: print "# Checking %s: nodeguid %s lid %s"%( IBA_describe.node_type(ninf.nodeType), ninf.nodeGUID,pinf.LID); else: print "# Checking %s: nodeguid %s lid %s port %u"%( IBA_describe.node_type(ninf.nodeType), ninf.nodeGUID,pinf.LID,portIdx); print "Node check lid %u:"%(pinf.LID), if failed is not None: print (red("FAILED") if failed else blue("WARNING") if warnings else green("OK")); for I in warnings: print blue("#warn: %s"%(I)); return not (failed or warnings);
def display_LFDB(switch, sbn, path, all): max_port = switch.ninf.numPorts print "Unicast lids [%u-%u] of switch %s %r" % (0, len(switch.lfdb) - 1, path, switch.desc) print " Lid Out Destination" print " Port Info" top_lid = len(sbn.lids) count = 0 for lid, oport in enumerate(switch.lfdb): desc = '' if oport <= max_port: if lid < top_lid: port = sbn.lids[lid] if port is not None and port.parent is not None: desc = "(%s portguid %s %r)" % (IBA_describe.node_type( port.parent.ninf.nodeType), port.portGUID, port.parent.desc) else: if not all: continue if lid == IBA.LID_RESERVED: desc = "(reserved LID - illegal port)" else: desc = "(illegal port)" count = count + 1 print "%6u %03u : %s" % (lid, oport, desc) if all: print "%u lids dumped" % (count) else: print "%u valid lids dumped" % (count)
def display_LFDB(switch,sbn,path,all): max_port = switch.ninf.numPorts; print "Unicast lids [%u-%u] of switch %s %r"%(0,len(switch.lfdb)-1, path,switch.desc); print " Lid Out Destination"; print " Port Info"; top_lid = len(sbn.lids); count = 0 for lid,oport in enumerate(switch.lfdb): desc = ''; if oport <= max_port: if lid < top_lid: port = sbn.lids[lid]; if port is not None and port.parent is not None: desc = "(%s portguid %s %r)"%( IBA_describe.node_type(port.parent.ninf.nodeType), port.portGUID,port.parent.desc); else: if not all: continue; if lid == IBA.LID_RESERVED: desc = "(reserved LID - illegal port)"; else: desc = "(illegal port)"; count = count+1; print "%6u %03u : %s"%(lid,oport,desc); if all: print "%u lids dumped"%(count); else: print "%u valid lids dumped"%(count);
def step(out_port, nport): nport_ep = nport.to_end_port() print "[%u] -> %s port %s[%u] lid %u/%u %s" % ( out_port.port_id, IBA_describe.node_type( nport.parent.ninf.nodeType), nport_ep.portGUID, nport.port_id, nport_ep.LID, 16 - nport_ep.pinf.LMC, IBA_describe.dstr(nport.parent.desc, quotes=True))
def step(out_port,nport): nport_ep = nport.to_end_port(); print "[%u] -> %s port %s[%u] lid %u/%u %s"%( out_port.port_id, IBA_describe.node_type(nport.parent.ninf.nodeType), nport_ep.portGUID, nport.port_id, nport_ep.LID,16 - nport_ep.pinf.LMC, IBA_describe.dstr(nport.parent.desc,quotes=True));
def print_header(ninf, pinf, desc, portIdx, failed, kind): if lib.args.verbosity >= 1 or failed or warnings: if desc: desc = " (%s) " % (IBA_describe.dstr(desc)) else: desc = ' ' if kind & KIND_PORT: print "Port check lid %u%sport %u:" % (pinf.LID, desc, portIdx), if kind & KIND_PERF: if portIdx == 0xFF: print "Error check lid %u%sall ports:" % (pinf.LID, desc), else: print "Error check lid %u%sport %u:" % (pinf.LID, desc, portIdx), if kind & KIND_CLEAR: if portIdx == 0xFF: print "Clear counters lid %u%sall ports:" % (pinf.LID, desc), else: print "Clear counters lid %u%sport %u:" % (pinf.LID, desc, portIdx), if kind & KIND_NODE: if ninf.nodeType == IBA.NODE_SWITCH: print "# Checking %s: nodeguid %s lid %s" % ( IBA_describe.node_type( ninf.nodeType), ninf.nodeGUID, pinf.LID) else: print "# Checking %s: nodeguid %s lid %s port %u" % ( IBA_describe.node_type( ninf.nodeType), ninf.nodeGUID, pinf.LID, portIdx) print "Node check lid %u:" % (pinf.LID), if failed is not None: print( red("FAILED") if failed else blue("WARNING") if warnings else green("OK")) for I in warnings: print blue("#warn: %s" % (I)) return not (failed or warnings)
def cmd_ibtracert(argv,o): """Show the route a path will take in the network Usage: %prog {TARGET}|{SOURCE TARGET} If SOURCE is not specified then the local end port is used. When tracing a multicast path the entire multicast spanning tree for the MLID is loaded, and the route that goes between start/end is printed""" LibIBOpts.setup(o,address=True,discovery=True); o.add_option("-r","--reverse",action="store_true",dest="reverse", help="Swap source and target"); o.add_option("-m","--mlid",action="store",dest="mlid", type=int, help="Report on a multicast path"); (args,values) = o.parse_args(argv); lib = LibIBOpts(o,args,values,2,(tmpl_target,tmpl_target)); if len(values) <= 0: raise CmdError("Too few arguments"); with lib.get_umad_for_target() as umad: sched = lib.get_sched(umad); sbn = lib.get_subnet(sched,["all_SwitchInfo"]); # Index 0 is the source, 1 is the target, 2 is the first source if len(values) == 1: paths = [rdma.path.IBPath(sched.end_port, SLID=sched.end_port.lid, DLID=sched.end_port.lid), values[0]]; spath,dpath = paths; # If the target has source information then copy it in to the # source path. if dpath.SLID != 0: spath.DLID = dpath.SLID; if dpath.SGID is not None: spath.DGID = dpath.SGID; else: paths = list(values); if args.reverse: paths.reverse(); # Resolve the paths to something usable paths = [resolve_path(umad,sbn,I) for I in paths]; sched.run(mqueue=(rdma.discovery.subnet_get_port(sched,sbn,I) for I in paths)); ports = [sbn.path_to_port(I) for I in paths]; # If we are starting at something other than a switch port, or our # local port then we need to have the connected switch port because we # cannot DR from a CA port. Simplest way to get this is to # trace to the target from the local port. sport = ports[0]; dport = ports[1]; if (not isinstance(sport.parent,rdma.subnet.Switch) and sport not in sbn.topology and sport.LID != paths[0].end_port.lid and not isinstance(paths[0],rdma.path.IBDRPath) and not isinstance(sched,rdma.satransactor.SATransactor)): if sbn.lid_routed: lpath = rdma.path.IBPath(sched.end_port,SLID=sched.end_port.lid, DLID=sched.end_port.lid, dqpn=0,sqpn=0,qkey=IBA.IB_DEFAULT_QP0_QKEY); else: lpath = rdma.path.IBDRPath(sched.end_port); if lib.debug >= 1: print "D: Figuring out route from local port to source" paths.append(lpath); sched.run(queue=rdma.discovery.subnet_get_port(sched,sbn,lpath)); lport = sbn.path_to_port(lpath); ports.append(lport); paths[0] = trace(umad,sched,sbn,lport,lpath,sport,paths[0], lambda x,y: None) # The target must be LID routed. if dport.LID == 0: raise CmdError("Target port %s does not have a valid LID"%( ports[2].portGUID)); if isinstance(paths[1],rdma.path.IBDRPath): paths[1] = rdma.path.IBPath(sched.end_port, DLID=ports[1].LID, dqpn=0,sqpn=0, qkey=IBA.IB_DEFAULT_QP0_QKEY); if lib.debug >= 1: for n,path,port in zip(("SRC","DST","START"),paths,ports): print "D: %s is %s (%s)"%(n,path,port.portGUID); print "From %s %s portnum %u LID %u/%u %s"%( IBA_describe.node_type(sport.parent.ninf.nodeType), sport.portGUID,sport.port_id, sport.LID,16-sport.pinf.LMC, IBA_describe.dstr(sport.parent.desc,quotes=True)); def step(out_port,nport): nport_ep = nport.to_end_port(); print "[%u] -> %s port %s[%u] lid %u/%u %s"%( out_port.port_id, IBA_describe.node_type(nport.parent.ninf.nodeType), nport_ep.portGUID, nport.port_id, nport_ep.LID,16 - nport_ep.pinf.LMC, IBA_describe.dstr(nport.parent.desc,quotes=True)); if args.mlid is not None: if args.mlid < IBA.LID_MULTICAST: raise CmdError("Multicast LID %r is invalid"%(args.mlid)); topo = fetch_mcast(sched,sbn,sport,paths[0],args.mlid); if lib.debug >= 1: print "D: Multicast spanning tree topology contains %u entries"%(len(topo)) lst = trace_mcast(topo,ports[0],ports[1]); step(ports[0],topo[ports[0]]); for I in lst: step(I,topo[I]); else: trace(umad,sched,sbn,ports[0],paths[0],ports[1],paths[1],step); print "To %s %s portnum %u LID %u/%u %s"%( IBA_describe.node_type(dport.parent.ninf.nodeType), dport.portGUID,dport.port_id, paths[1].DLID,16-dport.pinf.LMC, IBA_describe.dstr(dport.parent.desc,quotes=True)); return lib.done();
def cmd_ibtracert(argv, o): """Show the route a path will take in the network Usage: %prog {TARGET}|{SOURCE TARGET} If SOURCE is not specified then the local end port is used. When tracing a multicast path the entire multicast spanning tree for the MLID is loaded, and the route that goes between start/end is printed""" LibIBOpts.setup(o, address=True, discovery=True) o.add_option("-r", "--reverse", action="store_true", dest="reverse", help="Swap source and target") o.add_option("-m", "--mlid", action="store", dest="mlid", type=int, help="Report on a multicast path") (args, values) = o.parse_args(argv) lib = LibIBOpts(o, args, values, 2, (tmpl_target, tmpl_target)) if len(values) <= 0: raise CmdError("Too few arguments") with lib.get_umad_for_target() as umad: sched = lib.get_sched(umad) sbn = lib.get_subnet(sched, ["all_SwitchInfo"]) # Index 0 is the source, 1 is the target, 2 is the first source if len(values) == 1: paths = [ rdma.path.IBPath(sched.end_port, SLID=sched.end_port.lid, DLID=sched.end_port.lid), values[0] ] spath, dpath = paths # If the target has source information then copy it in to the # source path. if dpath.SLID != 0: spath.DLID = dpath.SLID if dpath.SGID is not None: spath.DGID = dpath.SGID else: paths = list(values) if args.reverse: paths.reverse() # Resolve the paths to something usable paths = [resolve_path(umad, sbn, I) for I in paths] sched.run(mqueue=(rdma.discovery.subnet_get_port(sched, sbn, I) for I in paths)) ports = [sbn.path_to_port(I) for I in paths] # If we are starting at something other than a switch port, or our # local port then we need to have the connected switch port because we # cannot DR from a CA port. Simplest way to get this is to # trace to the target from the local port. sport = ports[0] dport = ports[1] if (not isinstance(sport.parent, rdma.subnet.Switch) and sport not in sbn.topology and sport.LID != paths[0].end_port.lid and not isinstance(paths[0], rdma.path.IBDRPath) and not isinstance(sched, rdma.satransactor.SATransactor)): if sbn.lid_routed: lpath = rdma.path.IBPath(sched.end_port, SLID=sched.end_port.lid, DLID=sched.end_port.lid, dqpn=0, sqpn=0, qkey=IBA.IB_DEFAULT_QP0_QKEY) else: lpath = rdma.path.IBDRPath(sched.end_port) if lib.debug >= 1: print "D: Figuring out route from local port to source" paths.append(lpath) sched.run(queue=rdma.discovery.subnet_get_port(sched, sbn, lpath)) lport = sbn.path_to_port(lpath) ports.append(lport) paths[0] = trace(umad, sched, sbn, lport, lpath, sport, paths[0], lambda x, y: None) # The target must be LID routed. if dport.LID == 0: raise CmdError("Target port %s does not have a valid LID" % (ports[2].portGUID)) if isinstance(paths[1], rdma.path.IBDRPath): paths[1] = rdma.path.IBPath(sched.end_port, DLID=ports[1].LID, dqpn=0, sqpn=0, qkey=IBA.IB_DEFAULT_QP0_QKEY) if lib.debug >= 1: for n, path, port in zip(("SRC", "DST", "START"), paths, ports): print "D: %s is %s (%s)" % (n, path, port.portGUID) print "From %s %s portnum %u LID %u/%u %s" % ( IBA_describe.node_type(sport.parent.ninf.nodeType), sport.portGUID, sport.port_id, sport.LID, 16 - sport.pinf.LMC, IBA_describe.dstr(sport.parent.desc, quotes=True)) def step(out_port, nport): nport_ep = nport.to_end_port() print "[%u] -> %s port %s[%u] lid %u/%u %s" % ( out_port.port_id, IBA_describe.node_type( nport.parent.ninf.nodeType), nport_ep.portGUID, nport.port_id, nport_ep.LID, 16 - nport_ep.pinf.LMC, IBA_describe.dstr(nport.parent.desc, quotes=True)) if args.mlid is not None: if args.mlid < IBA.LID_MULTICAST: raise CmdError("Multicast LID %r is invalid" % (args.mlid)) topo = fetch_mcast(sched, sbn, sport, paths[0], args.mlid) if lib.debug >= 1: print "D: Multicast spanning tree topology contains %u entries" % ( len(topo)) lst = trace_mcast(topo, ports[0], ports[1]) step(ports[0], topo[ports[0]]) for I in lst: step(I, topo[I]) else: trace(umad, sched, sbn, ports[0], paths[0], ports[1], paths[1], step) print "To %s %s portnum %u LID %u/%u %s" % ( IBA_describe.node_type(dport.parent.ninf.nodeType), dport.portGUID, dport.port_id, paths[1].DLID, 16 - dport.pinf.LMC, IBA_describe.dstr(dport.parent.desc, quotes=True)) return lib.done()