Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Manu_Pillai
Explorer

Check if Object Exists for IP Subnet/CIDR

Jump to solution

Objective : Check if there is an object for 10.63.127.0/24 ?

As far as I understand, we need use "show-objects" with filter for Network Subnet and mask length.

Following brings many other objects, filter not working. Perhaps I missed something ?

mgmt_cli show objects order.1.ASC "name" type "network" filter "subnet4: 10.63.127.0 AND mask-length4: 24" --format json -s id.txt

0 Kudos
1 Solution

Accepted Solutions
Art_Zalenekas
Employee
Employee

You are missing a single quote at the end for your JQ query.
If you are trying to get all objects based on that filter, then you don't have to filter out for the object type network anymore. Just execute the command without the JQ query. You can apply JQ to show only specific fields of interest, like nametype, and uid.

View solution in original post

0 Kudos
4 Replies
Art_Zalenekas
Employee
Employee

It seems you are searching for objects of type network that match the criteria. If you want to search for all objects, just omit the type parameter. Also, no need to specify type of object in the filter, you can use CIDR notation directly: 10.63.127.0/24

If you are looking for all objects but of network type:

mgmt_cli -r true show objects filter "10.63.127.0/24" -f json | jq '.objects[] | select(.type != "network")'

Use JQ to filter out all you don't need as a type.

0 Kudos
Manu_Pillai
Explorer

My objective is to get matching objects for IPv4 network 10.63.127.0 with CIDR 24 or subnet mask 255.255.255.0

I tried the following (matching Network) based on your example, NO LUCK

 

mgmt_cli -r true show objects filter "10.63.127.0/24" -f json | jq '.objects[] | select(.type == "network")

 

 

0 Kudos
Art_Zalenekas
Employee
Employee

You are missing a single quote at the end for your JQ query.
If you are trying to get all objects based on that filter, then you don't have to filter out for the object type network anymore. Just execute the command without the JQ query. You can apply JQ to show only specific fields of interest, like nametype, and uid.

View solution in original post

0 Kudos
Manu_Pillai
Explorer

Thanks, that was a copy paste, typo was the culprit.

Since I wanted only network type objects for "10.63.127.0/24", I went with following -


mgmt_cli -r true show objects filter "10.63.127.0/24" -f json -s id.txt | jq '.objects[] | select(.type == "network")'
0 Kudos