Skip to content
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

Made changes to aci_rest module to only add annotation when the value is a dictionary and changed the way the cookie is retrieved in the httpapi plugin (DCNE-176) #689

Merged
merged 1 commit into from
Oct 17, 2024
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/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)
lhercot marked this conversation as resolved.
Show resolved Hide resolved
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")}
shrsr marked this conversation as resolved.
Show resolved Hide resolved
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", {})
shrsr marked this conversation as resolved.
Show resolved Hide resolved
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
26 changes: 25 additions & 1 deletion tests/integration/targets/aci_rest/tasks/json_inline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,28 @@
- nm_add_tenant_annotation_children.imdata.0.fvTenant.attributes.annotation == "test:inoption"
- nm_add_tenant_annotation_children.imdata.0.fvTenant.children.0.fvAp.attributes.annotation == "test:inoption"
- nm_add_tenant_annotation_children.imdata.0.fvTenant.children.0.fvAp.children.0.fvAEPg.attributes.annotation == "test:inchild"
- nm_add_tenant_annotation_children.imdata.0.fvTenant.children.2.fvCtx.attributes.annotation == "test:inoption"
- nm_add_tenant_annotation_children.imdata.0.fvTenant.children.2.fvCtx.attributes.annotation == "test:inoption"

# Test to check the fix for disabling intersight connectivity issue: https://github.com/CiscoDevNet/ansible-aci/issues/685
shrsr marked this conversation as resolved.
Show resolved Hide resolved
- name: Disable Intersight Connectivity
cisco.aci.aci_rest:
host: '{{ aci_hostname }}'
username: '{{ aci_username }}'
password: '{{ aci_password }}'
validate_certs: '{{ aci_validate_certs | default(false) }}'
use_ssl: '{{ aci_use_ssl | default(true) }}'
use_proxy: '{{ aci_use_proxy | default(true) }}'
output_level: '{{ aci_output_level | default("info") }}'
path: /connector/Systems.json
method: post
rsp_subtree_preserve: true
content:
{
"AdminState": false
}
register: disable_intersight_connectivity

- name: Verify Intersight Connectivity is disabled
assert:
that:
- disable_intersight_connectivity.imdata.0.AdminState == false