New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xml filter plugin #31948

Open
wants to merge 9 commits into
base: devel
from

Conversation

Projects
None yet
5 participants
@GIC-de
Contributor

GIC-de commented Oct 19, 2017

SUMMARY

The xml filter plugin allows to retrieve the text of an xml element within an xml structure provided as string.

Example Usage:

  - name: show version
    junos_rpc:
        rpc: get-software-information
    register: junos_version

  - name: ...
...
     when: junos_version.xml|xml_findtext('.//package-information[name=\"junos-openconfig\"]/comment') != "JUNOS Openconfig [0.0.0.5]"
ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME
  • lib/ansible/plugins/filter/xml.py
ANSIBLE VERSION
ansible 2.3.2.0
@dagwieers

This comment has been minimized.

Member

dagwieers commented Oct 21, 2017

In the example, why is the double-quote being escaped ?

@ansible ansible deleted a comment from ansibot Oct 21, 2017

@ansible ansible deleted a comment from ansibot Oct 21, 2017

@ansible ansible deleted a comment from ansibot Oct 21, 2017

@dagwieers

This comment has been minimized.

Member

dagwieers commented Oct 21, 2017

This is looking good, and should probably get a mention in the xml/win_xml module documentation as well as the xml module Wiki page.

@@ -0,0 +1,49 @@
# (c) 2017, Christian Giese (@GIC-de)

This comment has been minimized.

@dagwieers

dagwieers Oct 21, 2017

Member

This should be:

# Copyright: (c) 2017, Christian Giese (@GIC-de)
@@ -0,0 +1,49 @@
# (c) 2017, Christian Giese (@GIC-de)
#
# This file is part of Ansible

This comment has been minimized.

@dagwieers

dagwieers Oct 21, 2017

Member

We now have a single line GPL license statement.

# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
@dagwieers

LGTM

@GIC-de

This comment has been minimized.

Contributor

GIC-de commented Jan 10, 2018

New xml_findall filter which allows to iterate over an xml structure.

  - name: check isis adjacency
    fail:
        msg: "isis adjacency not up"
    when: "item|xml_findtext('.//adjacency-state') != 'Up'"
    with_items: "{{ isis_adjacency.xml|xml_findall('.//isis-adjacency') }}"

@ansibot ansibot removed the stale_ci label Jan 10, 2018

@ansibot ansibot added the stale_ci label Jan 19, 2018

@GIC-de

This comment has been minimized.

Contributor

GIC-de commented Jan 31, 2018

@dagwieers is there something missing to get this change merged?

@maxamillion

This comment has been minimized.

Contributor

maxamillion commented Dec 5, 2018

First off, apologies for the lag time on this and thank you for the pull request!

Could you please add some integration tests to exercise the new functionality added? Also, please include a changelog fragment. Also, some notation in the filters doc would be appreciated, the notable file is ./docs/docsite/rst/user_guide/playbooks_filters.rst. Otherwise the changes look good. 👍

@maxamillion

This comment has been minimized.

Contributor

maxamillion commented Dec 5, 2018

needs_revision

@ansibot ansibot added needs_revision and removed core_review labels Dec 5, 2018

@GIC-de GIC-de force-pushed the GIC-de:xml_filter branch from f507af6 to 1b19533 Dec 6, 2018

@ansibot ansibot removed the stale_ci label Dec 6, 2018

GIC-de added some commits Jan 10, 2018

xml filter tests and documentation
+ add unit test
+ add integration tests
+ add to user guide

@GIC-de GIC-de force-pushed the GIC-de:xml_filter branch from 1b19533 to f42c8d6 Dec 7, 2018

@ansibot

This comment has been minimized.

Contributor

ansibot commented Dec 7, 2018

@ansibot

This comment has been minimized.

Contributor

ansibot commented Dec 7, 2018

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

test/units/plugins/filter/test_xml.py:40:161: E501 line too long (164 > 160 characters)

click here for bot help

GIC-de added some commits Dec 12, 2018

fix unit and integration tests
+ python 2/3 compatibility
+ move from filter to xml integrations tests
@ansibot

This comment has been minimized.

Contributor

ansibot commented Dec 12, 2018

@ansibot ansibot added the m:xml label Dec 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment