-
Notifications
You must be signed in to change notification settings - Fork 98
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
Modified 'aci_rest' and 'aci_config_snapshot' modules to display the correct URL output string #487
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -250,6 +250,7 @@ | |||||
|
||||||
import json | ||||||
import os | ||||||
import re | ||||||
|
||||||
try: | ||||||
from ansible.module_utils.six.moves.urllib.parse import parse_qsl, urlencode, urlparse, urlunparse | ||||||
|
@@ -283,7 +284,7 @@ | |||||
HAS_YAML = False | ||||||
|
||||||
from ansible.module_utils.basic import AnsibleModule | ||||||
from ansible_collections.cisco.aci.plugins.module_utils.aci import ACIModule, aci_argument_spec | ||||||
from ansible_collections.cisco.aci.plugins.module_utils.aci import ACIModule, aci_argument_spec, replace_apic_host | ||||||
from ansible.module_utils._text import to_text | ||||||
|
||||||
|
||||||
|
@@ -406,8 +407,11 @@ def main(): | |||||
module.fail_json(msg="Failed to parse provided XML payload: {0}".format(to_text(e)), payload=payload) | ||||||
|
||||||
# Perform actual request using auth cookie (Same as aci.request(), but also supports XML) | ||||||
aci.url = "{0}/{1}".format(aci.base_url, path.lstrip("/")) | ||||||
# NOTE By setting aci.path we ensure that Ansible displays accurate URL info when the plugin and the aci_rest module are used. | ||||||
aci.path = path.lstrip("/") | ||||||
aci.url = "{0}/{1}".format(aci.base_url, aci.path) | ||||||
if aci.params.get("method") != "get" and not rsp_subtree_preserve: | ||||||
aci.path = "{0}?rsp-subtree=modified".format(aci.path) | ||||||
aci.url = update_qsl(aci.url, {"rsp-subtree": "modified"}) | ||||||
|
||||||
method = aci.params.get("method").upper() | ||||||
|
@@ -434,6 +438,9 @@ def main(): | |||||
aci.result["totalCount"] = aci.totalCount | ||||||
|
||||||
else: | ||||||
# NOTE A case when aci_rest is used with check mode and the apic host is used directly from the inventory | ||||||
if aci.connection is not None and aci.params.get("host") is None: | ||||||
aci.url = replace_apic_host(aci.url, re.sub(r"[[\]]", "", aci.connection.get_option("host")).split(",")[0]) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if this is the only location where this is used because it is an exception we could also decide to only set here by leveraging the url parse/unparse function here
Suggested change
|
||||||
aci.method = method | ||||||
# Set changed to true so check_mode changed result is behaving similar to non aci_rest modules | ||||||
aci.result["changed"] = True | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this function in aci.py or should we place in the aci_rest which is the only place where it is used?