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):