Skip to main content

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! :)

Hi Gio,

Please use this link for NetBrain supported APIs via QAPP.

https://www.netbraintech.com/docs/ie101/help/index.html?qapp-api-list.htm

Please be noted that we don’t have any API function that can execute commands in a device, so you may have to rely on Qapp-CLI Node to do that.

 

Regarding Multiple commands/config/snmp output – you can use Merge table function to merge two or more outputs.

 


As shown, you can use Append, Merge or Neighbour Join to join two tables and achieve your requirement.
 

above i have appended two different outputs

Please let us know if you have any other queries

Regards,

Kranthi Kumar


Hi Gio,

Please use this link for NetBrain supported APIs via QAPP.

https://www.netbraintech.com/docs/ie101/help/index.html?qapp-api-list.htm

Please be noted that we don’t have any API function that can execute commands in a device, so you may have to rely on Qapp-CLI Node to do that.

 

Regarding Multiple commands/config/snmp output – you can use Merge table function to merge two or more outputs.

 


As shown, you can use Append, Merge or Neighbour Join to join two tables and achieve your requirement.
 

above i have appended two different outputs

Please let us know if you have any other queries

Regards,

Kranthi Kumar

 

Hi Kranthi,

Thank you for the help and for letting me know that there’s not API that will allow me to do this. I guess I may have to think of another way… I know how to merge tables and output together so that’s not an issue!

The issue is that I don’t have a way to easily apply conditions to my data from a GDT within my canvas before I send it to the command nodes. :(

All the best,
Gio


Reply