Using the Cisco devnet uniq python package, I run a query against APIC-EM to retrieve a list of all network devices. This information is used to build a list of instances representing platform model, specific platform and software version:
It produces the following output which I have found useful for auditing:
Platform C2960 has 5 models. WS-C2960-24TT-L 12.2(50)SE5 used by 6 devices WS-C2960-48TT-L 12.2(55)SE5 used by 2 devices WS-C2960-48TT-S 12.2(50)SE5 used by 3 devices WS-C2960-24-S 12.2(44)SE6 used by 2 devices WS-C2960-48PST-L 12.2(50)SE5 used by 1 devices Platform C3750X has 4 models. WS-C3750X-24T-S 12.2(55)SE5 used by 2 devices WS-C3750X-48T-L 12.2(58)SE2 used by 6 devices 15.2(4)E4 used by 1 devices WS-C3750X-48PF-L 12.2(55)SE5 used by 4 devices 12.2(58)SE2 used by 2 devices 15.2(4)E4 used by 3 devices WS-C3750X-48T-S 12.2(58)SE2 used by 2 devices Platform C6509 has 1 models. WS-C6509-E 15.1(2)SY6 used by 2 devices 15.1(2)SY used by 2 devices
The full source code can be found here:
Whilst reading through the Cisco Devnet site I came across a similar script to mine, which I must admit has a much more succinct way of building a data structure to represent the switch inventory. Take a look: https://github.com/CiscoDevNet/python_code_samples_network/tree/master/apic-em_get_inventory_stats
However my script offers the following benefits (of course it does!):
- Splits out the individual switches in a stack, instead of recording a platform as a stack. Allowing switch model totals to be easily obtained.
- Hostname is stored against software version, so you know which switch is running 12.2(40) in your estate.
- Switches are grouped by family, ie C6500, N7k-7000, etc. Although I do like the sorting used in the devnet script.