Skip to main content
Solved

Arista WIFI Validate AP Version

  • April 2, 2025
  • 2 replies
  • 49 views

Forum|alt.badge.img

Following on from 

 I thought I would share this NQE if others are using Arista AP’s and want to maintain version numbers across their estate.
 

/**
* @intent List all Arista AP's and there software version.
* @description List all Arista AP End Points and there software version.
*/

allowedVersion = "18.0.0";

foreach endpoint in network.endpoints
where endpoint.profileName == "Arista Wireless AP's"
foreach command in endpoint.cliCommandResponses
where command.command == "show device info"

let ParsedResponse = parseConfigBlocks(OS.UNKNOWN,command.response)
foreach line in ParsedResponse
let modelNo = patternMatch(line.text,`Device Model : {string}`)
foreach line in ParsedResponse
let software = patternMatch(line.text, `Device Version : {string}`)
foreach line in ParsedResponse
let serialNo = patternMatch(line.text,`Serial Number : {string}`)
where isPresent(modelNo)
where isPresent(software)
where isPresent(serialNo)
select {
violation: software != allowedVersion,
name: endpoint.name,
location: endpoint.locationName,
ModelNo: modelNo,
SerialNo: serialNo,
Software: software
}

Hope it helps, it probably can be refined to make it more efficient, but will revisit these over time as quite new to NQE’s at the moment. 

Best answer by GaryB

@SteveBamford awesome work. blockMatches is your best friend for these tasks

 

test =
"""
Device Name : AP-01
Serial Number : 123345
MAC Address : aa:bb:cc:dd:ee:ff
IP Address : 192.168.1.10
Device Model : C-230
Device Version : 10.0.0.123
Status : Connected
Uptime : 5 days, 3 hours
Channel : 6 (2.4GHz), 44 (5GHz)
Clients : 12
""";

pattern =
```
Device Model : {model:string}
Device Version : {version:string}
Serial Number : {serial:string}
```;

foreach x in [0]
let parsed = parseConfigBlocks(OS.UNKNOWN, test)
let matches = blockMatches(parsed, pattern)
foreach m in matches
select m

 

 

2 replies

Forum|alt.badge.img+2
  • Employee
  • 56 replies
  • Answer
  • April 2, 2025

@SteveBamford awesome work. blockMatches is your best friend for these tasks

 

test =
"""
Device Name : AP-01
Serial Number : 123345
MAC Address : aa:bb:cc:dd:ee:ff
IP Address : 192.168.1.10
Device Model : C-230
Device Version : 10.0.0.123
Status : Connected
Uptime : 5 days, 3 hours
Channel : 6 (2.4GHz), 44 (5GHz)
Clients : 12
""";

pattern =
```
Device Model : {model:string}
Device Version : {version:string}
Serial Number : {serial:string}
```;

foreach x in [0]
let parsed = parseConfigBlocks(OS.UNKNOWN, test)
let matches = blockMatches(parsed, pattern)
foreach m in matches
select m

 

 


Forum|alt.badge.img
  • Author
  • Driver
  • 4 replies
  • April 2, 2025

Thanks ​@GaryB I took you advice and reworked this to use blockmatches and it is definitely cleaner and easier to work with 😀

/**
* @intent List all Arista AP's and there software version.
* @description List all Arista AP End Points and there software version.
*/

pattern =
```
Device Model : {model:string}
Serial Number : {serial:string}
Device Version : {version:string}
```;
allowedVersion = "18.0.0";

foreach endpoint in network.endpoints
where endpoint.profileName == "Arista Wireless AP's"
foreach command in endpoint.cliCommandResponses
where command.command == "show device info"

foreach x in [0]
let parsed = parseConfigBlocks(OS.UNKNOWN,command.response)
let matches = blockMatches(parsed,pattern)
foreach detail in matches

select{
violation: detail.data.version != allowedVersion,
name:endpoint.name,
model:detail.data.model,
location:endpoint.locationName,
serial:detail.data.serial,
version: detail.data.version
}