11-12-2020 03:20 PM
Hello,
I am trying to automat some processes for documentation with scripts. I am looking for a NBI query which gives back the model and Serial numbers of a Summit Stack. Can someone help me?
Kind regards
Christoph Schneider
Solved! Go to Solution.
11-13-2020 10:25 AM
Hello Christoph,
unfortunately there is no official guide for Python Scripting with XMC. But you can find many official examples under Task -> Scripts and Workflows not only the VLAN scripts.
More examples can also be found here: https://github.com/extremenetworks
For your concrete problem here a small example (quick and dirty) how to query a switch (XOS only!) and then output the serial numbers.
import re
#Send CLI commands
def sendConfigCmds(cmds):
for cmd in cmds:
cli_results = emc_cli.send( cmd )
if cli_results.isSuccess() is False:
print 'CLI-ERROR: ' + cli_results.getError()
return False
return cli_results.getOutput()
#Use allways a main function in XMC
def main():
commands = []
commands.append("show version")
result = sendConfigCmds( commands )
if result:
result_lines = result.splitlines()
for line in result_lines:
match = re.search("Slot.*?:",line)
if match:
line_parts = line.split()
if len(line_parts) > 2:
print("Serial: " + line_parts[3])
#Start program
main()
Here is what you will see with “show version”:
Slot-1 sw001 # show version
Slot-1 : 800601-00-18 8914N-46722 Rev 18 BootROM: 1.0.2.1 IMG: 22.7.1.2
Slot-2 : 800601-00-18 8912N-46755 Rev 18 BootROM: 1.0.2.1 IMG: 22.7.1.2
Here is the output:
Serial: 8914N-46722
Serial: 8912N-46755
Hope that helps.
11-27-2020 09:29 AM
Hey everyone,
To add to this: The information “serials in a Summit Stack” actually is available via NBI on a per-device query basis.
{
network {
device(ip:"1.2.3.4") {
id
deviceName
deviceData {
macAddress
ipAddress
vendor
family
subFamily
deviceDisplayType
nosId
firmware
}
entityData {
deviceTopology {
entPhysicalDesc
entPhysicalModelName
entPhysicalName
entPhysicalSerialNum
}
}
}
}
The serials for each slot will be included as entPhysicalSerialNum.
Please note that this works for exactly the use case stated. Do not rely on correct information for other use cases, there is a long list of caveats with that API call (sorry, cannot disclose, customer-paid work)… And, as usual with the NBI, doing a refresh before firing the query is a good idea.
11-13-2020 10:48 AM
Hello Stephan,
yes that helps. Next time I will check on GitHub first.
Thank you.
Kind regards
Christoph Schneider
11-13-2020 10:25 AM
Hello Christoph,
unfortunately there is no official guide for Python Scripting with XMC. But you can find many official examples under Task -> Scripts and Workflows not only the VLAN scripts.
More examples can also be found here: https://github.com/extremenetworks
For your concrete problem here a small example (quick and dirty) how to query a switch (XOS only!) and then output the serial numbers.
import re
#Send CLI commands
def sendConfigCmds(cmds):
for cmd in cmds:
cli_results = emc_cli.send( cmd )
if cli_results.isSuccess() is False:
print 'CLI-ERROR: ' + cli_results.getError()
return False
return cli_results.getOutput()
#Use allways a main function in XMC
def main():
commands = []
commands.append("show version")
result = sendConfigCmds( commands )
if result:
result_lines = result.splitlines()
for line in result_lines:
match = re.search("Slot.*?:",line)
if match:
line_parts = line.split()
if len(line_parts) > 2:
print("Serial: " + line_parts[3])
#Start program
main()
Here is what you will see with “show version”:
Slot-1 sw001 # show version
Slot-1 : 800601-00-18 8914N-46722 Rev 18 BootROM: 1.0.2.1 IMG: 22.7.1.2
Slot-2 : 800601-00-18 8912N-46755 Rev 18 BootROM: 1.0.2.1 IMG: 22.7.1.2
Here is the output:
Serial: 8914N-46722
Serial: 8912N-46755
Hope that helps.
11-13-2020 09:03 AM
Hi Stephan,
can you may help me out? I see an example Python script for executing CLI Commands in the XMC but it seems to be for VLAN configuration. Is there a documentation for how to execute CLI commands via python this? Do you may know how to do it and tell me?
Kind regards
Christoph Schneider