Skip to main content
Solved

How to isolate a single commandType output for parsing?

  • October 31, 2024
  • 3 replies
  • 88 views

Forum|alt.badge.img+3

I am trying to get the output from commandType NHRP_STATE so I can then pull out the tunnel peer IPs with a patternmatch.

 

When the NHRP table was a custom command the command.commandText was able to get this information, now how to do so that NHRP is part of the data model?

Best answer by AricaFN

foreach device in network.devices
foreach command in device.outputs.commands
where command.commandType == CommandType.NHRP_STATE
let response = parseConfigBlocks(device.platform.os, command.response)
foreach match in patternMatches(response, pattern)

This will allow you to define your pattern and match it against the command output. 

3 replies

AricaFN
Employee
Forum|alt.badge.img+3
  • Employee
  • Answer
  • October 31, 2024
foreach device in network.devices
foreach command in device.outputs.commands
where command.commandType == CommandType.NHRP_STATE
let response = parseConfigBlocks(device.platform.os, command.response)
foreach match in patternMatches(response, pattern)

This will allow you to define your pattern and match it against the command output. 


Forum|alt.badge.img+3
  • Author
  • Spotter
  • October 31, 2024

Thanks - I had gotten misled by the lowercase commandType vs the uppercase C CommandType to call it in the data model.

 


Tyson Henrie
Employee
Forum|alt.badge.img+2
  • Employee
  • October 31, 2024

The case is trying to be a difference between the lowercase position on the model tree and the upper case data type.  Unfortunately it is confusing.  If you hover over the commandType in “command.commandType” you will see a popup showing a yellow “CommandType” which indicates the data type.  The data type is what you use on the right hand side of the ==.