Skip to content

zpe.nodegrid.nodegrid_read_state returns last sub-option value #69

@m-hau

Description

@m-hau

When using the zpe.nodegrid.nodegrid_read_state module to query options which also enable other sub-options, the value returned is of the last sub-option (which most likely is not the one requested). As an example, querying the LLDP state of a network connection (with LLDP already enabled) on the CLI also returns the other LLDP options (id and description):

[admin@nodegrid /]# show /settings/network_connections/ETH0/ enable_lldp
enable_lldp = yes
port_id = interface_name
port_description = interface_description
[admin@nodegrid /]#

Doing this using the zpe.nodegrid.nodegrid_read_state module, the value returned is not yes but interface_description, which is the value of the last sub-option port_description.

admin@nodegrid:~$ ansible -m 'zpe.nodegrid.nodegrid_read_state' \
        -a '{ "read_options": { "path": "/settings/network_connections/ETH0", "options": "enable_lldp" } }' nodegrid
nodegrid | SUCCESS => 
    changed: false
    message: No change required
    output:
        read_options:
            changed: false
            failed: false
            message: ''
            results:
            -   option: enable_lldp
                path: /settings/network_connections/ETH0
                value: interface_description
admin@nodegrid:~$

The relevant code-bit is read_path_option(). Not sure if/what options really need this behaviour, maybe it would be enough to break out of the loop after the first value was found.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions