Beispiel #1
0
def iop(port, fileflag):

    # if the port is null, just bail
    if port.port_type == 0:
        return

    # build the name of the file to store results to
    vendor_name = oom_get_keyvalue(port, 'VENDOR_NAME').replace(" ", "_")[0:8]
    outfilename = vendor_name + '_'
    vendor_sn = oom_get_keyvalue(port, 'VENDOR_SN').replace(" ", "_")
    outfilename += vendor_sn + '_EEPROMdecode_'
    dt = datetime.now()
    dateformat = "%Y%m%d%H%M%S"
    timestr = dt.strftime(dateformat)
    outfilename += timestr + '.txt'

    # see if the output should go to the screen or a file
    if fileflag == '-f':
        sys.stdout = open(outfilename, 'w+')

    # identify the module
    print
    print 'Port: %s' % port.port_name
    print '%s %s module' % \
        (oom_get_keyvalue(port, 'VENDOR_NAME'),
         mod_id(port.port_type))
    print 'Part Number: %s  Serial Number: %s' % \
        (oom_get_keyvalue(port, 'VENDOR_PN'),
         oom_get_keyvalue(port, 'VENDOR_SN'))
    print outfilename

    # print out the Serial ID keys
    print
    keys = port.fmap['SERIAL_ID']
    print 'SERIAL_ID Keys:'
    for key in sorted(keys):
        val = oom_get_keyvalue(port, key)
        decoder = port.mmap[key][1]
        if ((decoder == 'get_bytes') or (decoder == 'get_cablespec')):
            valstr = hexstr(val)
        else:
            valstr = str(val)
        print '%s: %s' % (key, valstr)

    # print out the Vendor Specific data after the Serial ID data
    print
    vend_specific = ''
    if port.port_type == 0x3 or (port.port_type == 0xB):  # SFP
        vend_specific = hexstr(oom_get_keyvalue(port, 'VENDOR_SPECIFIC_96'))
    if (port.port_type == 0xD) or (port.port_type == 0x11):  # QSFP+/QSFP28
        vend_specific = hexstr(oom_get_keyvalue(port, 'VENDOR_SPECIFIC_224'))
    print 'Vendor Specific: ' + vend_specific

    # dump the raw data from the two most popular blocks, by type
    print
    if port.port_type == 0x3 or (port.port_type == 0xB):  # SFP
        print 'I2C Address A0h, bytes 0-127, in hex'
        print_block_hex(oom_get_memory_sff(port, 0xA0, 0, 0, 128), 0)
        print
        print 'I2C Address A2h, bytes 0-127, in hex'
        print_block_hex(oom_get_memory_sff(port, 0xA2, 0, 0, 128), 0)

    if (port.port_type == 0xD) or (port.port_type == 0x11):  # QSFP+/QSFP28
        print 'I2C Address A0h, bytes 0-127, in hex'
        print_block_hex(oom_get_memory_sff(port, 0xA0, 0, 0, 128), 0)
        print
        print 'I2C Address A0h, page 0, bytes 128-255, in hex'
        print_block_hex(oom_get_memory_sff(port, 0xA0, 0, 128, 128), 0)

    # print out all the keys
    keys = port.mmap
    print 'All Keys:'
    print
    for key in sorted(keys):
        val = oom_get_keyvalue(port, key)
        decoder = port.mmap[key][1]
        if ((decoder == 'get_bytes') or (decoder == 'get_cablespec')):
            valstr = hexstr(val)
        else:
            valstr = str(val)
        print '%s: %s' % (key, valstr)
Beispiel #2
0
port = oom_get_port(5)
print '0xA0, page 0, offset 0, 128 bytes'
print_block_hex(oom_get_memory_sff(port, 0xA0, 0, 0, 128), 0)
print
print '0xA0, page 0, offset 128, 128 bytes'
print_block_hex(oom_get_memory_sff(port, 0xA0, 0, 128, 128), 128)

# get the internal list of keys and decoders for this type of module
# report their values for this port
keymap = port.mmap
print str(len(keymap.keys())) + ' keys implemented'
for keyx in sorted(keymap.keys()):
    if len(keymap[keyx]) >= 6:
        if keymap[keyx][1] == 'get_bytes':
            val = oom_get_keyvalue(port, keyx)
            print keyx + ': ' + hexstr(val)
        else:
            print keyx + ': ' + str(oom_get_keyvalue(port, keyx))

# similarly, get the function keys for this module type,
# report their values for this port
print ' '
print 'functions, with their keys and values:'
print ' '
fnkeys = port.fmap
for keyx in fnkeys:
    val = oom_get_memory(port, keyx)
    print keyx + ': '
    print str(val)
    print
