Beispiel #1
0
def cmd_set_nodedesc(argv,o):
    """Set or display the node description for CAs.
       Usage: %prog [-v] [NAME]

       By default all CAs are altered, use -C or -P to select a single CA."""
    o.add_option("-v",dest="view_all",action="store_true",
                 help="Increase the verbosity level of diagnostic messages, each -v increases by 1.")
    o.add_option("-C","--Ca",dest="CA",
                 help="RDMA device to use. Specify a device name or node GUID");
    o.add_option("-P","--Port",dest="port",
                 help="RDMA end port to use. Specify a GID, port GUID, DEVICE/PORT or port number.");
    (args,values) = o.parse_args(argv);

    dev = None
    if args.CA is not None:
        dev = rdma.get_device(args.CA);
    if dev is None and args.port is not None:
        dev = rdma.get_end_port(args.port).parent;

    if args.view_all or len(values) <= 0:
        for I in rdma.get_devices():
            if dev is not None and I != dev:
                continue;
            print "%s: %s"%(I.name,IBA_describe.dstr(I.node_desc))
    else:
        name = values[0].decode();
        name = name.encode("utf-8");
        for I in rdma.get_devices():
            if dev is not None and I != dev:
                continue;
            with open(os.path.join(I._dir,"node_desc"),"w") as F:
                F.write(name);
    return True;
Beispiel #2
0
def cmd_set_nodedesc(argv,o):
    """Set or display the node description for CAs.
       Usage: %prog [-v] [NAME]

       By default all CAs are altered, use -C or -P to select a single CA."""
    o.add_option("-v",dest="view_all",action="store_true",
                 help="Increase the verbosity level of diagnostic messages, each -v increases by 1.")
    o.add_option("-C","--Ca",dest="CA",
                 help="RDMA device to use. Specify a device name or node GUID");
    o.add_option("-P","--Port",dest="port",
                 help="RDMA end port to use. Specify a GID, port GUID, DEVICE/PORT or port number.");
    (args,values) = o.parse_args(argv);

    dev = None
    if args.CA is not None:
        dev = rdma.get_device(args.CA);
    if dev is None and args.port is not None:
        dev = rdma.get_end_port(args.port).parent;

    if args.view_all or len(values) <= 0:
        for I in rdma.get_devices():
            if dev is not None and I != dev:
                continue;
            print "%s: %s"%(I.name,IBA_describe.dstr(I.node_desc))
    else:
        name = values[0].decode();
        name = name.encode("utf-8");
        for I in rdma.get_devices():
            if dev is not None and I != dev:
                continue;
            with open(os.path.join(I._dir,"node_desc"),"w") as F:
                F.write(name);
    return True;
Beispiel #3
0
 def get_end_port(self):
     """Process the options for specifying the device similar to libib, this
     version is much richer though."""
     if self.args.CA is None and self.args.port is None:
         for dev in rdma.get_devices():
             for ep in dev.end_ports:
                 if ep.state >= IBA.PORT_STATE_INIT:
                     return ep
         return rdma.get_end_port();
     if self.args.CA is None:
         try:
             return rdma.get_end_port(self.args.port);
         except rdma.RDMAError:
             pass;
         dev = rdma.get_device()
     else:
         dev = rdma.get_device(self.args.CA);
     if self.args.port is None:
         return dev.end_ports.first();
     return rdma.get_end_port("%s/%s"%(dev.name,self.args.port));
Beispiel #4
0
 def get_end_port(self):
     """Process the options for specifying the device similar to libib, this
     version is much richer though."""
     if self.args.CA is None and self.args.port is None:
         for dev in rdma.get_devices():
             for ep in dev.end_ports:
                 if ep.state >= IBA.PORT_STATE_INIT:
                     return ep
         return rdma.get_end_port()
     if self.args.CA is None:
         try:
             return rdma.get_end_port(self.args.port)
         except rdma.RDMAError:
             pass
         dev = rdma.get_device()
     else:
         dev = rdma.get_device(self.args.CA)
     if self.args.port is None:
         return dev.end_ports.first()
     return rdma.get_end_port("%s/%s" % (dev.name, self.args.port))
