From d9fc3def9483ee3b5c0fb0dca621058bcd7b3a27 Mon Sep 17 00:00:00 2001 From: Mike Wiebe Date: Tue, 29 Aug 2017 17:07:46 -0400 Subject: [PATCH] Fixes #28779 eth_mode key error (#28782) * Fixes #28779 eth_mode key error * Remove unused get_config references * Addressed PR comment --- lib/ansible/modules/network/nxos/nxos_interface.py | 6 ++---- test/units/modules/network/nxos/test_nxos_interface.py | 4 ---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/ansible/modules/network/nxos/nxos_interface.py b/lib/ansible/modules/network/nxos/nxos_interface.py index c6c94e2d9aa..a27f61bcac5 100644 --- a/lib/ansible/modules/network/nxos/nxos_interface.py +++ b/lib/ansible/modules/network/nxos/nxos_interface.py @@ -141,7 +141,7 @@ commands: sample: ["interface port-channel101", "shutdown"] ''' -from ansible.module_utils.nxos import get_config, load_config, run_commands +from ansible.module_utils.nxos import load_config, run_commands from ansible.module_utils.nxos import nxos_argument_spec, check_args from ansible.module_utils.basic import AnsibleModule @@ -280,7 +280,7 @@ def get_interface(intf, module): if body: interface_table = body['TABLE_interface']['ROW_interface'] - if interface_table['eth_mode'] == 'fex-fabric': + if interface_table.get('eth_mode') == 'fex-fabric': module.fail_json(msg='nxos_interface does not support interfaces with mode "fex-fabric"') intf_type = get_interface_type(intf) if intf_type in ['portchannel', 'ethernet']: @@ -700,8 +700,6 @@ def main(): cmds.extend(cmds2) end_state, is_default = smart_existing(module, intf_type, normalized_interface) - else: - end_state = get_interfaces_dict(module)[interface_type] cmds = [cmd for cmd in cmds if cmd != 'configure'] results['commands'] = cmds diff --git a/test/units/modules/network/nxos/test_nxos_interface.py b/test/units/modules/network/nxos/test_nxos_interface.py index 769fa1612ab..e477c5d1673 100644 --- a/test/units/modules/network/nxos/test_nxos_interface.py +++ b/test/units/modules/network/nxos/test_nxos_interface.py @@ -37,13 +37,9 @@ class TestNxosInterfaceModule(TestNxosModule): self.mock_load_config = patch('ansible.modules.network.nxos.nxos_interface.load_config') self.load_config = self.mock_load_config.start() - self.mock_get_config = patch('ansible.modules.network.nxos.nxos_interface.get_config') - self.get_config = self.mock_get_config.start() - def tearDown(self): self.mock_run_commands.stop() self.mock_load_config.stop() - self.mock_get_config.stop() def load_fixtures(self, commands=None, device=''): self.load_config.return_value = None