From 00abe6dbe7e8670d53741df0fc3eaded84b2d080 Mon Sep 17 00:00:00 2001 From: Trishna Guha Date: Tue, 20 Mar 2018 01:53:08 +0530 Subject: [PATCH] fix UnboundLocalError nxos_bgp_af module (#37610) Signed-off-by: Trishna Guha --- lib/ansible/modules/network/nxos/nxos_bgp_af.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/network/nxos/nxos_bgp_af.py b/lib/ansible/modules/network/nxos/nxos_bgp_af.py index 76a0245ec4..b50db52dde 100644 --- a/lib/ansible/modules/network/nxos/nxos_bgp_af.py +++ b/lib/ansible/modules/network/nxos/nxos_bgp_af.py @@ -490,14 +490,16 @@ def get_network_command(existing, key, value): command = '{0} {1}'.format(key, inet[0]) elif len(inet) == 2: command = '{0} {1} route-map {2}'.format(key, inet[0], inet[1]) - commands.append(command) + if command: + commands.append(command) for enet in existing_networks: if enet not in value: if len(enet) == 1: command = 'no {0} {1}'.format(key, enet[0]) elif len(enet) == 2: command = 'no {0} {1} route-map {2}'.format(key, enet[0], enet[1]) - commands.append(command) + if command: + commands.append(command) return commands @@ -515,7 +517,8 @@ def get_inject_map_command(existing, key, value): command = ('inject-map {0} exist-map {1} ' 'copy-attributes'.format(maps[0], maps[1])) - commands.append(command) + if command: + commands.append(command) for emaps in existing_maps: if emaps not in value: if len(emaps) == 2: @@ -525,7 +528,8 @@ def get_inject_map_command(existing, key, value): command = ('no inject-map {0} exist-map {1} ' 'copy-attributes'.format(emaps[0], emaps[1])) - commands.append(command) + if command: + commands.append(command) return commands