Bug 1653743 - [RFE] ansible modules facts - return nested information for all elements with 'href' attribute
Summary: [RFE] ansible modules facts - return nested information for all elements with...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Virtualization Manager
Classification: Red Hat
Component: ansible
Version: 4.3.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ovirt-4.3.7
: ---
Assignee: Martin Necas
QA Contact: Pavol Brilla
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-11-27 14:28 UTC by Lucie Leistnerova
Modified: 2020-01-09 13:25 UTC (History)
5 users (show)

Fixed In Version: ansible-2.8.4-1.el7ae
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-01-09 13:25:51 UTC
oVirt Team: Infra
Target Upstream Version:
Embargoed:
lleistne: testing_plan_complete?


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github ansible ansible pull 49239 0 'None' closed ovirt: Return also nested attributes of structs 2020-11-02 06:39:07 UTC
Github ansible ansible pull 57299 0 'None' closed ovirt: Resolve also list of hrefs 2020-11-02 06:39:07 UTC
Github ansible ansible pull 58970 0 'None' closed ovirt: Resolve also list of hrefs 2020-11-02 06:39:25 UTC

Description Lucie Leistnerova 2018-11-27 14:28:05 UTC
Description of problem:
Parameter fetch_nested in facts modules (e.g. ovirt_vm_facts) returns data only for <link> elements. But there are also <template>, <storage_domain> and other elements that could load data too.

for example in VM API call:

        <lease>
            <storage_domain href="/ovirt-engine/api/storagedomains/b1d7018b-14b1-4766-b390-5a95974ec38b" id="b1d7018b-14b1-4766-b390-5a95974ec38b"/>
        </lease>
...
        <cluster href="/ovirt-engine/api/clusters/00000002-0002-0002-0002-00000000017a" id="00000002-0002-0002-0002-00000000017a"/>
        <cpu_profile href="/ovirt-engine/api/cpuprofiles/58a16ddd-0017-0195-0176-0000000000d9" id="58a16ddd-0017-0195-0176-0000000000d9"/>
        <quota id="58a16e35-03c4-03d0-0104-0000000001ce"/>
        <next_run_configuration_exists>false</next_run_configuration_exists>
        <numa_tune_mode>interleave</numa_tune_mode>
        <status>down</status>
        <stop_time>2018-10-31T09:18:53.411+01:00</stop_time>
        <original_template href="/ovirt-engine/api/templates/00000000-0000-0000-0000-000000000000" id="00000000-0000-0000-0000-000000000000"/>
        <template href="/ovirt-engine/api/templates/00000000-0000-0000-0000-000000000000" id="00000000-0000-0000-0000-000000000000"/>

Comment 3 Lucie Leistnerova 2019-05-29 14:13:49 UTC
Direct elements works, e.g. disks:
<quota href="/ovirt-engine/api/datacenters/87bc2e30-f3b1-11e8-aa7d-001a4a013f36/quotas/96f2a2e4-f3b1-11e8-82b6-001a4a013f36" id="96f2a2e4-f3b1-11e8-82b6-001a4a013f36"/>
-->
"quota": {
                "href": "/ovirt-engine/api/datacenters/87bc2e30-f3b1-11e8-aa7d-001a4a013f36/quotas/96f2a2e4-f3b1-11e8-82b6-001a4a013f36",
                "id": "96f2a2e4-f3b1-11e8-82b6-001a4a013f36",
                "name": "Default"
            },

But when the element is in a list or other element, it doesn't work, e.g. in disks:

        <storage_domains>
            <storage_domain href="/ovirt-engine/api/storagedomains/82ceb4c9-e844-4fc7-b0ff-559052e6301f" id="82ceb4c9-e844-4fc7-b0ff-559052e6301f"/>
        </storage_domains>
-->
            "storage_domains": [
                {
                    "href": "/ovirt-engine/api/storagedomains/82ceb4c9-e844-4fc7-b0ff-559052e6301f",
                    "id": "82ceb4c9-e844-4fc7-b0ff-559052e6301f"
                }
            ],

or template:

        <version>
            <version_name>base version</version_name>
            <version_number>1</version_number>
            <base_template href="/ovirt-engine/api/templates/264640fc-1b51-4263-995b-47e3e9dd3c8f" id="264640fc-1b51-4263-995b-47e3e9dd3c8f"/>
        </version>
