Skip to main content
Solved

"Or" statement in NQE?

  • September 13, 2023
  • 2 replies
  • 59 views

Forum|alt.badge.img

Is there a way to add an "or" statement in a NQE? We are checking IOS versions against a model and Cisco says it can be this or that but the NQE we have looks like it's looking for both and throwing a false positive.

Best answer by jack.shen

the syntax for logical OR in NQE is ||

Here is an example to identify this or that model: 

 

foreach d in network.devices

where device.platform.model == “model1” || device.platform.model == “model2” || device.platform.model == “model3”



 

An alternative to check multiple device model is to 

  1. generate a list of device model that you want to include
  2. take advantage of the item in list method 

for example, the above nqe query can be rewritten as: 

 

my_ios_model=[

“model1”, 

“model2”,

“model3”

]

foreach d in network.devices

where d.platform.model in my_ios_model

...

...

 

 

2 replies

  • Employee
  • Answer
  • September 17, 2023

the syntax for logical OR in NQE is ||

Here is an example to identify this or that model: 

 

foreach d in network.devices

where device.platform.model == “model1” || device.platform.model == “model2” || device.platform.model == “model3”



 

An alternative to check multiple device model is to 

  1. generate a list of device model that you want to include
  2. take advantage of the item in list method 

for example, the above nqe query can be rewritten as: 

 

my_ios_model=[

“model1”, 

“model2”,

“model3”

]

foreach d in network.devices

where d.platform.model in my_ios_model

...

...

 

 


Forum|alt.badge.img
  • Author
  • Ramping Up
  • September 18, 2023

Thanks @jack.shen!