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-12-2020 03:26 PM
Or by IP:
{
network {
device(ip: "10.22.255.255") {
id
chassisId
deviceData {
sysDescr
}
}
}
}
Gives
{
"data": {
"network": {
"device": {
"id": 377,
"chassisId": "ABCDEF123456",
"deviceData": {
"sysDescr": "VSP-8404C (8.1.7.0)"
}
}
}
}
}
11-12-2020 03:24 PM
Christoph,
Try this:
{
network {
devices {
id
chassisId
deviceData {
sysDescr
}
}
}
}
Mig