-->
            "version": {
                "base_template": {
                    "href": "/ovirt-engine/api/templates/264640fc-1b51-4263-995b-47e3e9dd3c8f",
                    "id": "264640fc-1b51-4263-995b-47e3e9dd3c8f"
                },
                "version_name": "base version",
                "version_number": 1
            },

Tested in ansible-2.8.0-0.9.rc3.el7ae.noarch

Comment 4 Lucie Leistnerova 2019-06-07 08:26:49 UTC
One other thing I've found, ovirt_host_facts returns more on <cluster> than needed when not nested.

      ovirt_host_facts:
        auth: "{{ ovirt_auth }}"
        pattern: "name=vhost*"
        fetch_nested: True
        nested_attributes:
          - name

returns correctly:

            "cluster": {
                "href": "/ovirt-engine/api/clusters/87c0c65c-f3b1-11e8-9209-001a4a013f36",
                "id": "87c0c65c-f3b1-11e8-9209-001a4a013f36",
                "name": "Default"
            },

but with fetch_nested: False returns all information on the cluster

"cluster": {
                "affinity_groups": [],
                "ballooning_enabled": false,
                "comment": "",
                "cpu": {
                    "architecture": "x86_64",
                    "type": "Intel Westmere Family"
                },
....

But in module ovirt_vm_facts it works as expected.

Comment 5 Ondra Machacek 2019-06-11 11:15:47 UTC
We fetch this info in ovirt_host_facts, so we are able to compare cluster version and filter it. This is different issue only in ovirt_host_facts. Can you please open an issue for that module.

Comment 6 Lucie Leistnerova 2019-06-11 13:12:18 UTC
Done - BZ 1719303

Comment 7 Sandro Bonazzola 2019-07-30 07:35:46 UTC
ansible-2.8.3 has been released, please check this bug is fixed there.

Comment 9 Sandro Bonazzola 2019-08-23 13:31:26 UTC
Can we get this verified?

Comment 10 Pavol Brilla 2019-08-26 10:51:07 UTC
Working for storage_domains in disks, but for base_template in element version in template still doesn't return name of template 

ansible localhost -m ovirt_template_facts -a 'pattern="name=*" fetch_nested=True nested_attributes=name'
......
                "version": {
                    "base_template": {
                        "href": "/ovirt-engine/api/templates/154f10b7-de72-4b0b-87cf-54a52d7ad035", 
                        "id": "154f10b7-de72-4b0b-87cf-54a52d7ad035"
                    }, 
......

VS

<template href="/ovirt-engine/api/templates/154f10b7-de72-4b0b-87cf-54a52d7ad035" id="154f10b7-de72-4b0b-87cf-54a52d7ad035">
.....
    <name>golden_template_rhel7.7</name>



# ansible --version
ansible 2.8.4

Comment 11 Ondra Machacek 2019-09-05 11:49:46 UTC
(In reply to Pavol Brilla from comment #10)
> Working for storage_domains in disks, but for base_template in element
> version in template still doesn't return name of template 
> 
> ansible localhost -m ovirt_template_facts -a 'pattern="name=*"
> fetch_nested=True nested_attributes=name'
> ......
>                 "version": {
>                     "base_template": {
>                         "href":
> "/ovirt-engine/api/templates/154f10b7-de72-4b0b-87cf-54a52d7ad035", 
>                         "id": "154f10b7-de72-4b0b-87cf-54a52d7ad035"
>                     }, 
> ......
> 
> VS
> 
> <template
> href="/ovirt-engine/api/templates/154f10b7-de72-4b0b-87cf-54a52d7ad035"
> id="154f10b7-de72-4b0b-87cf-54a52d7ad035">
> .....
>     <name>golden_template_rhel7.7</name>
> 
> 
> 
> # ansible --version
> ansible 2.8.4

Going over each nested attribute attributes and checking if it's a link would bring much bigger time complexity, for no value IMHO. We should document that by default we go only over first level attributes, not any other level of attribute and maybe add parameter which enables going deeper, but I would close this bug, and open new one to track this. Moving back to ON_QA.

Comment 12 Pavol Brilla 2019-11-04 08:11:02 UTC
Issue opened for clarification: https://github.com/ansible/ansible/issues/63127

As previously stated other cases verified

Comment 13 Sandro Bonazzola 2020-01-09 13:25:51 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2019:2543


Note You need to log in before you can comment on or make changes to this bug.