Beispiel #3
0
    def showports(self, func):
        # get rid of any old windows hanging around
        kill_widgets()

        for portnum in self.inv.curselection():
            port = self.portlist[portnum]
            if port.port_type is 0:
                continue
            if func is "DOM":
                newroot = Tk()  # get a new window
                newroot.title("%s DOM Status" % port.port_name)

                # put a frame in it so it can scroll
                frame = Frame(newroot, bd=2, relief=SUNKEN)
                frame.pack()

                # put a canvas in it to hold all the graphics
                cwidth = 1000
                if port.port_type is 3:  # SFP gets a narrower canvas
                    cwidth = 550
                c = Canvas(frame,
                           bd=0,
                           width=cwidth,
                           height=300,
                           scrollregion=(0, 0, 1540, 300))
                c.pack_propagate(0)  # don't let it autoscale
                c.pack(side=TOP, expand=True, fill=BOTH)

                # give the canvas a scrollbar
                dsbar = Scrollbar(frame, orient=HORIZONTAL)
                dsbar.pack(side=BOTTOM, fill=X)
                dsbar.config(command=c.xview)
                c.config(xscrollcommand=dsbar.set)
                draw_DOM(c, port)
                continue

            # Common code path for "CODE", "ALL", and any fmap

            if func is "CODE":
                boxheight = 24
            else:
                try:  # see if 'func' is a key in the function map (eg DOM)
                    keys = port.fmap[func]
                except:  # if not, special case "ALL keys"
                    if func is "ALL":
                        keys = []
                        for key in port.mmap:
                            keys.append(key)
                    else:
                        continue
                boxheight = len(keys)
            if boxheight > 40:
                boxheight = 40

            # build the scrollable listbox in a separate window
            newroot = Tk()
            newf = Frame(newroot, bd=2, relief=SUNKEN)
            newf.pack()
            sbar = Scrollbar(newf)
            sbar.pack(side=RIGHT, fill=Y)
            portbox = Listbox(newf, width=75, height=str(boxheight))
            portbox.pack()
            portbox.config(yscrollcommand=sbar.set)
            sbar.config(command=portbox.yview)

            # and add contents
            if func is 'CODE':
                printcode(newroot, portbox, port, portnum)
            else:
                newroot.title("%s keys -- %s" % (func, portstr(port)))

                # this code lifted from oomlib.py::oom_get_memory
                # specifically to read each page once, if it
                # holds dynamic keys (and don't read at all if all static)
                mm = port.mmap
                for key in keys:
                    if mm[key][0] == 1:  # Dynamic key, invalidate cache
                        pagekey = mm[key][3]  # page of interest
                        if mm[key][4] < 128:  # unless it's low memory page
                            pagekey = -1  # whose pagekey is -1
                        port.invalidate_page(mm[key][2], pagekey)

                for key in sorted(keys):
                    val = oom_get_keyvalue_cached(port, key)
                    decoder = port.mmap[key][1]
                    if ((decoder is 'get_bytes')
                            or (decoder is 'get_cablespec')):
                        valstr = hexstr(val)
                    else:
                        valstr = str(val)
                    endstr = '%s: %s' % (key, valstr)
                    portbox.insert(END, endstr)
Beispiel #4
0
def iop(port, fileflag):

    # if the port is null, just bail
    if port.port_type == 0:
        return

    # build the name of the file to store results to
    vendor_name = oom_get_keyvalue(port, 'VENDOR_NAME').replace(" ", "_")[0:8]
    outfilename = vendor_name + '_'
    vendor_sn = oom_get_keyvalue(port, 'VENDOR_SN').replace(" ", "_")
    outfilename += vendor_sn + '_EEPROMdecode_'
    dt = datetime.now()
    dateformat = "%Y%m%d%H%M%S"
    timestr = dt.strftime(dateformat)
    outfilename += timestr + '.txt'

    # see if the output should go to the screen or a file
    if fileflag == '-f':
        sys.stdout = open(outfilename, 'w+')

    # identify the module
    print
    print 'Port: %s' % port.port_name
    print '%s %s module' % \
        (oom_get_keyvalue(port, 'VENDOR_NAME'),
         mod_id(chr(port.port_type)))
    print 'Part Number: %s  Serial Number: %s' % \
        (oom_get_keyvalue(port, 'VENDOR_PN'),
         oom_get_keyvalue(port, 'VENDOR_SN'))
    print outfilename

    # print out the Serial ID keys
    print
    keys = port.fmap['SERIAL_ID']
    print 'SERIAL_ID Keys:'
    for key in sorted(keys):
        val = oom_get_keyvalue(port, key)
        decoder = port.mmap[key][1]
        if ((decoder == 'get_bytes') or (decoder == 'get_cablespec')):
            valstr = hexstr(val)
        else:
            valstr = str(val)
        print '%s: %s' % (key, valstr)

    # print out the Vendor Specific data after the Serial ID data
    print
    vend_specific = ''
    if port.port_type == 0x3:   # SFP
        vend_specific = hexstr(oom_get_keyvalue(port, 'VENDOR_SPECIFIC_96'))
    if (port.port_type == 0xD) or (port.port_type == 0x11):  # QSFP+/QSFP28
        vend_specific = hexstr(oom_get_keyvalue(port, 'VENDOR_SPECIFIC_224'))
    print 'Vendor Specific: ' + vend_specific

    # dump the raw data from the two most popular blocks, by type
    print
    if port.port_type == 0x3:  # SFP
        print 'I2C Address A0h, bytes 0-127, in hex'
        print_block_hex(oom_get_memory_sff(port, 0xA0, 0, 0, 128), 0)
        print
        print 'I2C Address A2h, bytes 0-127, in hex'
        print_block_hex(oom_get_memory_sff(port, 0xA2, 0, 0, 128), 0)

    if (port.port_type == 0xD) or (port.port_type == 0x11):  # QSFP+/QSFP28
        print 'I2C Address A0h, bytes 0-127, in hex'
        print_block_hex(oom_get_memory_sff(port, 0xA0, 0, 0, 128), 0)
        print
        print 'I2C Address A0h, page 0, bytes 128-255, in hex'
        print_block_hex(oom_get_memory_sff(port, 0xA0, 0, 128, 128), 0)
