Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
akurtasanov
Contributor
Jump to solution

Problem with jq parsing mgmt_cli output.

Good day.

I'm trying to earn all Non-FQDN (Wildcard) domain from SMS server through CLI.

I'm able to receive all domain by using as example 'mgmt_cli -r true show dns-domains details-level full limit 5 --format json'.

But when I try to parse output with jq and filter as example '.objects[].is-sub-domain' I receive next error message ' error: domain is not defined'. Other variations of using this filter and Boolean value have same result ' error: domain is not defined'.

Filters like '.objects[].name' or '.objects[].domain' work fine.

How to do correct parsing?

P.S. Additionally tried old Whitepaper about FQDN objects. Doesn't work too.

 

  

0 Kudos
1 Solution

Accepted Solutions
masher
Employee
Employee

I believe that you need to add the is-sub-domain in quotes as well as adding details-level full to your mgmt_cli command.

[Expert@mgmt2:0]# mgmt_cli -r true show dns-domains -f json details-level full| jq -r '.objects[]|."is-sub-domain"'
true
false
 [Expert@mgmt2:0]# mgmt_cli -r true show dns-domains -f json details-level full| jq -r '.objects[]|[.name,."is-sub-domain"]'
[
".corp.example2.com",
true
]
[
".www.example.com",
false
]

 

View solution in original post

4 Replies
masher
Employee
Employee

I believe that you need to add the is-sub-domain in quotes as well as adding details-level full to your mgmt_cli command.

[Expert@mgmt2:0]# mgmt_cli -r true show dns-domains -f json details-level full| jq -r '.objects[]|."is-sub-domain"'
true
false
 [Expert@mgmt2:0]# mgmt_cli -r true show dns-domains -f json details-level full| jq -r '.objects[]|[.name,."is-sub-domain"]'
[
".corp.example2.com",
true
]
[
".www.example.com",
false
]

 

akurtasanov
Contributor

Interesting.

Thanks!

Will try.

0 Kudos
Bob_Zimmerman
Authority
Authority

This is the biggest headache with using the management API via mgmt_cli. At least 60% of the keys have dashes in them, and jq makes you quote keys which contain dashes.

Separately, jq has the ability to extract objects which match a given predicate using the 'select' command, like so:

[Expert@DallasSC]# mgmt_cli -f json -r true show dns-domains details-level full limit 500 offset 0 | jq -c '.objects[]|select(."is-sub-domain" == false)|.'
{"uid":"00112233-4455-6677-8899-aabbccddeeff","name":".core.windows.net","type":"dns-domain","domain":{...},"is-sub-domain":true,"comments":"","color":"black","icon":"Objects/domain","tags":[],"meta-info":{"lock":"unlocked","validation-state":"ok","last-modify-time":{"posix":"[...]","iso-8601":"[...]"},"last-modifier":"[...]","creation-time":{"posix":"[...]","iso-8601":"[...]"},"creator":"[...]"},"read-only":false,"available-actions":{"edit":"true","delete":"true","clone":"true"}}
...

Once you have the objects, you can carve them up for display any way you want by just replacing that last dot.

akurtasanov
Contributor

Thanks!

0 Kudos

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events