Fixes #28779 eth_mode key error (#28782)

* Fixes #28779 eth_mode key error

* Remove unused get_config references

* Addressed PR comment
pull/28802/head
Mike Wiebe 7 years ago committed by Nathaniel Case
parent e9dd4717e5
commit d9fc3def94

@ -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

@ -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

Loading…
Cancel
Save