Skip to content
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

uri: Add support for parsing XML payload #53045

Open
wants to merge 7 commits into
base: devel
from

Conversation

Projects
None yet
3 participants
@dagwieers
Copy link
Member

dagwieers commented Feb 27, 2019

SUMMARY

This PR add support for parsing XML payload useful when automating XML,
XHTML or SOAP payload.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

uri

ADDITIONAL INFORMATION
[dwieers@localhost ~]$ ansible -m uri -a 'url=https://c220m4-3/nuova body="<aaaLogin inName=\"admin\" inPassword=\"password\"/>" validate_certs=no method=POST' localhost

localhost | SUCCESS => {
    "changed": false,
    "connection": "close",
    "content_length": "189",
    "content_type": "application/soap+xml;charset=UTF-8",
    "cookies": {},
    "cookies_string": "",
    "date": "Wed, 27 Feb 2019 12:27:43 GMT",
    "elapsed": 2,
    "msg": "OK (189 bytes)",
    "redirected": false,
    "server": "Mbedthis-Appweb/2.4.2",
    "status": 200,
    "url": "https://bdsol-aci51-c220m4-3/nuova",
    "x_frame_options": "SAMEORIGIN",
    "xml": {
        "aaaLogin": {
            "@cookie": "",
            "@outCookie": "1551270463/1946f5e8-82e0-12e0-861f-0ac36c11332c",
            "@outPriv": "admin",
            "@outRefreshPeriod": "600",
            "@outSessionId": "1880",
            "@outVersion": "2.0(13e)",
            "@response": "yes"
        }
    }
}
uri: Add support for parsing XML payload
This PR add support for parsing XML payload useful when automating XML,
XHTML or SOAP payload.
@ansibot

This comment has been minimized.

Copy link
Contributor

ansibot commented Feb 27, 2019

@dagwieers dagwieers force-pushed the dagwieers:uri-xml branch from f7d795e to 3919b82 Feb 27, 2019

@ansibot

This comment was marked as resolved.

Copy link
Contributor

ansibot commented Feb 27, 2019

The test ansible-test sanity --test pylint [explain] failed with 2 errors:

lib/ansible/modules/net_tools/basics/uri.py:319:17: bad-whitespace Exactly one space required around assignment     HAS_XMLTODICT=True                  ^
lib/ansible/modules/net_tools/basics/uri.py:321:17: bad-whitespace Exactly one space required around assignment     HAS_XMLTODICT=False                  ^

The test ansible-test sanity --test pep8 [explain] failed with 3 errors:

lib/ansible/modules/net_tools/basics/uri.py:319:18: E225 missing whitespace around operator
lib/ansible/modules/net_tools/basics/uri.py:321:18: E225 missing whitespace around operator
lib/ansible/modules/net_tools/basics/uri.py:333:1: E302 expected 2 blank lines, found 1

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

lib/ansible/modules/net_tools/basics/uri.py:0:0: E305 DOCUMENTATION.requires: extra keys not allowed @ data['requires']. Got ['xmltodict (when dealing with XML content)']

click here for bot help

@ansibot ansibot added needs_revision and removed core_review labels Feb 27, 2019

@dagwieers dagwieers force-pushed the dagwieers:uri-xml branch from c70e7b5 to 291b815 Feb 27, 2019

dagwieers added some commits Feb 27, 2019

@dagwieers dagwieers force-pushed the dagwieers:uri-xml branch from 6aa633d to 91f318d Feb 27, 2019

@ansibot ansibot added core_review and removed needs_revision labels Feb 27, 2019

@bcoca bcoca removed the needs_triage label Mar 5, 2019

@bcoca
Copy link
Member

bcoca left a comment

Instead of building this into the URI module (and eventually a parser for every type of content) it would work better as a filter (so other modules can also benefit). It also avoid having xmltodict as a new requriement for the module, specially since most current uses don't need it.

Also, there are many competing standards on how to convert xml to dictionaries ... i would look at a more flexible solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.