Skip to content

Commit

Permalink
[bugfix] Made changes to aci_rest module to only add annotation when …
Browse files Browse the repository at this point in the history
…the value is a dictionary and changed the way the cookie is retrieved in the httpapi plugin
  • Loading branch information
shrsr committed Oct 4, 2024
1 parent 7ab2866 commit bcd3f89
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
5 changes: 1 addition & 4 deletions plugins/httpapi/aci.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ def login(self, username, password):
self.connection._connected = True
try:
response, response_data = self.connection.send(path, data, method=method)
response_value = self._get_response_value(response_data)
self.connection._auth = {
"Cookie": "APIC-Cookie={0}".format(self._response_to_json(response_value).get("imdata")[0]["aaaLogin"]["attributes"]["token"])
}
self.connection._auth = {"Cookie": response.headers.get("Set-Cookie")}
self.connection.queue_message("debug", "Connection to {0} was successful".format(self.connection.get_option("host")))
except Exception as exc_login:
self.connection._connected = False
Expand Down
12 changes: 8 additions & 4 deletions plugins/module_utils/aci.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,10 +606,14 @@ def response_json(self, rawoutput):
return

# Extract JSON API output
self.imdata = jsondata.get("imdata")
if self.imdata is None:
self.imdata = dict()
self.totalCount = int(jsondata.get("totalCount"))
if isinstance(jsondata, list):
self.imdata = jsondata
self.totalCount = len(jsondata)
else:
self.imdata = jsondata.get("imdata", {})
total_count = jsondata.get("totalCount")
if total_count is not None:
self.totalCount = int(total_count)

# Handle possible APIC error information
self.response_error()
Expand Down
17 changes: 9 additions & 8 deletions plugins/modules/aci_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,15 @@ def add_annotation(annotation, payload):
for key, val in payload.items():
if key in ANNOTATION_UNSUPPORTED:
continue
att = val.get("attributes", {})
if "annotation" not in att.keys():
att["annotation"] = annotation
# Recursively add annotation to children
children = val.get("children", None)
if children:
for child in children:
add_annotation(annotation, child)
if isinstance(val, dict):
att = val.get("attributes", {})
if "annotation" not in att.keys():
att["annotation"] = annotation
# Recursively add annotation to children
children = val.get("children", None)
if children:
for child in children:
add_annotation(annotation, child)


def add_annotation_xml(annotation, tree):
Expand Down

0 comments on commit bcd3f89

Please sign in to comment.