Skip to main content

New Query Functionality @query

  • January 15, 2024
  • 2 replies
  • 164 views

cariddir
Spotter
Forum|alt.badge.img+5

I’m not sure if most people check back on the built in configs in the Forward Library, but this one is pretty slick.  Are these part of release notes or anything? I looked in the NQE documentation and didn’t find anything related, but I could be looking in the wrong spot.


@query
query(Operating_Systems: List<OS>,
Device_Name_Patterns: List<String>,
Config_Pattern: PatternBlocks<{}>) =
foreach device in network.devices
where isPresent(device.files.config)
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))
foreach match in blockMatches(device.files.config, Config_Pattern)
select {
Device: device.name,
OS: device.platform.os,
"OS Version": device.platform.osVersion,
Model: device.platform.model,
Match: match.blocks,
Tags: device.tagNames
};

Regardless, these queries need more PR for the users. Thanks to whoever developed it under: To find: goto: Forward Library→ Devices → Config Diff or Config Search

Click Parameters and add the variables you are looking for.

 

2 replies

Andreas
Employee
  • Employee
  • January 16, 2024

Hi @cariddir,

I’m glad you found this useful. I’m biased, but I think it is a really cool feature and query, too! 😁

It is a bit buried, but the general capability (but not necessarily this specific query) is mentioned in the docs and release docs:


cariddir
Spotter
Forum|alt.badge.img+5
  • Author
  • Spotter
  • January 16, 2024

Ahhhh, in the release docs. I’m the guy who tries putting things together out of the box, THEN read the documentation! ;-)

(doesn’t work well for IKEA).

Perfect, and yes, very cool feature!