Hello Dick,

I'm trying to get like the below format  and also its listing I wanted to 
join (' , ')  "dn": "sys/rack-unit-1/psu-1"  , "id": "1" 

 "msg": The PSU output is, {
        "dn": "sys/rack-unit-1/psu-1",
        "id": "1",
        "operability": "operable",
        "presence": "equipped"

      "dn": "sys/rack-unit-1/psu-2",
        "id": "2",
        "operability": "operable",
        "presence": "equipped"
    }
}

Thanks,
Ramesh 

On Wednesday, 30 December 2020 at 17:56:25 UTC-5 dick....@geant.org wrote:

> On Wed, 30 Dec 2020 at 15:46, Ramesh AR <rames...@gmail.com> wrote:
>
>> Folks, trying to get json query for the below data's.
>>
>> Tried the below queries but didn't get output as expected. can someone 
>> help me . 
>>
>
> Apologies for the obvious question, but what output do you expect?
>
>
>
>
>
> Try 1:
>> ++++++++++++++++++++++++++
>>    register: result
>>   - name: Display PSU status
>>     debug: msg="{{ result.json | json_query(jmesquery) }}"
>>     vars:
>>       jmesquery: "[*].{dn: dn, id: id}"
>> ++++++++++++++++++++++++++++
>> Try:2
>>     # msg: "{{ 
>> result|json_query('configResolveClass.children[0].outConfigs.children[0].equipmentPsu.attributes.equipmentPsu.attributes[0].{dn:
>>  
>> dn, id: id, operability: operability, presence:presence}') }}"
>> +++++++++++++++++++++++++++++
>>
>> Ansible Facts:
>> +++++++++++++++++++++++++++
>>    "aaaLogin": {
>>         "attributes": {
>>             "cookie": "",
>>             "outCookie": 
>> "1609339398/bec3ca01-b7af-17af-a0f6-bc16ee6a0f70",
>>             "outPriv": "admin",
>>             "outRefreshPeriod": "600",
>>             "outSessionId": "8446",
>>             "outVersion": "3.1(3a)",
>>             "response": "yes"
>>         }
>>     },
>>     "ansible_facts": {
>>         "discovered_interpreter_python": "/usr/bin/python3"
>>     },
>>     "changed": false,
>>     "configResolveClass": {
>>         "attributes": {
>>             "classId": "equipmentPsu",
>>             "cookie": "1609339398/bec3ca01-b7af-17af-a0f6-bc16ee6a0f70",
>>             "response": "yes"
>>         },
>>         "children": [
>>             {
>>                 "outConfigs": {
>>                     "attributes": {},
>>                     "children": [
>>                         {
>>                             "equipmentPsu": {
>>                                 "attributes": {
>>                                     "dn": "sys/rack-unit-1/psu-1",
>>                                     "fwVersion": "12002216",
>>                                     "id": "1",
>>                                     "input": "135",
>>                                     "maxOutput": "NA",
>>                                     "model": "700-014160-0000",
>>                                     "operability": "operable",
>>                                     "output": "118",
>>                                     "pid": "UCSC-PSU1-770W",
>>                                     "power": "on",
>>                                     "presence": "equipped",
>>                                     "serial": "ART2221F58Q",
>>                                     "thermal": "ok",
>>                                     "vendor": "Cisco Systems Inc",
>>                                     "voltage": "ok"
>>                                 }
>>                             }
>>                         },
>>                         {
>>                             "equipmentPsu": {
>>                                 "attributes": {
>>                                     "dn": "sys/rack-unit-1/psu-2",
>>                                     "fwVersion": "12002216",
>>                                     "id": "2",
>>                                     "input": "140",
>>                                     "maxOutput": "NA",
>>                                     "model": "700-014160-0000",
>>                                     "operability": "operable",
>>                                     "output": "127",
>>                                     "pid": "UCSC-PSU1-770W",
>>                                     "power": "on",
>>                                     "presence": "equipped",
>>                                     "serial": "ART2221F4XS",
>>                                     "thermal": "ok",
>>                                     "vendor": "Cisco Systems Inc",
>>                                     "voltage": "ok"
>>                                 }
>>                             }
>>                         }
>>                     ]
>>                 }
>>             }
>>         ]
>>     },
>>     "elapsed": 3,
>>     "invocation": {
>>         "module_args": {
>>             "content": "<configResolveClass inHierarchical=\"false\" 
>> classId=\"equipmentPsu\"/>\n",
>>             "hostname": "host1",
>>             "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
>>             "path": null,
>>             "protocol": "https",
>>             "timeout": 60,
>>             "username": "VIPER_VIO",
>>             "validate_certs": false
>>         }
>>     },
>>     "response": "OK (unknown bytes)",
>>     "status": 200
>> }
>> ++++++++++++++++++++++++++++++++++++++++++++++++++++
>> Thanks,
>> Ramesh
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to ansible-proje...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/2da6748f-ae6e-4f05-8def-8d71520a43c3n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/2da6748f-ae6e-4f05-8def-8d71520a43c3n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> -- 
> Sent from a mobile device - please excuse the brevity, spelling and 
> punctuation.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/dff8e628-4afc-40bb-b737-f35181cc0ffan%40googlegroups.com.

Reply via email to