From 1b3e23b0bd9f909255ac0659548f6c77d290f0c8 Mon Sep 17 00:00:00 2001 From: Shreyas Date: Wed, 13 Sep 2023 20:01:47 -0400 Subject: [PATCH] [ignore] Fixed issue in 'aci_config_rollback'. The xml response is now parsed by response_xml function in aci.py when status is not 200 --- plugins/module_utils/aci.py | 2 +- plugins/modules/aci_config_rollback.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/module_utils/aci.py b/plugins/module_utils/aci.py index 530d99c5d..9c6e2db2d 100644 --- a/plugins/module_utils/aci.py +++ b/plugins/module_utils/aci.py @@ -556,7 +556,7 @@ def response_xml(self, rawoutput): self.imdata = xmldata.get("imdata", {}).get("children") if self.imdata is None: self.imdata = dict() - self.totalCount = int(xmldata.get("imdata", {}).get("attributes", {}).get("totalCount")) + self.totalCount = int(xmldata.get("imdata", {}).get("attributes", {}).get("totalCount", -1)) # Handle possible APIC error information self.response_error() diff --git a/plugins/modules/aci_config_rollback.py b/plugins/modules/aci_config_rollback.py index f7d19d7a1..d6e47271b 100644 --- a/plugins/modules/aci_config_rollback.py +++ b/plugins/modules/aci_config_rollback.py @@ -315,8 +315,13 @@ def get_preview(aci): except AttributeError: xml_to_json(aci, info.get("body")) else: - aci.result["raw"] = info["body"] - aci.fail_json(msg="Request failed: see 'raw' output") + try: + # APIC error + aci.response_xml(info["body"]) + aci.fail_json(msg="APIC Error {code}: {text}".format_map(aci.error)) + except KeyError: + # Connection error + aci.fail_json(msg="Connection failed for {url}. {msg}".format_map(info)) def xml_to_json(aci, response_data):