From 5537218c94130cc6dbab104be82d3d1b9b5ab5f5 Mon Sep 17 00:00:00 2001 From: rahushen Date: Wed, 13 Sep 2017 08:37:06 -0400 Subject: [PATCH] fixes #27066 - nxos_acl errors when there are 0 or 1 access lists configured (#29076) * fixes #27066 * replace type() with isinstance() --- lib/ansible/modules/network/nxos/nxos_acl.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/network/nxos/nxos_acl.py b/lib/ansible/modules/network/nxos/nxos_acl.py index 0a448a78f2..33f6a7c49f 100644 --- a/lib/ansible/modules/network/nxos/nxos_acl.py +++ b/lib/ansible/modules/network/nxos/nxos_acl.py @@ -239,11 +239,20 @@ def get_acl(module, acl_name, seq_number): acl_body = {} body = execute_show_command(command, module)[0] - all_acl_body = body['TABLE_ip_ipv6_mac']['ROW_ip_ipv6_mac'] + if body: + all_acl_body = body['TABLE_ip_ipv6_mac']['ROW_ip_ipv6_mac'] + else: + # no access-lists configured on the device + return {}, [] - for acl in all_acl_body: - if acl.get('acl_name') == acl_name: - acl_body = acl + if isinstance(all_acl_body, dict): + # Only 1 ACL configured. + if all_acl_body.get('acl_name') == acl_name: + acl_body = all_acl_body + else: + for acl in all_acl_body: + if acl.get('acl_name') == acl_name: + acl_body = acl try: acl_entries = acl_body['TABLE_seqno']['ROW_seqno']