Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions plugins/modules/aci_config_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,7 @@ def main():
target_filter={"name": export_policy},
),
)
# Variable set for reuse of correct url in get_existing() triggered from exit_json() after query request
reset_url = aci.url

aci.get_existing()

aci.payload(
Expand All @@ -305,8 +304,6 @@ def main():
path = "api/node/mo/uni/backupst/jobs-[uni/fabric/configexp-{0}].json".format(export_policy)
aci.api_call("GET", url="{0}/{1}".format(aci.base_url, path))
aci.result["job_details"] = aci.existing[0].get("configJobCont", {})
# Reset state and url to display correct in output and trigger get_existing() function with correct url
aci.url = reset_url

else:
# Prefix the proper url to export_policy
Expand Down
9 changes: 8 additions & 1 deletion plugins/modules/aci_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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 = urlunparse(urlparse(aci.url)._replace(netloc=re.sub(r"[[\]]", "", aci.connection.get_option("host")).split(",")[0]))
aci.method = method
# Set changed to true so check_mode changed result is behaving similar to non aci_rest modules
aci.result["changed"] = True
Expand Down