Beispiel #5
0
    while 1:
        lines = 0
        while lines < numlines:
            pnum = (pcount) % numports
            pcount += 1
            port = portlist[pnum]
            outstr = str.format("{:6} {:10}",
                                port.port_name, type_to_str(port.port_type))
            keylist = port.fmap
            if keylist == {}:
                continue
            keylist = port.fmap["SERIAL_ID"]
            keyoff = 0
            while len(outstr) < linelen:
                temp = (pcycle + keyoff) % len(keylist)
                keyoff += 1
                key = keylist[temp % len(keylist)]
                if len(port.mmap[key]) >= 6:
                    if port.mmap[key][1] == 'get_bytes':
                        val = oom_get_keyvalue(port, key)
                        outstr += key + ': ' + hexstr(val) + '; '
                    else:
                        outstr += key + ': ' \
                                + str(oom_get_keyvalue(port, key)) + "; "
            print outstr[0:linelen]
            lines += 1
        pcycle += 1  # it will take a LONG time to roll over
        sleep(2)
except KeyboardInterrupt:
    print "Thanks for running the OOM OCP Demo!"
Beispiel #6
0
# ////////////////////////////////////////////////////////////////////

from oom import *  # the published OOM Northbound API
from oom.decode import hexstr  # helper function from the decode pack

# open port 0
port = oom_get_port(0)

# get the internal list of keys and decoders for this type of module
# report their values for this port
keymap = port.mmap
for keyx in sorted(keymap.keys()):
    if len(keymap[keyx]) == 6:
        if keymap[keyx][1] == 'get_bytes':
            val = oom_get_keyvalue(port, keyx)
            print keyx + ': ' + hexstr(val)
        else:
            print keyx + ': ' + str(oom_get_keyvalue(port, keyx))

# similarly, get the function keys for this module type,
# report their values for this port
print ' '
print 'functions, with their keys and values:'
print ' '
fnkeys = port.fmap
for keyx in fnkeys:
    val = oom_get_memory(port, keyx)
    print keyx + ': '
    print str(val)
    print
Beispiel #7
0
    while 1:
        lines = 0
        while lines < numlines:
            pnum = (pcount) % numports
            pcount += 1
            port = portlist[pnum]
            outstr = str.format("{:6} {:10}", port.port_name,
                                type_to_str(port.port_type))
            keylist = port.fmap
            if keylist == {}:
                continue
            keylist = port.fmap["SERIAL_ID"]
            keyoff = 0
            while len(outstr) < linelen:
                temp = (pcycle + keyoff) % len(keylist)
                keyoff += 1
                key = keylist[temp % len(keylist)]
                if len(port.mmap[key]) >= 6:
                    if port.mmap[key][1] == 'get_bytes':
                        val = oom_get_keyvalue(port, key)
                        outstr += key + ': ' + hexstr(val) + '; '
                    else:
                        outstr += key + ': ' \
                                + str(oom_get_keyvalue(port, key)) + "; "
            print outstr[0:linelen]
            lines += 1
        pcycle += 1  # it will take a LONG time to roll over
        sleep(2)
except KeyboardInterrupt:
    print "Thanks for running the OOM OCP Demo!"