Skip to main content

Hi Forward Networks team,

 

I am looking at the API, specifically the call to get a device's data files.

I can get the files for a single device at a time by just putting in the hostname in the parameters, however I was wondering if there is a parameter which will allow me to pull from multiple devices at once.

For example lets say I want to pull from devices ABC, DEF, GHI

or

I want to pull from every device that starts with ABC*

Is this something that can be done?

Or would another possibility be to create a separate group of devices which includes all the devices I want to pull from and then just run the GET call on that device group.

 

Kind regards,

Sebastian

Hello @Sebastian Coros  You could do this with NQE knowing the limitations of NQE pagination. The example below takes a list of OS types and deviceName globs to select the LLDP output collected in a snapshot. 

The only other solution would be to call NQE to gather the list of device names and iterating over that by calling the device files API as you mentioned.



Example:
 

@query
query(Operating_Systems: List<OS>, Device_Name_Patterns: List<String>) =
foreach device in network.devices
where length(Operating_Systems) == 0 ||
device.platform.os in Operating_Systems
where length(Device_Name_Patterns) == 0 ||
max(foreach pattern in Device_Name_Patterns
select matches(device.name, pattern))
let outputs = device.outputs
foreach command in outputs.commands
where command.commandType == CommandType.LLDP
select { deviceName: device.name, data: command.response };


Here I am referencing the query committed in NQE Library by queryID and populating parameters to filer the output. Again just be aware you might have to deal with pagination of the NQE API call.

Execution:
 

curl -X 'POST' \
'https://fwd.app/api/nqe?networkId=<networkid>' \
-H 'accept: application/json' \
-H 'Authorization: Basic <BASE64 id:secrets> \
-H 'Content-Type: application/json' \
-d '{

"queryId": "<queryId>",
"parameters": {
"Device_Name_Patterns": s"sjc*"],
"Operating_Systems": s"ARISTA_EOS"]
}
}'


 


Hi @GaryB, thank you for the response.

 

I am trying to make a NQE and run this query but it seems that no matter what I set the parameters as the query always returns 0 results.

Any idea why?

 

 


@Sebastian Coros Sorry you are having issues, I have asked your Customer Success Architect to reach out and assist.


Hi @GaryB, any updates on this, I have yet to be contacted by anyone.

Kind regards.


@Sebastian Coros Apologies, Someone will be in contact today.  cc: @davetee 


Reply