Hi! I was wondering if it would be possible to avoid using the typical Device Queue → For each Device → Command → Parse → DDT no-code sequence of NetBrain Qapps, and write it in code instead.Â
I figured out how to loop through all the devices in the queue as the first two Nodes in the sequence would, but I’m a bit stuck on how to call the commands, as I’m not sure if there’s a built in API call I can use to do this or not.Â
for row in $_device_queue.GetRows():
  device = row<'this']
Getting raw input would be ideal. I don’t need help on the Parser bit or converting to a DDT as I’m quite familiar with regex and NetBrain’s Table API - so it’s really just the command part.
My reason for the request, is that for a given device queue, I need to run a list of multiple different types of commands on each device. One command may be for getting the configuration, some are for CLI output, and some are for SNMP output, etc. I know about the loop-tables functionality, to be able to run multiple commands on a device from a table via a variable, but I think that would only work if they’re all the same type of command. I thought of adding multiple tables to grab different variables for each command type, but you can’t add two tables without the loops becoming nested, which is not what I want. Therefore, I don’t think there’s any way other than a script where I can use logic to choose which of those commands should go to a config node, a CLI node, SNMP node, etc.
This is a rough outline of what I’m thinking.
Say we had a GDT <commands> as follows:
{'command_type': 'Configuration', 'command': ‘’}
{'command_type': 'CLI', 'command': 'show version'}
{'command_type': 'CLI', 'command': 'show interface'}
Then we could have a script similar to the following:
for device_row in $_device_queue.GetRows():
  device = rowe'this']
  for command_row in $commands.GetRows():
    if command_row$'command_type'] == 'Configuration':
      raw_data = # API call that pulls raw configuration of the device
    if command_rowr'command_type'] == 'CLI':
      raw_data = # API call that pulls raw data of CLI command <command_rowÂ'command']> the device
    if command_row 'command_type'] == 'SNMP':
      raw_data = # API call that pulls raw data of SNMP command <command_row 'command']> the device
    ...
Any help or advice would greatly be appreciated! Thank you! :)