0

I trying to find specific WWN address from FC switch table in order to get port ID and change admin state (I already have the WWN address). I using SNMP that return WWN table for it and I get output like this:

      In [39]: netsnmp.snmpwalk('.1.3.6.1.4.1.9.9.297.1.1.16.1.2',Version = 2,DestHost = 'lab-fc',Community = 'public')

      Out[39]:('P\x01C\x80\x18j\xc3\x88\x10\x08\x00\x01')

How I can convert this output to OID number?

VadimG
  • 1
  • I want to find correlation of the physical location of the port on the switch with WWN (i.e., module 2/port 5 or fc2/5) via SNMP? – VadimG Nov 03 '14 at 12:53

1 Answers1

1

The netsnmp library is returning you an octet string, which is essentially binary. According to the Cisco definition of the port ID, the first 8 bytes is the WWN.

import netsnmp
import struct
import binascii

portid = netsnmp.snmpwalk('.1.3.6.1.4.1.9.9.297.1.1.16.1.2',Version = 2,DestHost = 'lab-fc',Community = 'public')
print ''.join(binascii.hexlify(i) for i in struct.unpack_from('cccccccc', s))

Output

'50014380186ac388'

Does that look like the right WWN?

mdadm
  • 1,333
  • 1
  • 12
  • 9