Beispiel #5
0
def cmd_ibstat(argv, o):
    """Display the RDMA end ports in the system.
       Usage: %prog [-lsp] [DEVICE [PORT]]"""
    o.add_option("-l",
                 "--list_of_cas",
                 action="store_true",
                 dest="list_cas",
                 help="List all IB devices names")
    o.add_option("-s",
                 "--short",
                 action="store_true",
                 dest="short",
                 help="Do not show port information")
    o.add_option("-p",
                 "--port_list",
                 action="store_true",
                 dest="ports",
                 help="Show only port GUIDs")
    (args, values) = o.parse_args(argv)

    if args.list_cas:
        if len(values) != 0: raise CmdError("Too many arguments")
        for I in rdma.get_devices():
            print I.name
        return True

    if len(values) == 0:
        end_ports = (I for J in rdma.get_devices() for I in J.end_ports)
    elif len(values) == 1:
        end_ports = (I for I in rdma.get_device(values[0]).end_ports)
    elif len(values) == 2:
        end_ports = (rdma.get_end_port("%s/%s" % (values[0], values[1])), )
    else:
        raise CmdError("Too many arguments")

    if args.ports:
        for I in end_ports:
            print I.port_guid
        return True

    def show_ca(dev):
        print "CA %r" % (dev.name)
        print "\tCA type: %s" % (dev.hca_type)
        print "\tNumber of ports: %s" % (len(dev.end_ports))
        print "\tFirmware version: %s" % (IBA_describe.dstr(dev.fw_ver))
        print "\tHardware version: %s" % (IBA_describe.dstr(dev.hw_ver))
        print "\tNode GUID: %s" % (dev.node_guid)
        print "\tSystem image GUID: %s" % (dev.sys_image_guid)

    def show_port(port, offset="\t\t"):
        print "%sState: %s" % (offset, IBA_describe.link_state(port.state))
        print "%sPhysical state: %s" % (
            offset, IBA_describe.phys_link_state(port.phys_state))
        print "%sRate: %r" % (offset, port.rate)
        print "%sBase lid: %r" % (offset, port.lid)
        print "%sLMC: %r" % (offset, port.lmc)
        print "%sSM lid: %r" % (offset, port.sm_lid)
        print "%sCapability mask: 0x%08x" % (offset, port.cap_mask)
        print "%sPort GUID: %s" % (offset, port.port_guid)

    last_ca = None
    if args.short:
        for I in end_ports:
            if last_ca != I.parent:
                show_ca(I.parent)
                last_ca = I.parent
        return True

    if isinstance(end_ports, tuple):
        I = end_ports[0]
        print "CA: %r" % (I.parent.name)
        print "Port %u:" % (I.port_id)
        show_port(I, offset="")
        return True

    for I in end_ports:
        if last_ca != I.parent:
            show_ca(I.parent)
            last_ca = I.parent
        print "\tPort %u:" % (I.port_id)
        show_port(I)
    return True
Beispiel #6
0
def cmd_ibstat(argv,o):
    """Display the RDMA end ports in the system.
       Usage: %prog [-lsp] [DEVICE [PORT]]"""
    o.add_option("-l","--list_of_cas",action="store_true",dest="list_cas",
                 help="List all IB devices names");
    o.add_option("-s","--short",action="store_true",dest="short",
                 help="Do not show port information");
    o.add_option("-p","--port_list",action="store_true",dest="ports",
                 help="Show only port GUIDs");
    (args,values) = o.parse_args(argv);

    if args.list_cas:
        if len(values) != 0: raise CmdError("Too many arguments");
        for I in rdma.get_devices():
            print I.name;
        return True;

    if len(values) == 0:
        end_ports = (I for J in rdma.get_devices() for I in J.end_ports);
    elif len(values) == 1:
        end_ports = (I for I in rdma.get_device(values[0]).end_ports);
    elif len(values) == 2:
        end_ports = (rdma.get_end_port("%s/%s"%(values[0],values[1])),);
    else:
        raise CmdError("Too many arguments");

    if args.ports:
        for I in end_ports:
            print I.port_guid;
        return True;

    def show_ca(dev):
        print "CA %r"%(dev.name);
        print "\tCA type: %s"%(dev.hca_type);
        print "\tNumber of ports: %s"%(len(dev.end_ports));
        print "\tFirmware version: %s"%(IBA_describe.dstr(dev.fw_ver));
        print "\tHardware version: %s"%(IBA_describe.dstr(dev.hw_ver));
        print "\tNode GUID: %s"%(dev.node_guid);
        print "\tSystem image GUID: %s"%(dev.sys_image_guid);
    def show_port(port,offset="\t\t"):
        print "%sState: %s"%(offset,IBA_describe.link_state(port.state));
        print "%sPhysical state: %s"%(offset,IBA_describe.phys_link_state(port.phys_state));
        print "%sRate: %r"%(offset,port.rate);
        print "%sBase lid: %r"%(offset,port.lid);
        print "%sLMC: %r"%(offset,port.lmc);
        print "%sSM lid: %r"%(offset,port.sm_lid);
        print "%sCapability mask: 0x%08x"%(offset,port.cap_mask);
        print "%sPort GUID: %s"%(offset,port.port_guid);

    last_ca = None;
    if args.short:
        for I in end_ports:
            if last_ca != I.parent:
                show_ca(I.parent);
                last_ca = I.parent;
        return True;

    if isinstance(end_ports,tuple):
        I = end_ports[0];
        print "CA: %r"%(I.parent.name);
        print "Port %u:"%(I.port_id);
        show_port(I,offset="");
        return True;

    for I in end_ports:
        if last_ca != I.parent:
            show_ca(I.parent);
            last_ca = I.parent;
        print "\tPort %u:"%(I.port_id);
        show_port(I);
    return True;