Solved

Extreme Management NBI Query Stacking

  • 12 November 2020
  • 11 replies
  • 98 views

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

icon

Best answer by StephanH 13 November 2020, 11:25

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.

 

View original

11 replies

Userlevel 6
Badge +1

Christoph,

 

Try this:

{
  network {
    devices {
      id
      chassisId
      deviceData {
        sysDescr
      }
    }
  }
}

Mig

Userlevel 6
Badge +1

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)"
        }
      }
    }
  }
}

Hello Mig,

 

thank you for your answer but this query only gives back the Information for the primary node of the stack.

 

Kind regards

Christoph Schneider

Userlevel 6
Badge +1

Christoph,

 

I don’t have Summit stack to test it, check withthis if you find something:

{

  network{devices {

    id

    chassisId

    deviceData {

      addEnableAuthOnAccess

      addSyslogServer

      addToGroup

      addToNacGroup

      addToNetsight

      addToPolicyDomain

      addToSiteArchive

      addToSiteMap

      addTrapServer

      addZtpPlus

      apCount

      archiveId

      assetTag

      bootProm

      chassisId

      chassisMac

      checkRmaConfiguration

      companyName

      connectedIpAddress

      connector

      createDeviceTime

      currentlicenseKey

      defaultSiteId

      defaultSitePath

      details

      deviceASN

      deviceDisplayType

      deviceId

      deviceSitePrecedence

      disconnectPrecedence

      dnsServer

      dnsServer2

      dnsServer3

      dot1qMaxVlanId

      enableCollection

      enforceNeeded

      ezConfigComplete

      ezConfigCompleteError

      ezConfigCompleteOrPending

      ezConfigCompleteWithoutError

      ezConfigConfigFailed

      ezConfigConnect

      ezConfigImageUpgrade

      ezConfigPreReg

      ezConfigReadyToSendConfig

      ezConfigRma

      ezConfigRmaFailed

      ezConfigStaged

      ezConfigState

      ezconfig

      fabricAttachEnable

      fabricAttachRole

      fabricDvrDomainId

      fabricDvrRole

      fabricEnable

      fabricIpV4Shortcuts

      fabricIpV6Shortcuts

      fabricIsisIpSourceAddress

      fabricIsisIpV6SourceAddress

      fabricManualArea

      fabricMulticastEnable

      fabricName

      fabricNickName

      fabricPrimaryBVlan

      fabricSecondaryBVlan

      fabricSystemId

      fabricSystemName

      fabricTopologyType

      fabricType

      family

      firmware

      firstSeenTime

      gateway

      groupId

      hasVendorProfileChanges

      ipAddress

      jsonVendorProfile

      lacp

      lacpLogging

      lastEnforce

      lastEnforceUser

      lastLicenseUpdateTime

      lastSeenTime

      lastUpdate

      lldp

      lldpLogging

      macAddress

      mapId

      mgmtInterface

      mgmtInterfaceOutOfBand

      mgmtInterfaceVlan

      mvrp

      mvrpLogging

      nacApplianceGroup

      nacJsonParameters

      name

      newController

      nickname

      nosId

      note

      ntpServer

      ntpServer2

      ospf

      ospfLogging

      outOfService

      physicalPortCount

      poe

      poeLogging

      policyDomain

      pollGroup

      pollType

      prefix

      preregistrationCreator

      preregistrationTimestamp

      productName

      profileId

      profileName

      regionDomain

      registerSyslogReceiver

      registerTrapReceiver

      replacementSerialNumber

      rmaConfigured

      serialNumber

      siteId

      snmpRetry

      snmpTimeout

      source

      spanningTree

      spanningTreeLogging

      stacking

      stackingLogging

      statisticsCollectionLevel

      status

      subFamily

      syncChangedSnmpField

      syncDesiredFabricDvrLeafModeBoot

      syncDesiredVlansToCurrent

      sysContact

      sysDescr

      sysLocation

      sysName

      sysObjectId

      sysObjectIdName

      timesSeen

      topologyRole

      userData1

      userData2

      userData3

      userData4

      vendor

      vxlan

      vxlanLogging

      wirelessController

      ztpAllowComputeSite

      ztpCLIRecoveryModeOnly

      ztpConfigImport

      ztpDnsSearchSuffix

      ztpDomainName

      ztpLastPollIntervalInMs

      ztpPlusCachedConfigurationHashCode

      ztpPlusCachedFullConfigurationHashCode

      ztpPlusHttpEnabled

      ztpPlusHttpsEnabled

      ztpPlusLldpHoldTime

      ztpPlusRequestConfig

      ztpPlusSnmpEnabled

      ztpPlusSshEnabled

      ztpPlusTelnetEnabled

      ztpScheduledConfigureDate

      ztpScheduledConfigurePending

      ztpScheduledConfigureTime

      ztpScheduledConfigureType

      ztpScheduledDownloadDate

      ztpScheduledDownloadPending

      ztpScheduledDownloadTime

      ztpScheduledDownloadType

      ztpUseDiscoveredMode

    }

  }}

    }

Mig

Thanks again. But still only information over the primary node.

Userlevel 6
Badge +1

This is all you’ll be able to get from NBI.

Mig

Userlevel 6
Badge

Hello,

from the XMC point of view, a stack is just one device, no matter how many switches are attached to it. Therefore you won't find any information about stack members anywhere in the XMC (only if you create your own FlexViews and ask MIBs). Correspondingly also not in the NBI.

The only possibility, I see, is to ask the switches directly. You can simply create a script or a workflow that reads the information directly from the switches (stacks) via CLI. 

If you need the data externally, you can send it by mail or store it on a file on a network share that is connected to the XMC.

Surely not as nice as query this externally with the NBI. But it works.

 

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

Userlevel 6
Badge

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.

 

Hello Stephan,

 

yes that helps. Next time I will check on GitHub first.

 

Thank you.

 

Kind regards

Christoph Schneider

Userlevel 2

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.

Reply