diff --git a/lib/ansible/modules/network/nxos/nxos_interface.py b/lib/ansible/modules/network/nxos/nxos_interface.py index 3c33dd2c297..6093447df8c 100644 --- a/lib/ansible/modules/network/nxos/nxos_interface.py +++ b/lib/ansible/modules/network/nxos/nxos_interface.py @@ -20,16 +20,17 @@ ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'network'} - -DOCUMENTATION = ''' +DOCUMENTATION = """ --- module: nxos_interface extends_documentation_fragment: nxos version_added: "2.1" short_description: Manages physical attributes of interfaces. description: - - Manages physical attributes of interfaces of NX-OS switches. -author: Jason Edelman (@jedelman8) + - Manages physical attributes of interfaces of NX-OS switches. +author: + - Jason Edelman (@jedelman8) + - Trishna Guha (@trishnaguha) notes: - Tested against NXOSv 7.3.(0)D1(1) on VIRL - This module is also used to create logical interfaces such as @@ -40,18 +41,23 @@ notes: - The M(nxos_overlay_global) C(anycast_gateway_mac) attribute must be set before setting the C(fabric_forwarding_anycast_gateway) property. options: - interface: + name: description: - Full name of interface, i.e. Ethernet1/1, port-channel10. required: true default: null + aliases: [interface] interface_type: description: - Interface type to be unconfigured from the device. required: false default: null choices: ['loopback', 'portchannel', 'svi', 'nve'] - version_added: "2.2" + version_added: 2.2 + speed: + description: + - Interface link speed. + version_added: 2.5 admin_state: description: - Administrative state of the interface. @@ -80,48 +86,73 @@ options: required: false default: null choices: ['enable','disable'] - version_added: "2.2" + version_added: 2.2 fabric_forwarding_anycast_gateway: description: - Associate SVI with anycast gateway under VLAN configuration mode. required: false default: null choices: ['true','false'] - version_added: "2.2" + version_added: 2.2 + duplex: + description: + - Interface link status + default: auto + choices: ['full', 'half', 'auto'] + version_added: 2.5 + tx_rate: + description: + - Transmit rate in bits per second (bps). + version_added: 2.5 + rx_rate: + description: + - Receiver rate in bits per second (bps). + version_added: 2.5 + neighbors: + description: + - Check the operational state of given interface C(name) for LLDP neighbor. + - The following suboptions are available. + suboptions: + host: + description: + - "LLDP neighbor host for given interface C(name)." + port: + description: + - "LLDP neighbor port to which given interface C(name) is connected." + version_added: 2.5 + aggregate: + description: List of Interfaces definitions. + version_added: 2.5 state: description: - Specify desired state of the resource. required: true default: present choices: ['present','absent','default'] -''' +""" -EXAMPLES = ''' +EXAMPLES = """ - name: Ensure an interface is a Layer 3 port and that it has the proper description nxos_interface: - interface: Ethernet1/1 + name: Ethernet1/1 description: 'Configured by Ansible' mode: layer3 - host: 68.170.147.165 - name: Admin down an interface nxos_interface: - interface: Ethernet2/1 - host: 68.170.147.165 + name: Ethernet2/1 admin_state: down - name: Remove all loopback interfaces nxos_interface: - interface: loopback + name: loopback state: absent - host: 68.170.147.165 - name: Remove all logical interfaces nxos_interface: interface_type: "{{ item }} " state: absent - host: "{{ inventory_hostname }}" - with_items: + loop: - loopback - portchannel - svi @@ -129,38 +160,226 @@ EXAMPLES = ''' - name: Admin up all loopback interfaces nxos_interface: - interface: loopback 0-1023 + name: loopback 0-1023 admin_state: up - name: Admin down all loopback interfaces nxos_interface: - interface: looback 0-1023 + name: looback 0-1023 admin_state: down -''' -RETURN = ''' +- name: Check neighbors intent arguments + nxos_interface: + name: Ethernet2/3 + neighbors: + - port: Ethernet2/3 + host: abc.mycompany.com + +- name: Add interface using aggregate + nxos_interface: + aggregate: + - { name: Ethernet0/1, mtu: 256, description: test-interface-1 } + - { name: Ethernet0/2, mtu: 516, description: test-interface-2 } + duplex: full + speed: 100 + state: present + +- name: Delete interface using aggregate + nxos_interface: + aggregate: + - name: Loopback9 + - name: Loopback10 + state: absent + +- name: Check intent arguments + nxos_interface: + name: Ethernet0/2 + state: up + tx_rate: ge(0) + rx_rate: le(0) +""" + +RETURN = """ commands: description: command list sent to the device returned: always type: list - sample: ["interface port-channel101", "shutdown"] -''' + sample: + - interface Ethernet2/3 + - mtu 1500 + - speed 10 +""" + +import re +import time + +from copy import deepcopy + from ansible.module_utils.network.nxos.nxos import load_config, run_commands -from ansible.module_utils.network.nxos.nxos import nxos_argument_spec, check_args +from ansible.module_utils.network.nxos.nxos import nxos_argument_spec from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.network.common.utils import conditional, remove_default_spec -def is_default_interface(interface, module): - """Checks to see if interface exists and if it is a default config - Args: - interface (str): full name of interface, i.e. vlan10, - Ethernet1/1, loopback10 - Returns: - True: if interface has default config - False: if it does not have a default config - DNE (str): if the interface does not exist - loopbacks, SVIs, etc. +def execute_show_command(command, module): + if 'show run' not in command: + output = 'json' + else: + output = 'text' + cmds = [{ + 'command': command, + 'output': output, + }] + body = run_commands(module, cmds, check_rc=False) + if body and "Invalid" in body[0]: + return [] + else: + return body + + +def search_obj_in_list(name, lst): + for o in lst: + if o['name'] == name: + return o + + return None + + +def get_interface_type(interface): + """Gets the type of interface """ - command = 'show run interface {0}'.format(interface) + if interface.upper().startswith('ET'): + return 'ethernet' + elif interface.upper().startswith('VL'): + return 'svi' + elif interface.upper().startswith('LO'): + return 'loopback' + elif interface.upper().startswith('MG'): + return 'management' + elif interface.upper().startswith('MA'): + return 'management' + elif interface.upper().startswith('PO'): + return 'portchannel' + elif interface.upper().startswith('NV'): + return 'nve' + else: + return 'unknown' + + +def get_interfaces_dict(module): + """Gets all active interfaces on a given switch + """ + try: + body = execute_show_command('show interface', module)[0] + except IndexError: + return {} + + interfaces = { + 'ethernet': [], + 'svi': [], + 'loopback': [], + 'management': [], + 'portchannel': [], + 'nve': [], + 'unknown': [] + } + + if body: + interface_list = body['TABLE_interface']['ROW_interface'] + for index in interface_list: + intf = index['interface'] + intf_type = get_interface_type(intf) + interfaces[intf_type].append(intf) + + return interfaces + + +def normalize_interface(name): + """Return the normalized interface name + """ + if not name: + return None + + def _get_number(name): + digits = '' + for char in name: + if char.isdigit() or char == '/': + digits += char + return digits + + if name.lower().startswith('et'): + if_type = 'Ethernet' + elif name.lower().startswith('vl'): + if_type = 'Vlan' + elif name.lower().startswith('lo'): + if_type = 'loopback' + elif name.lower().startswith('po'): + if_type = 'port-channel' + elif name.lower().startswith('nv'): + if_type = 'nve' + else: + if_type = None + + number_list = name.split(' ') + if len(number_list) == 2: + number = number_list[-1].strip() + else: + number = _get_number(name) + + if if_type: + proper_interface = if_type + number + else: + proper_interface = name + + return proper_interface + + +def get_vlan_interface_attributes(name, intf_type, module): + """ Returns dictionary that has two k/v pairs: + admin_state & description if not an svi, returns None + """ + command = 'show run interface {0} all'.format(name) + try: + body = execute_show_command(command, module)[0] + except IndexError: + return None + if body: + command_list = body.split('\n') + desc = None + admin_state = 'down' + for each in command_list: + if 'description' in each: + desc = each.lstrip().split("description")[1].lstrip() + elif 'no shutdown' in each: + admin_state = 'up' + return dict(description=desc, admin_state=admin_state) + else: + return None + + +def get_interface_type_removed_cmds(interfaces): + commands = [] + + for interface in interfaces: + if interface != 'Vlan1': + commands.append('no interface {0}'.format(interface)) + + return commands + + +def get_admin_state(admin_state): + command = '' + if admin_state == 'up': + command = 'no shutdown' + elif admin_state == 'down': + command = 'shutdown' + return command + + +def is_default_interface(name, module): + """Checks to see if interface exists and if it is a default config + """ + command = 'show run interface {0}'.format(name) try: body = execute_show_command(command, module)[0] @@ -181,557 +400,397 @@ def is_default_interface(interface, module): return 'DNE' -def get_interface_type(interface): - """Gets the type of interface - Args: - interface (str): full name of interface, i.e. Ethernet1/1, loopback10, - port-channel20, vlan20 - Returns: - type of interface: ethernet, svi, loopback, management, portchannel, - or unknown - """ - if interface.upper().startswith('ET'): - return 'ethernet' - elif interface.upper().startswith('VL'): - return 'svi' - elif interface.upper().startswith('LO'): - return 'loopback' - elif interface.upper().startswith('MG'): - return 'management' - elif interface.upper().startswith('MA'): - return 'management' - elif interface.upper().startswith('PO'): - return 'portchannel' - elif interface.upper().startswith('NV'): - return 'nve' +def add_command_to_interface(interface, cmd, commands): + if interface not in commands: + commands.append(interface) + commands.append(cmd) + + +def map_obj_to_commands(updates, module): + commands = list() + commands2 = list() + want, have = updates + + args = ('speed', 'description', 'duplex', 'mtu') + for w in want: + name = w['name'] + mode = w['mode'] + ip_forward = w['ip_forward'] + fabric_forwarding_anycast_gateway = w['fabric_forwarding_anycast_gateway'] + admin_state = w['admin_state'] + state = w['state'] + interface_type = w['interface_type'] + del w['state'] + if name: + w['interface_type'] = None + + obj_in_have = search_obj_in_list(name, have) + is_default = is_default_interface(name, module) + if name: + interface = 'interface ' + name + + if interface_type and state == 'present': + module.fail_json(msg='The interface_type param can be used only with state absent.') + + if state == 'absent': + if obj_in_have: + commands.append('no interface {0}'.format(name)) + elif interface_type: + intfs = get_interfaces_dict(module)[interface_type] + cmds = get_interface_type_removed_cmds(intfs) + commands.extend(cmds) + + elif state == 'present': + if obj_in_have: + for item in args: + candidate = w.get(item) + + if candidate and candidate != obj_in_have.get(item): + cmd = item + ' ' + str(candidate) + add_command_to_interface(interface, cmd, commands) + + if mode == 'layer2' and mode != obj_in_have.get('mode'): + add_command_to_interface(interface, 'switchport', commands) + elif mode == 'layer3' and mode != obj_in_have.get('mode'): + add_command_to_interface(interface, 'no switchport', commands) + + if admin_state == 'up' and admin_state != obj_in_have.get('admin_state'): + add_command_to_interface(interface, 'no shutdown', commands) + elif admin_state == 'down' and admin_state != obj_in_have.get('admin_state'): + add_command_to_interface(interface, 'shutdown', commands) + + if ip_forward == 'enable' and ip_forward != obj_in_have.get('ip_forward'): + add_command_to_interface(interface, 'ip forward', commands) + elif ip_forward == 'disable' and ip_forward != obj_in_have.get('ip forward'): + add_command_to_interface(interface, 'no ip forward', commands) + + if (fabric_forwarding_anycast_gateway is True and + obj_in_have.get('fabric_forwarding_anycast_gateway') is True): + add_command_to_interface(interface, 'fabric forwarding mode anycast-gateway', commands) + + elif (fabric_forwarding_anycast_gateway is False and + obj_in_have.get('fabric_forwarding_anycast_gateway') is False): + add_command_to_interface(interface, 'no fabric forwarding mode anycast-gateway', commands) + + if name and get_interface_type(name) == 'ethernet': + if mode != obj_in_have.get('mode'): + admin_state = w.get('admin_state') or obj_in_have.get('admin_state') + if admin_state: + c1 = 'interface {0}'.format(normalize_interface(w['name'])) + c2 = get_admin_state(admin_state) + commands2.append(c1) + commands2.append(c2) + + else: + commands.append(interface) + for item in args: + candidate = w.get(item) + if candidate: + commands.append(item + ' ' + str(candidate)) + + if mode == 'layer2': + commands.append('switchport') + elif mode == 'layer3': + commands.append('no switchport') + + if admin_state == 'up': + commands.append('no shutdown') + elif admin_state == 'down': + commands.append('shutdown') + + if ip_forward == 'enable': + commands.append('ip forward') + elif ip_forward == 'disable': + commands.append('no ip forward') + + if fabric_forwarding_anycast_gateway is True: + commands.append('fabric forwarding mode anycast-gateway') + + elif fabric_forwarding_anycast_gateway is False: + commands.append('no fabric forwarding mode anycast-gateway') + + elif state == 'default': + if is_default is False: + commands.append('default interface {0}'.format(name)) + elif is_default == 'DNE': + module.exit_json(msg='interface you are trying to default does not exist') + + return commands, commands2 + + +def map_params_to_obj(module): + obj = [] + aggregate = module.params.get('aggregate') + if aggregate: + for item in aggregate: + for key in item: + if item.get(key) is None: + item[key] = module.params[key] + + d = item.copy() + name = d['name'] + d['name'] = normalize_interface(name) + obj.append(d) + else: - return 'unknown' + obj.append({ + 'name': normalize_interface(module.params['name']), + 'description': module.params['description'], + 'speed': module.params['speed'], + 'mode': module.params['mode'], + 'mtu': module.params['mtu'], + 'duplex': module.params['duplex'], + 'ip_forward': module.params['ip_forward'], + 'fabric_forwarding_anycast_gateway': module.params['fabric_forwarding_anycast_gateway'], + 'admin_state': module.params['admin_state'], + 'state': module.params['state'], + 'interface_type': module.params['interface_type'], + 'tx_rate': module.params['tx_rate'], + 'rx_rate': module.params['rx_rate'], + 'neighbors': module.params['neighbors'] + }) + + return obj -def get_manual_interface_attributes(interface, module): - """Gets admin state and description of a SVI interface. Hack due to API. - Args: - interface (str): full name of SVI interface, i.e. vlan10 - Returns: - dictionary that has two k/v pairs: admin_state & description - if not an svi, returns None - """ +def map_config_to_obj(want, module): + objs = list() - if get_interface_type(interface) == 'svi': - command = 'show run interface {0} all'.format(interface) + for w in want: + obj = dict(name=None, description=None, admin_state=None, speed=None, + mtu=None, mode=None, duplex=None, interface_type=None, + ip_forward=None, fabric_forwarding_anycast_gateway=None) + + command = 'show interface {0}'.format(w['name']) try: - # body = run_commands(module, [command])[0] body = execute_show_command(command, module)[0] except IndexError: - return None + return list() if body: - command_list = body.split('\n') - desc = None - admin_state = 'down' - for each in command_list: - if 'description' in each: - desc = each.lstrip().split("description")[1].lstrip() - elif 'no shutdown' in each: - admin_state = 'up' + try: + interface_table = body['TABLE_interface']['ROW_interface'] + except KeyError: + return list() - return dict(description=desc, admin_state=admin_state) - else: - return None + if interface_table: + 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(w['name']) + + if intf_type in ['portchannel', 'ethernet']: + if not interface_table.get('eth_mode'): + obj['mode'] = 'layer3' + + if intf_type == 'ethernet': + obj['name'] = normalize_interface(interface_table.get('interface')) + obj['admin_state'] = interface_table.get('admin_state') + obj['description'] = interface_table.get('desc') + obj['mtu'] = int(interface_table.get('eth_mtu')) + obj['duplex'] = interface_table.get('eth_duplex') + speed = interface_table.get('eth_speed') + if 'auto' in speed: + obj['speed'] = speed + else: + obj['speed'] = int(speed.split()[0]) + mode = interface_table.get('eth_mode') + if mode in ('access', 'trunk'): + obj['mode'] = 'layer2' + elif mode in ('routed', 'layer3'): + obj['mode'] = 'layer3' + + command = 'show run interface {0}'.format(obj['name']) + body = execute_show_command(command, module)[0] + if 'ip forward' in body: + obj['ip_forward'] = 'enable' + else: + obj['ip_forward'] = 'disable' + if 'fabric forwarding mode anycast-gateway' in body: + obj['fabric_forwarding_anycast_gateway'] = True + else: + obj['fabric_forwarding_anycast_gateway'] = False + + elif intf_type == 'svi': + obj['name'] = normalize_interface(interface_table.get('interface')) + attributes = get_vlan_interface_attributes(obj['name'], intf_type, module) + obj['admin_state'] = str(attributes.get('admin_state', + 'nxapibug')) + obj['description'] = str(attributes.get('description', + 'nxapi_bug')) + + command = 'show run interface {0}'.format(obj['name']) + body = execute_show_command(command, module)[0] + if 'ip forward' in body: + obj['ip_forward'] = 'enable' + else: + obj['ip_forward'] = 'disable' + if 'fabric forwarding mode anycast-gateway' in body: + obj['fabric_forwarding_anycast_gateway'] = True + else: + obj['fabric_forwarding_anycast_gateway'] = False + + elif intf_type in ('loopback', 'management', 'nve'): + obj['name'] = normalize_interface(interface_table.get('interface')) + obj['admin_state'] = interface_table.get('admin_state') + obj['description'] = interface_table.get('desc') + + elif intf_type == 'portchannel': + obj['name'] = normalize_interface(interface_table.get('interface')) + obj['admin_state'] = interface_table.get('admin_state') + obj['description'] = interface_table.get('desc') + obj['mode'] = interface_table.get('eth_mode') + + objs.append(obj) + + return objs -def get_interface(intf, module): - """Gets current config/state of interface - Args: - intf (string): full name of interface, i.e. Ethernet1/1, loopback10, - port-channel20, vlan20 - Returns: - dictionary that has relevant config/state data about the given - interface based on the type of interface it is - """ - base_key_map = { - 'interface': 'interface', - 'admin_state': 'admin_state', - 'desc': 'description', - } - mode_map = { - 'eth_mode': 'mode' - } - mtu_map = { - 'eth_mtu': 'mtu' - } - loop_map = { - 'state': 'admin_state' - } - svi_map = { - 'svi_admin_state': 'admin_state', - 'desc': 'description' - } - mode_value_map = { - "mode": { - "access": "layer2", - "trunk": "layer2", - "routed": "layer3", - "layer3": "layer3" - } - } +def check_declarative_intent_params(module, want): + failed_conditions = [] + have_neighbors = None + for w in want: + want_tx_rate = w.get('tx_rate') + want_rx_rate = w.get('rx_rate') + want_neighbors = w.get('neighbors') - key_map = {} - interface = {} + time.sleep(module.params['delay']) - command = 'show interface {0}'.format(intf) - try: - body = execute_show_command(command, module)[0] - except IndexError: - return {} - if body: - try: - interface_table = body['TABLE_interface']['ROW_interface'] - except KeyError: - return {} - if interface_table: - 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']: - if not interface_table.get('eth_mode'): - interface_table['eth_mode'] = 'layer3' - - if intf_type == 'ethernet': - key_map.update(base_key_map) - key_map.update(mode_map) - key_map.update(mtu_map) - temp_dict = apply_key_map(key_map, interface_table) - temp_dict = apply_value_map(mode_value_map, temp_dict) - interface.update(temp_dict) - - elif intf_type == 'svi': - key_map.update(svi_map) - temp_dict = apply_key_map(key_map, interface_table) - interface.update(temp_dict) - attributes = get_manual_interface_attributes(intf, module) - interface['admin_state'] = str(attributes.get('admin_state', - 'nxapibug')) - interface['description'] = str(attributes.get('description', - 'nxapi_bug')) - command = 'show run interface {0}'.format(intf) - body = execute_show_command(command, module)[0] - if 'ip forward' in body: - interface['ip_forward'] = 'enable' - else: - interface['ip_forward'] = 'disable' - if 'fabric forwarding mode anycast-gateway' in body: - interface['fabric_forwarding_anycast_gateway'] = True - else: - interface['fabric_forwarding_anycast_gateway'] = False - - elif intf_type == 'loopback': - key_map.update(base_key_map) - key_map.pop('admin_state') - key_map.update(loop_map) - temp_dict = apply_key_map(key_map, interface_table) - if not temp_dict.get('description'): - temp_dict['description'] = "None" - interface.update(temp_dict) - - elif intf_type == 'management': - key_map.update(base_key_map) - temp_dict = apply_key_map(key_map, interface_table) - interface.update(temp_dict) - - elif intf_type == 'portchannel': - key_map.update(base_key_map) - key_map.update(mode_map) - temp_dict = apply_key_map(key_map, interface_table) - temp_dict = apply_value_map(mode_value_map, temp_dict) - if not temp_dict.get('description'): - temp_dict['description'] = "None" - interface.update(temp_dict) - - elif intf_type == 'nve': - key_map.update(base_key_map) - temp_dict = apply_key_map(key_map, interface_table) - if not temp_dict.get('description'): - temp_dict['description'] = "None" - interface.update(temp_dict) - - return interface - - -def get_intf_args(interface): - intf_type = get_interface_type(interface) - - arguments = ['admin_state', 'description'] - - if intf_type in ['ethernet', 'portchannel']: - arguments.extend(['mode']) - arguments.extend(['mtu']) - if intf_type == 'svi': - arguments.extend(['ip_forward', 'fabric_forwarding_anycast_gateway']) - - return arguments - - -def get_interfaces_dict(module): - """Gets all active interfaces on a given switch - Returns: - dictionary with interface type (ethernet,svi,loop,portchannel) as the - keys. Each value is a list of interfaces of given interface (key) - type. - """ - command = 'show interface' - try: - body = execute_show_command(command, module)[0] - except IndexError: - return {} - - interfaces = { - 'ethernet': [], - 'svi': [], - 'loopback': [], - 'management': [], - 'portchannel': [], - 'nve': [], - 'unknown': [] - } - - if body: - interface_list = body['TABLE_interface']['ROW_interface'] - for index in interface_list: - intf = index['interface'] - intf_type = get_interface_type(intf) - - interfaces[intf_type].append(intf) - - return interfaces - - -def normalize_interface(if_name): - """Return the normalized interface name - """ - def _get_number(if_name): - digits = '' - for char in if_name: - if char.isdigit() or char == '/': - digits += char - return digits - - if if_name.lower().startswith('et'): - if_type = 'Ethernet' - elif if_name.lower().startswith('vl'): - if_type = 'Vlan' - elif if_name.lower().startswith('lo'): - if_type = 'loopback' - elif if_name.lower().startswith('po'): - if_type = 'port-channel' - elif if_name.lower().startswith('nv'): - if_type = 'nve' - else: - if_type = None - - number_list = if_name.split(' ') - if len(number_list) == 2: - number = number_list[-1].strip() - else: - number = _get_number(if_name) - - if if_type: - proper_interface = if_type + number - else: - proper_interface = if_name - - return proper_interface - - -def apply_key_map(key_map, table): - new_dict = {} - for key, value in table.items(): - new_key = key_map.get(key) - if new_key: - value = table.get(key) - if value: - new_dict[new_key] = str(value) - else: - new_dict[new_key] = value - return new_dict - - -def apply_value_map(value_map, resource): - for key, value in value_map.items(): - resource[key] = value[resource.get(key)] - return resource - - -def get_interface_config_commands(interface, intf, existing): - """Generates list of commands to configure on device - Args: - interface (str): k/v pairs in the form of a set that should - be configured on the device - intf (str): full name of interface, i.e. Ethernet1/1 - Returns: - list: ordered list of commands to be sent to device - """ - - commands = [] - desc = interface.get('description') - if desc: - commands.append('description {0}'.format(desc)) - - mode = interface.get('mode') - if mode: - if mode == 'layer2': - command = 'switchport' - elif mode == 'layer3': - command = 'no switchport' - commands.append(command) - - mtu = interface.get('mtu') - if mtu != 'None': - commands.append('mtu {0}'.format(mtu)) - - if 'mtu None' in commands: - commands.pop() - - admin_state = interface.get('admin_state') - if admin_state: - command = get_admin_state(interface, intf, admin_state) - commands.append(command) - - ip_forward = interface.get('ip_forward') - if ip_forward: - if ip_forward == 'enable': - commands.append('ip forward') + cmd = [{'command': 'show interface {0}'.format(w['name']), 'output': 'text'}] + output = run_commands(module, cmd, check_rc=False) + if output: + out = output[0] else: - commands.append('no ip forward') + out = '' + if want_tx_rate: + match = re.search(r'output rate (\d+)', out, re.M) + have_tx_rate = None - fabric_forwarding_anycast_gateway = interface.get( - 'fabric_forwarding_anycast_gateway') - if fabric_forwarding_anycast_gateway is not None: - if fabric_forwarding_anycast_gateway is True: - commands.append('fabric forwarding mode anycast-gateway') - elif fabric_forwarding_anycast_gateway is False: - commands.append('no fabric forwarding mode anycast-gateway') + if match: + have_tx_rate = match.group(1) - if commands: - commands.insert(0, 'interface {0}'.format(intf)) + if have_tx_rate is None or not conditional(want_tx_rate, have_tx_rate.strip(), cast=int): + failed_conditions.append('tx_rate ' + want_tx_rate) - return commands + if want_rx_rate: + match = re.search(r'input rate (\d+)', out, re.M) + have_rx_rate = None + if match: + have_rx_rate = match.group(1) -def get_admin_state(interface, intf, admin_state): - command = '' - if admin_state == 'up': - command = 'no shutdown' - elif admin_state == 'down': - command = 'shutdown' - return command + if have_rx_rate is None or not conditional(want_rx_rate, have_rx_rate.strip(), cast=int): + failed_conditions.append('rx_rate ' + want_rx_rate) + if want_neighbors: + have_host = [] + have_port = [] + if have_neighbors is None: + cmd = [{'command': 'show lldp neighbors interface {0} detail'.format(w['name']), 'output': 'text'}] + output = run_commands(module, cmd, check_rc=False) + if output: + have_neighbors = output[0] + else: + have_neighbors = '' + if have_neighbors and 'Total entries displayed: 0' not in have_neighbors: + for line in have_neighbors.strip().split('\n'): + if line.startswith('Port Description'): + have_port.append(line.split(': ')[1]) + if line.startswith('System Name'): + have_host.append(line.split(': ')[1]) -def get_proposed(existing, normalized_interface, args): + for item in want_neighbors: + host = item.get('host') + port = item.get('port') + if host and host not in have_host: + failed_conditions.append('host ' + host) + if port and port not in have_port: + failed_conditions.append('port ' + port) - # gets proper params that are allowed based on interface type - allowed_params = get_intf_args(normalized_interface) - - proposed = {} - - # retrieves proper interface params from args (user defined params) - for param in allowed_params: - temp = args.get(param) - if temp is not None: - proposed[param] = temp - - return proposed - - -def smart_existing(module, intf_type, normalized_interface): - # 7K BUG MAY CAUSE THIS TO FAIL - - all_interfaces = get_interfaces_dict(module) - if normalized_interface in all_interfaces[intf_type]: - existing = get_interface(normalized_interface, module) - is_default = is_default_interface(normalized_interface, module) - else: - if (intf_type in ['loopback', 'portchannel', 'svi', 'nve'] or - intf_type == 'ethernet' and "." in normalized_interface): - existing = {} - is_default = 'DNE' - elif intf_type == 'ethernet': - module.fail_json(msg='Invalid Ethernet interface provided.', - interface=normalized_interface) - return existing, is_default - - -def execute_show_command(command, module): - if 'show run' not in command: - output = 'json' - else: - output = 'text' - cmds = [{ - 'command': command, - 'output': output, - }] - - body = run_commands(module, cmds) - if body and "Invalid" in body[0]: - return [] - else: - return body - - -def flatten_list(command_lists): - flat_command_list = [] - for command in command_lists: - if isinstance(command, list): - flat_command_list.extend(command) - else: - flat_command_list.append(command) - return flat_command_list - - -def get_interface_type_removed_cmds(interfaces): - commands = [] - - for interface in interfaces: - if interface != 'Vlan1': - commands.append('no interface {0}'.format(interface)) - - return commands + return failed_conditions def main(): - - argument_spec = dict( - interface=dict(required=False,), - admin_state=dict(default='up', choices=['up', 'down'], required=False), - description=dict(required=False, default=None), - mode=dict(choices=['layer2', 'layer3'], required=False), - mtu=dict(type='int', required=False), - interface_type=dict(required=False, choices=['loopback', 'portchannel', 'svi', 'nve']), - ip_forward=dict(required=False, choices=['enable', 'disable']), - fabric_forwarding_anycast_gateway=dict(required=False, type='bool'), - state=dict(choices=['absent', 'present', 'default'], default='present', required=False) + """ main entry point for module execution + """ + neighbors_spec = dict( + host=dict(), + port=dict() ) + element_spec = dict( + name=dict(aliases=['interface']), + admin_state=dict(default='up', choices=['up', 'down']), + description=dict(), + speed=dict(), + mode=dict(choices=['layer2', 'layer3']), + mtu=dict(), + duplex=dict(choices=['full', 'half', 'auto']), + interface_type=dict(choices=['loopback', 'portchannel', 'svi', 'nve']), + ip_forward=dict(choices=['enable', 'disable']), + fabric_forwarding_anycast_gateway=dict(type='bool'), + tx_rate=dict(), + rx_rate=dict(), + neighbors=dict(type='list', elements='dict', options=neighbors_spec), + delay=dict(default=10, type='int'), + state=dict(choices=['absent', 'present', 'default'], default='present') + ) + + aggregate_spec = deepcopy(element_spec) + aggregate_spec['name'] = dict(required=True) + + # remove default in aggregate spec, to handle common arguments + remove_default_spec(aggregate_spec) + + argument_spec = dict( + aggregate=dict(type='list', elements='dict', options=aggregate_spec, + mutually_exclusive=[['name', 'interface_type']]) + ) + + argument_spec.update(element_spec) argument_spec.update(nxos_argument_spec) + required_one_of = [['name', 'aggregate']] + mutually_exclusive = [['name', 'aggregate'], + ['name', 'interface_type']] + module = AnsibleModule(argument_spec=argument_spec, - mutually_exclusive=[['interface', 'interface_type']], + required_one_of=required_one_of, + mutually_exclusive=mutually_exclusive, supports_check_mode=True) - warnings = list() - check_args(module, warnings) - results = dict(changed=False, warnings=warnings) + result = {'changed': False} + if warnings: + result['warnings'] = warnings - interface = module.params['interface'] - interface_type = module.params['interface_type'] - admin_state = module.params['admin_state'] - description = module.params['description'] - mode = module.params['mode'] - mtu = str(module.params['mtu']) - ip_forward = module.params['ip_forward'] - fabric_forwarding_anycast_gateway = module.params['fabric_forwarding_anycast_gateway'] - state = module.params['state'] - - if interface: - interface = interface.lower() - intf_type = get_interface_type(interface) - normalized_interface = normalize_interface(interface) - - if normalized_interface == 'Vlan1' and state == 'absent': - module.fail_json(msg='ERROR: CANNOT REMOVE VLAN 1!') - - if intf_type == 'nve': - if description or mode: - module.fail_json(msg='description and mode params are not ' - 'supported in this module. Use ' - 'nxos_vxlan_vtep instead.') - if (ip_forward or fabric_forwarding_anycast_gateway) and intf_type != 'svi': - module.fail_json(msg='The ip_forward and ' - 'fabric_forwarding_anycast_gateway features ' - ' are only available for SVIs.') - - args = dict(interface=interface, admin_state=admin_state, - description=description, mode=mode, mtu=mtu, ip_forward=ip_forward, - fabric_forwarding_anycast_gateway=fabric_forwarding_anycast_gateway) - if (normalized_interface.startswith('Eth') or normalized_interface.startswith('po'))\ - and "." in normalized_interface: - args["mode"] = None - - if intf_type == 'unknown': - module.fail_json(msg='unknown interface type found-1', - interface=interface) - - existing, is_default = smart_existing(module, intf_type, normalized_interface) - proposed = get_proposed(existing, normalized_interface, args) - else: - intf_type = normalized_interface = interface_type - proposed = dict(interface_type=interface_type) + want = map_params_to_obj(module) + have = map_config_to_obj(want, module) commands = [] - if interface: - delta = dict() + commands1, commands2 = map_obj_to_commands((want, have), module) + commands.extend(commands1) - if state == 'absent': - if intf_type in ['svi', 'loopback', 'portchannel', 'nve']: - if is_default != 'DNE': - cmds = ['no interface {0}'.format(normalized_interface)] - commands.append(cmds) - elif intf_type in ['ethernet'] and is_default is False: - if "." in normalized_interface: - cmds = ['no interface {0}'.format(normalized_interface)] - else: - cmds = ['default interface {0}'.format(normalized_interface)] - commands.append(cmds) - elif state == 'present': - if not existing: - cmds = get_interface_config_commands(proposed, normalized_interface, existing) - commands.append(cmds) - else: - delta = dict(set(proposed.items()).difference(existing.items())) - if delta: - cmds = get_interface_config_commands(delta, normalized_interface, existing) - commands.append(cmds) - elif state == 'default': - if is_default is False: - cmds = ['default interface {0}'.format(normalized_interface)] - commands.append(cmds) - elif is_default == 'DNE': - module.exit_json(msg='interface you are trying to default does not exist') - elif interface_type: - if state == 'present': - module.fail_json(msg='The interface_type param can be used only with state absent.') + if commands: + if not module.check_mode: + load_config(module, commands) + result['changed'] = True + # if the mode changes from L2 to L3, the admin state + # seems to change after the API call, so adding a second API + # call to ensure it's in the desired state. + if commands2: + load_config(module, commands2) + commands.extend(commands2) + commands = [cmd for cmd in commands if cmd != 'configure'] + result['commands'] = commands - existing = get_interfaces_dict(module)[interface_type] - cmds = get_interface_type_removed_cmds(existing) - commands.append(cmds) + if result['changed']: + failed_conditions = check_declarative_intent_params(module, want) - cmds = flatten_list(commands) - end_state = existing + if failed_conditions: + msg = 'One or more conditional statements have not been satisfied' + module.fail_json(msg=msg, failed_conditions=failed_conditions) - if cmds: - if module.check_mode: - module.exit_json(changed=True, commands=cmds) - else: - load_config(module, cmds) - results['changed'] = True - if module.params['interface']: - if delta.get('mode'): - # if the mode changes from L2 to L3, the admin state - # seems to change after the API call, so adding a second API - # call to ensure it's in the desired state. - admin_state = delta.get('admin_state') or admin_state - c1 = 'interface {0}'.format(normalized_interface) - c2 = get_admin_state(delta, normalized_interface, admin_state) - cmds2 = [c1, c2] - load_config(module, cmds2) - cmds.extend(cmds2) - end_state, is_default = smart_existing(module, intf_type, - normalized_interface) - cmds = [cmd for cmd in cmds if cmd != 'configure'] - - results['commands'] = cmds - - module.exit_json(**results) + module.exit_json(**result) if __name__ == '__main__': diff --git a/test/integration/targets/nxos_interface/tests/common/intent.yaml b/test/integration/targets/nxos_interface/tests/common/intent.yaml new file mode 100644 index 00000000000..6367e9b1749 --- /dev/null +++ b/test/integration/targets/nxos_interface/tests/common/intent.yaml @@ -0,0 +1,63 @@ +- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_interface intent test" + +- set_fact: testint1="{{ nxos_int1 }}" +- set_fact: testint2="{{ nxos_int2 }}" + +- name: "Setup: Put interfaces into a default state" + nxos_config: + lines: + - "default interface {{ testint1 }}" + - "default interface {{ testint2 }}" + provider: "{{ connection }}" + ignore_errors: yes + +- name: Check intent arguments + nxos_interface: + name: "{{ testint2 }}" + admin_state: up + tx_rate: ge(0) + rx_rate: ge(0) + provider: "{{ connection }}" + register: result + +- assert: + that: + - "result.failed == false" + +- name: Check intent arguments (failed condition) + nxos_interface: + name: "{{ testint2 }}" + admin_state: down + tx_rate: gt(0) + rx_rate: lt(0) + provider: "{{ connection }}" + ignore_errors: yes + register: result + +- assert: + that: + - "result.failed == true" + - "'tx_rate gt(0)' in result.failed_conditions" + - "'rx_rate lt(0)' in result.failed_conditions" + +- name: aggregate definition of interface + nxos_interface: + aggregate: + - { name: "{{ testint1 }}", description: "Test aggregation on first interface" } + - { name: "{{ testint2 }}", mode: layer3 } + provider: "{{ connection }}" + register: result + +- assert: + that: + - "result.changed == true" + +- name: "TearDown: Put interfaces into a default state" + nxos_config: + lines: + - "default interface {{ testint1 }}" + - "default interface {{ testint2 }}" + provider: "{{ connection }}" + ignore_errors: yes + +- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_interface intent test" diff --git a/test/integration/targets/nxos_interface/tests/common/sanity.yaml b/test/integration/targets/nxos_interface/tests/common/sanity.yaml index e5bcfbcb38d..fe623ff7b58 100644 --- a/test/integration/targets/nxos_interface/tests/common/sanity.yaml +++ b/test/integration/targets/nxos_interface/tests/common/sanity.yaml @@ -33,7 +33,7 @@ interface: "{{ testint }}" mode: layer3 description: 'Configured by Ansible - Layer3' - admin_state: 'up' + admin_state: up state: present provider: "{{ connection }}" register: result @@ -55,7 +55,7 @@ interface: "{{ testint }}" mode: layer2 description: 'Configured by Ansible - Layer2' - admin_state: 'down' + admin_state: down state: present provider: "{{ connection }}" register: result diff --git a/test/units/modules/network/nxos/fixtures/nxos_interface/show_interface b/test/units/modules/network/nxos/fixtures/nxos_interface/show_interface deleted file mode 100644 index ec23f11eb1d..00000000000 --- a/test/units/modules/network/nxos/fixtures/nxos_interface/show_interface +++ /dev/null @@ -1,846 +0,0 @@ -{ - "TABLE_interface": { - "ROW_interface": [ - { - "interface": "mgmt0", - "state": "up", - "admin_state": "up", - "eth_hw_desc": "GigabitEthernet", - "eth_hw_addr": "e4c7.220c.4fe5", - "eth_bia_addr": "e4c7.220c.4fe5", - "eth_ip_addr": "10.122.84.99", - "eth_ip_mask": 24, - "eth_ip_prefix": "10.122.84.0", - "eth_mtu": "1500", - "eth_bw": 1000000, - "eth_dly": 10, - "eth_reliability": "255", - "eth_txload": "1", - "eth_rxload": "1", - "eth_encap": "ARPA", - "medium": "broadcast", - "eth_mode": "routed", - "eth_duplex": "full", - "eth_speed": "1000 Mb/s", - "eth_autoneg": "on", - "eth_mdix": "off", - "eth_ethertype": "0x0000", - "vdc_lvl_in_avg_bytes": 47448, - "vdc_lvl_in_avg_pkts": 60, - "vdc_lvl_out_avg_bytes": 184968, - "vdc_lvl_out_avg_pkts": 59, - "vdc_lvl_in_pkts": 350043, - "vdc_lvl_in_ucast": 344955, - "vdc_lvl_in_mcast": 4700, - "vdc_lvl_in_bcast": 388, - "vdc_lvl_in_bytes": 108044389, - "vdc_lvl_out_pkts": 212806, - "vdc_lvl_out_ucast": 212606, - "vdc_lvl_out_mcast": 192, - "vdc_lvl_out_bcast": 8, - "vdc_lvl_out_bytes": 75961919, - "mgmt_in_pkts": 360175, - "mgmt_in_bytes": 108055870, - "mgmt_in_mcast": 11091, - "mgmt_in_compressed": 0, - "mgmt_in_errors": 0, - "mgmt_in_frame": 0, - "mgmt_in_overrun": 4072, - "mgmt_in_fifo": 0, - "mgmt_out_pkts": 212757, - "mgmt_out_bytes": 75100855, - "mgmt_out_underruns": 0, - "mgmt_out_errors": 0, - "mgmt_out_collisions": 0, - "mgmt_out_fifo": 0, - "mgmt_out_carrier": 0 - }, - { - "interface": "Ethernet2/1", - "state": "down", - "state_rsn_desc": "Administratively down", - "admin_state": "down", - "share_state": "Dedicated", - "eth_hw_desc": "1000 Ethernet", - "eth_hw_addr": "c84c.75fc.7c70", - "eth_bia_addr": "c84c.75fc.7c70", - "eth_mtu": "1500", - "eth_bw": 1000000, - "eth_dly": 10, - "eth_reliability": "255", - "eth_txload": "1", - "eth_rxload": "1", - "eth_encap": "ARPA", - "medium": "broadcast", - "eth_mode": "access", - "eth_duplex": "auto", - "eth_speed": "auto-speed", - "eth_media": "1G", - "eth_beacon": "off", - "eth_autoneg": "on", - "eth_in_flowctrl": "off", - "eth_out_flowctrl": "off", - "eth_mdix": "off", - "eth_ratemode": "dedicated", - "eth_swt_monitor": "off", - "eth_ethertype": "0x8100", - "eth_eee_state": "n/a", - "eth_link_flapped": "never", - "eth_clear_counters": "00:15:20", - "eth_reset_cntr": 0, - "eth_load_interval1_rx": 30, - "eth_inrate1_bits": 0, - "eth_inrate1_pkts": 0, - "eth_load_interval1_tx": 30, - "eth_outrate1_bits": 0, - "eth_outrate1_pkts": 0, - "eth_inrate1_summary_bits": "0 bps", - "eth_inrate1_summary_pkts": "0 pps", - "eth_outrate1_summary_bits": "0 bps", - "eth_outrate1_summary_pkts": "0 pps", - "eth_load_interval2_rx": 300, - "eth_inrate2_bits": 0, - "eth_inrate2_pkts": 0, - "eth_load_interval2_tx": 300, - "eth_outrate2_bits": 0, - "eth_outrate2_pkts": 0, - "eth_inrate2_summary_bits": "0 bps", - "eth_inrate2_summary_pkts": "0 pps", - "eth_outrate2_summary_bits": "0 bps", - "eth_outrate2_summary_pkts": "0 pps", - "eth_inucast": 4, - "eth_inmcast": 0, - "eth_inbcast": 0, - "eth_inpkts": 4, - "eth_inbytes": 2496, - "eth_jumbo_inpkts": 0, - "eth_storm_supp": 0, - "eth_runts": 0, - "eth_giants": 0, - "eth_crc": 0, - "eth_nobuf": 0, - "eth_inerr": 0, - "eth_frame": 0, - "eth_overrun": 0, - "eth_underrun": 0, - "eth_ignored": 0, - "eth_watchdog": 0, - "eth_bad_eth": 0, - "eth_bad_proto": 0, - "eth_in_ifdown_drops": 0, - "eth_dribble": 0, - "eth_indiscard": 0, - "eth_inpause": 0, - "eth_outucast": 4, - "eth_outmcast": 0, - "eth_outbcast": 0, - "eth_outpkts": 4, - "eth_outbytes": 2496, - "eth_jumbo_outpkts": 0, - "eth_outerr": 0, - "eth_coll": 0, - "eth_deferred": 0, - "eth_latecoll": 0, - "eth_lostcarrier": 0, - "eth_nocarrier": 0, - "eth_babbles": 0, - "eth_outdiscard": 0, - "eth_outpause": 0 - }, - { - "interface": "Ethernet2/2", - "state": "down", - "state_rsn_desc": "Administratively down", - "admin_state": "down", - "share_state": "Dedicated", - "eth_hw_desc": "1000 Ethernet", - "eth_hw_addr": "0026.980b.1041", - "eth_bia_addr": "c84c.75fc.7c71", - "eth_mtu": "1500", - "eth_bw": 1000000, - "eth_dly": 10, - "eth_reliability": "255", - "eth_txload": "1", - "eth_rxload": "1", - "eth_encap": "ARPA", - "medium": "broadcast", - "eth_mode": "routed", - "eth_duplex": "auto", - "eth_speed": "auto-speed", - "eth_media": "1G", - "eth_beacon": "off", - "eth_autoneg": "on", - "eth_in_flowctrl": "off", - "eth_out_flowctrl": "off", - "eth_mdix": "off", - "eth_ratemode": "dedicated", - "eth_swt_monitor": "off", - "eth_ethertype": "0x8100", - "eth_eee_state": "n/a", - "eth_link_flapped": "never", - "eth_clear_counters": "00:15:20", - "eth_reset_cntr": 0, - "eth_load_interval1_rx": 30, - "eth_inrate1_bits": 0, - "eth_inrate1_pkts": 0, - "eth_load_interval1_tx": 30, - "eth_outrate1_bits": 0, - "eth_outrate1_pkts": 0, - "eth_inrate1_summary_bits": "0 bps", - "eth_inrate1_summary_pkts": "0 pps", - "eth_outrate1_summary_bits": "0 bps", - "eth_outrate1_summary_pkts": "0 pps", - "eth_load_interval2_rx": 300, - "eth_inrate2_bits": 0, - "eth_inrate2_pkts": 0, - "eth_load_interval2_tx": 300, - "eth_outrate2_bits": 0, - "eth_outrate2_pkts": 0, - "eth_inrate2_summary_bits": "0 bps", - "eth_inrate2_summary_pkts": "0 pps", - "eth_outrate2_summary_bits": "0 bps", - "eth_outrate2_summary_pkts": "0 pps", - "eth_l3in_ucastpkts": 0, - "eth_l3in_ucastbytes": 0, - "eth_l3in_mcastpkts": 0, - "eth_l3in_mcastbytes": 0, - "eth_l3out_ucastpkts": 0, - "eth_l3out_ucastbytes": 0, - "eth_l3out_mcastpkts": 0, - "eth_l3out_mcastbytes": 0, - "eth_inucast": 4, - "eth_inmcast": 0, - "eth_inbcast": 0, - "eth_inpkts": 4, - "eth_inbytes": 2496, - "eth_jumbo_inpkts": 0, - "eth_storm_supp": 0, - "eth_runts": 0, - "eth_giants": 0, - "eth_crc": 0, - "eth_nobuf": 0, - "eth_inerr": 0, - "eth_frame": 0, - "eth_overrun": 0, - "eth_underrun": 0, - "eth_ignored": 0, - "eth_watchdog": 0, - "eth_bad_eth": 0, - "eth_bad_proto": 0, - "eth_in_ifdown_drops": 0, - "eth_dribble": 0, - "eth_indiscard": 0, - "eth_inpause": 0, - "eth_outucast": 4, - "eth_outmcast": 0, - "eth_outbcast": 0, - "eth_outpkts": 4, - "eth_outbytes": 2496, - "eth_jumbo_outpkts": 0, - "eth_outerr": 0, - "eth_coll": 0, - "eth_deferred": 0, - "eth_latecoll": 0, - "eth_lostcarrier": 0, - "eth_nocarrier": 0, - "eth_babbles": 0, - "eth_outdiscard": 0, - "eth_outpause": 0 - }, - { - "interface": "Ethernet2/3", - "state": "down", - "state_rsn_desc": "Administratively down", - "admin_state": "down", - "share_state": "Dedicated", - "eth_hw_desc": "1000 Ethernet", - "eth_hw_addr": "0026.980b.1041", - "eth_bia_addr": "c84c.75fc.7c72", - "eth_mtu": "1500", - "eth_bw": 1000000, - "eth_dly": 10, - "eth_reliability": "255", - "eth_txload": "1", - "eth_rxload": "1", - "eth_encap": "ARPA", - "medium": "broadcast", - "eth_mode": "routed", - "eth_duplex": "auto", - "eth_speed": "auto-speed", - "eth_media": "1G", - "eth_beacon": "off", - "eth_autoneg": "on", - "eth_in_flowctrl": "off", - "eth_out_flowctrl": "off", - "eth_mdix": "off", - "eth_ratemode": "dedicated", - "eth_swt_monitor": "off", - "eth_ethertype": "0x8100", - "eth_eee_state": "n/a", - "eth_link_flapped": "never", - "eth_clear_counters": "00:15:20", - "eth_reset_cntr": 0, - "eth_load_interval1_rx": 30, - "eth_inrate1_bits": 0, - "eth_inrate1_pkts": 0, - "eth_load_interval1_tx": 30, - "eth_outrate1_bits": 0, - "eth_outrate1_pkts": 0, - "eth_inrate1_summary_bits": "0 bps", - "eth_inrate1_summary_pkts": "0 pps", - "eth_outrate1_summary_bits": "0 bps", - "eth_outrate1_summary_pkts": "0 pps", - "eth_load_interval2_rx": 300, - "eth_inrate2_bits": 0, - "eth_inrate2_pkts": 0, - "eth_load_interval2_tx": 300, - "eth_outrate2_bits": 0, - "eth_outrate2_pkts": 0, - "eth_inrate2_summary_bits": "0 bps", - "eth_inrate2_summary_pkts": "0 pps", - "eth_outrate2_summary_bits": "0 bps", - "eth_outrate2_summary_pkts": "0 pps", - "eth_l3in_ucastpkts": 0, - "eth_l3in_ucastbytes": 0, - "eth_l3in_mcastpkts": 0, - "eth_l3in_mcastbytes": 0, - "eth_l3out_ucastpkts": 0, - "eth_l3out_ucastbytes": 0, - "eth_l3out_mcastpkts": 0, - "eth_l3out_mcastbytes": 0, - "eth_inucast": 4, - "eth_inmcast": 0, - "eth_inbcast": 0, - "eth_inpkts": 4, - "eth_inbytes": 2496, - "eth_jumbo_inpkts": 0, - "eth_storm_supp": 0, - "eth_runts": 0, - "eth_giants": 0, - "eth_crc": 0, - "eth_nobuf": 0, - "eth_inerr": 0, - "eth_frame": 0, - "eth_overrun": 0, - "eth_underrun": 0, - "eth_ignored": 0, - "eth_watchdog": 0, - "eth_bad_eth": 0, - "eth_bad_proto": 0, - "eth_in_ifdown_drops": 0, - "eth_dribble": 0, - "eth_indiscard": 0, - "eth_inpause": 0, - "eth_outucast": 4, - "eth_outmcast": 0, - "eth_outbcast": 0, - "eth_outpkts": 4, - "eth_outbytes": 2496, - "eth_jumbo_outpkts": 0, - "eth_outerr": 0, - "eth_coll": 0, - "eth_deferred": 0, - "eth_latecoll": 0, - "eth_lostcarrier": 0, - "eth_nocarrier": 0, - "eth_babbles": 0, - "eth_outdiscard": 0, - "eth_outpause": 0 - }, - { - "interface": "Ethernet2/4", - "state": "down", - "state_rsn_desc": "Administratively down", - "admin_state": "down", - "share_state": "Dedicated", - "eth_hw_desc": "1000 Ethernet", - "eth_hw_addr": "0026.980b.1041", - "eth_bia_addr": "c84c.75fc.7c73", - "eth_mtu": "1500", - "eth_bw": 1000000, - "eth_dly": 10, - "eth_reliability": "255", - "eth_txload": "1", - "eth_rxload": "1", - "eth_encap": "ARPA", - "medium": "broadcast", - "eth_mode": "routed", - "eth_duplex": "auto", - "eth_speed": "auto-speed", - "eth_media": "1G", - "eth_beacon": "off", - "eth_autoneg": "on", - "eth_in_flowctrl": "off", - "eth_out_flowctrl": "off", - "eth_mdix": "off", - "eth_ratemode": "dedicated", - "eth_swt_monitor": "off", - "eth_ethertype": "0x8100", - "eth_eee_state": "n/a", - "eth_link_flapped": "never", - "eth_clear_counters": "00:15:20", - "eth_reset_cntr": 0, - "eth_load_interval1_rx": 30, - "eth_inrate1_bits": 0, - "eth_inrate1_pkts": 0, - "eth_load_interval1_tx": 30, - "eth_outrate1_bits": 0, - "eth_outrate1_pkts": 0, - "eth_inrate1_summary_bits": "0 bps", - "eth_inrate1_summary_pkts": "0 pps", - "eth_outrate1_summary_bits": "0 bps", - "eth_outrate1_summary_pkts": "0 pps", - "eth_load_interval2_rx": 300, - "eth_inrate2_bits": 0, - "eth_inrate2_pkts": 0, - "eth_load_interval2_tx": 300, - "eth_outrate2_bits": 0, - "eth_outrate2_pkts": 0, - "eth_inrate2_summary_bits": "0 bps", - "eth_inrate2_summary_pkts": "0 pps", - "eth_outrate2_summary_bits": "0 bps", - "eth_outrate2_summary_pkts": "0 pps", - "eth_l3in_ucastpkts": 0, - "eth_l3in_ucastbytes": 0, - "eth_l3in_mcastpkts": 0, - "eth_l3in_mcastbytes": 0, - "eth_l3out_ucastpkts": 0, - "eth_l3out_ucastbytes": 0, - "eth_l3out_mcastpkts": 0, - "eth_l3out_mcastbytes": 0, - "eth_inucast": 4, - "eth_inmcast": 0, - "eth_inbcast": 0, - "eth_inpkts": 4, - "eth_inbytes": 2496, - "eth_jumbo_inpkts": 0, - "eth_storm_supp": 0, - "eth_runts": 0, - "eth_giants": 0, - "eth_crc": 0, - "eth_nobuf": 0, - "eth_inerr": 0, - "eth_frame": 0, - "eth_overrun": 0, - "eth_underrun": 0, - "eth_ignored": 0, - "eth_watchdog": 0, - "eth_bad_eth": 0, - "eth_bad_proto": 0, - "eth_in_ifdown_drops": 0, - "eth_dribble": 0, - "eth_indiscard": 0, - "eth_inpause": 0, - "eth_outucast": 4, - "eth_outmcast": 0, - "eth_outbcast": 0, - "eth_outpkts": 4, - "eth_outbytes": 2496, - "eth_jumbo_outpkts": 0, - "eth_outerr": 0, - "eth_coll": 0, - "eth_deferred": 0, - "eth_latecoll": 0, - "eth_lostcarrier": 0, - "eth_nocarrier": 0, - "eth_babbles": 0, - "eth_outdiscard": 0, - "eth_outpause": 0 - }, - { - "interface": "Ethernet2/5", - "state": "down", - "state_rsn_desc": "Administratively down", - "admin_state": "down", - "share_state": "Dedicated", - "eth_hw_desc": "1000 Ethernet", - "eth_hw_addr": "0026.980b.1041", - "eth_bia_addr": "c84c.75fc.7c74", - "eth_mtu": "1500", - "eth_bw": 1000000, - "eth_dly": 10, - "eth_reliability": "255", - "eth_txload": "1", - "eth_rxload": "1", - "eth_encap": "ARPA", - "medium": "broadcast", - "eth_mode": "routed", - "eth_duplex": "auto", - "eth_speed": "auto-speed", - "eth_media": "1G", - "eth_beacon": "off", - "eth_autoneg": "on", - "eth_in_flowctrl": "off", - "eth_out_flowctrl": "off", - "eth_mdix": "off", - "eth_ratemode": "dedicated", - "eth_swt_monitor": "off", - "eth_ethertype": "0x8100", - "eth_eee_state": "n/a", - "eth_link_flapped": "never", - "eth_clear_counters": "00:15:20", - "eth_reset_cntr": 0, - "eth_load_interval1_rx": 30, - "eth_inrate1_bits": 0, - "eth_inrate1_pkts": 0, - "eth_load_interval1_tx": 30, - "eth_outrate1_bits": 0, - "eth_outrate1_pkts": 0, - "eth_inrate1_summary_bits": "0 bps", - "eth_inrate1_summary_pkts": "0 pps", - "eth_outrate1_summary_bits": "0 bps", - "eth_outrate1_summary_pkts": "0 pps", - "eth_load_interval2_rx": 300, - "eth_inrate2_bits": 0, - "eth_inrate2_pkts": 0, - "eth_load_interval2_tx": 300, - "eth_outrate2_bits": 0, - "eth_outrate2_pkts": 0, - "eth_inrate2_summary_bits": "0 bps", - "eth_inrate2_summary_pkts": "0 pps", - "eth_outrate2_summary_bits": "0 bps", - "eth_outrate2_summary_pkts": "0 pps", - "eth_l3in_ucastpkts": 0, - "eth_l3in_ucastbytes": 0, - "eth_l3in_mcastpkts": 0, - "eth_l3in_mcastbytes": 0, - "eth_l3out_ucastpkts": 0, - "eth_l3out_ucastbytes": 0, - "eth_l3out_mcastpkts": 0, - "eth_l3out_mcastbytes": 0, - "eth_inucast": 4, - "eth_inmcast": 0, - "eth_inbcast": 0, - "eth_inpkts": 4, - "eth_inbytes": 2496, - "eth_jumbo_inpkts": 0, - "eth_storm_supp": 0, - "eth_runts": 0, - "eth_giants": 0, - "eth_crc": 0, - "eth_nobuf": 0, - "eth_inerr": 0, - "eth_frame": 0, - "eth_overrun": 0, - "eth_underrun": 0, - "eth_ignored": 0, - "eth_watchdog": 0, - "eth_bad_eth": 0, - "eth_bad_proto": 0, - "eth_in_ifdown_drops": 0, - "eth_dribble": 0, - "eth_indiscard": 0, - "eth_inpause": 0, - "eth_outucast": 4, - "eth_outmcast": 0, - "eth_outbcast": 0, - "eth_outpkts": 4, - "eth_outbytes": 2496, - "eth_jumbo_outpkts": 0, - "eth_outerr": 0, - "eth_coll": 0, - "eth_deferred": 0, - "eth_latecoll": 0, - "eth_lostcarrier": 0, - "eth_nocarrier": 0, - "eth_babbles": 0, - "eth_outdiscard": 0, - "eth_outpause": 0 - }, - { - "interface": "Ethernet2/6", - "state": "down", - "state_rsn_desc": "SFP not inserted", - "admin_state": "down", - "share_state": "Dedicated", - "eth_hw_desc": "1000 Ethernet", - "eth_hw_addr": "0026.980b.1041", - "eth_bia_addr": "c84c.75fc.7c75", - "eth_mtu": "1500", - "eth_bw": 1000000, - "eth_dly": 10, - "eth_reliability": "255", - "eth_txload": "1", - "eth_rxload": "1", - "eth_encap": "ARPA", - "medium": "broadcast", - "eth_mode": "routed", - "eth_duplex": "auto", - "eth_speed": "auto-speed", - "eth_beacon": "off", - "eth_autoneg": "on", - "eth_in_flowctrl": "off", - "eth_out_flowctrl": "off", - "eth_mdix": "off", - "eth_swt_monitor": "off", - "eth_ethertype": "0x8100", - "eth_eee_state": "n/a", - "eth_link_flapped": "never", - "eth_clear_counters": "00:15:20", - "eth_reset_cntr": 0, - "eth_load_interval1_rx": 30, - "eth_inrate1_bits": 0, - "eth_inrate1_pkts": 0, - "eth_load_interval1_tx": 30, - "eth_outrate1_bits": 0, - "eth_outrate1_pkts": 0, - "eth_inrate1_summary_bits": "0 bps", - "eth_inrate1_summary_pkts": "0 pps", - "eth_outrate1_summary_bits": "0 bps", - "eth_outrate1_summary_pkts": "0 pps", - "eth_load_interval2_rx": 300, - "eth_inrate2_bits": 0, - "eth_inrate2_pkts": 0, - "eth_load_interval2_tx": 300, - "eth_outrate2_bits": 0, - "eth_outrate2_pkts": 0, - "eth_inrate2_summary_bits": "0 bps", - "eth_inrate2_summary_pkts": "0 pps", - "eth_outrate2_summary_bits": "0 bps", - "eth_outrate2_summary_pkts": "0 pps", - "eth_l3in_ucastpkts": 0, - "eth_l3in_ucastbytes": 0, - "eth_l3in_mcastpkts": 0, - "eth_l3in_mcastbytes": 0, - "eth_l3out_ucastpkts": 0, - "eth_l3out_ucastbytes": 0, - "eth_l3out_mcastpkts": 0, - "eth_l3out_mcastbytes": 0, - "eth_inucast": 4, - "eth_inmcast": 0, - "eth_inbcast": 0, - "eth_inpkts": 4, - "eth_inbytes": 2496, - "eth_jumbo_inpkts": 0, - "eth_storm_supp": 0, - "eth_runts": 0, - "eth_giants": 0, - "eth_crc": 0, - "eth_nobuf": 0, - "eth_inerr": 0, - "eth_frame": 0, - "eth_overrun": 0, - "eth_underrun": 0, - "eth_ignored": 0, - "eth_watchdog": 0, - "eth_bad_eth": 0, - "eth_bad_proto": 0, - "eth_in_ifdown_drops": 0, - "eth_dribble": 0, - "eth_indiscard": 0, - "eth_inpause": 0, - "eth_outucast": 4, - "eth_outmcast": 0, - "eth_outbcast": 0, - "eth_outpkts": 4, - "eth_outbytes": 2496, - "eth_jumbo_outpkts": 0, - "eth_outerr": 0, - "eth_coll": 0, - "eth_deferred": 0, - "eth_latecoll": 0, - "eth_lostcarrier": 0, - "eth_nocarrier": 0, - "eth_babbles": 0, - "eth_outdiscard": 0, - "eth_outpause": 0 - }, - { - "interface": "Ethernet2/7", - "state": "down", - "state_rsn_desc": "SFP not inserted", - "admin_state": "down", - "share_state": "Dedicated", - "eth_hw_desc": "1000 Ethernet", - "eth_hw_addr": "0026.980b.1041", - "eth_bia_addr": "c84c.75fc.7c76", - "eth_mtu": "1500", - "eth_bw": 1000000, - "eth_dly": 10, - "eth_reliability": "255", - "eth_txload": "1", - "eth_rxload": "1", - "eth_encap": "ARPA", - "medium": "broadcast", - "eth_mode": "routed", - "eth_duplex": "auto", - "eth_speed": "auto-speed", - "eth_beacon": "off", - "eth_autoneg": "on", - "eth_in_flowctrl": "off", - "eth_out_flowctrl": "off", - "eth_mdix": "off", - "eth_swt_monitor": "off", - "eth_ethertype": "0x8100", - "eth_eee_state": "n/a", - "eth_link_flapped": "never", - "eth_clear_counters": "00:15:20", - "eth_reset_cntr": 0, - "eth_load_interval1_rx": 30, - "eth_inrate1_bits": 0, - "eth_inrate1_pkts": 0, - "eth_load_interval1_tx": 30, - "eth_outrate1_bits": 0, - "eth_outrate1_pkts": 0, - "eth_inrate1_summary_bits": "0 bps", - "eth_inrate1_summary_pkts": "0 pps", - "eth_outrate1_summary_bits": "0 bps", - "eth_outrate1_summary_pkts": "0 pps", - "eth_load_interval2_rx": 300, - "eth_inrate2_bits": 0, - "eth_inrate2_pkts": 0, - "eth_load_interval2_tx": 300, - "eth_outrate2_bits": 0, - "eth_outrate2_pkts": 0, - "eth_inrate2_summary_bits": "0 bps", - "eth_inrate2_summary_pkts": "0 pps", - "eth_outrate2_summary_bits": "0 bps", - "eth_outrate2_summary_pkts": "0 pps", - "eth_l3in_ucastpkts": 0, - "eth_l3in_ucastbytes": 0, - "eth_l3in_mcastpkts": 0, - "eth_l3in_mcastbytes": 0, - "eth_l3out_ucastpkts": 0, - "eth_l3out_ucastbytes": 0, - "eth_l3out_mcastpkts": 0, - "eth_l3out_mcastbytes": 0, - "eth_inucast": 4, - "eth_inmcast": 0, - "eth_inbcast": 0, - "eth_inpkts": 4, - "eth_inbytes": 2496, - "eth_jumbo_inpkts": 0, - "eth_storm_supp": 0, - "eth_runts": 0, - "eth_giants": 0, - "eth_crc": 0, - "eth_nobuf": 0, - "eth_inerr": 0, - "eth_frame": 0, - "eth_overrun": 0, - "eth_underrun": 0, - "eth_ignored": 0, - "eth_watchdog": 0, - "eth_bad_eth": 0, - "eth_bad_proto": 0, - "eth_in_ifdown_drops": 0, - "eth_dribble": 0, - "eth_indiscard": 0, - "eth_inpause": 0, - "eth_outucast": 4, - "eth_outmcast": 0, - "eth_outbcast": 0, - "eth_outpkts": 4, - "eth_outbytes": 2496, - "eth_jumbo_outpkts": 0, - "eth_outerr": 0, - "eth_coll": 0, - "eth_deferred": 0, - "eth_latecoll": 0, - "eth_lostcarrier": 0, - "eth_nocarrier": 0, - "eth_babbles": 0, - "eth_outdiscard": 0, - "eth_outpause": 0 - }, - { - "interface": "Ethernet2/8", - "state": "down", - "state_rsn_desc": "SFP not inserted", - "admin_state": "down", - "share_state": "Dedicated", - "eth_hw_desc": "1000 Ethernet", - "eth_hw_addr": "0026.980b.1041", - "eth_bia_addr": "c84c.75fc.7c77", - "eth_mtu": "1500", - "eth_bw": 1000000, - "eth_dly": 10, - "eth_reliability": "255", - "eth_txload": "1", - "eth_rxload": "1", - "eth_encap": "ARPA", - "medium": "broadcast", - "eth_mode": "routed", - "eth_duplex": "auto", - "eth_speed": "auto-speed", - "eth_beacon": "off", - "eth_autoneg": "on", - "eth_in_flowctrl": "off", - "eth_out_flowctrl": "off", - "eth_mdix": "off", - "eth_swt_monitor": "off", - "eth_ethertype": "0x8100", - "eth_eee_state": "n/a", - "eth_link_flapped": "never", - "eth_clear_counters": "00:15:20", - "eth_reset_cntr": 0, - "eth_load_interval1_rx": 30, - "eth_inrate1_bits": 0, - "eth_inrate1_pkts": 0, - "eth_load_interval1_tx": 30, - "eth_outrate1_bits": 0, - "eth_outrate1_pkts": 0, - "eth_inrate1_summary_bits": "0 bps", - "eth_inrate1_summary_pkts": "0 pps", - "eth_outrate1_summary_bits": "0 bps", - "eth_outrate1_summary_pkts": "0 pps", - "eth_load_interval2_rx": 300, - "eth_inrate2_bits": 0, - "eth_inrate2_pkts": 0, - "eth_load_interval2_tx": 300, - "eth_outrate2_bits": 0, - "eth_outrate2_pkts": 0, - "eth_inrate2_summary_bits": "0 bps", - "eth_inrate2_summary_pkts": "0 pps", - "eth_outrate2_summary_bits": "0 bps", - "eth_outrate2_summary_pkts": "0 pps", - "eth_l3in_ucastpkts": 0, - "eth_l3in_ucastbytes": 0, - "eth_l3in_mcastpkts": 0, - "eth_l3in_mcastbytes": 0, - "eth_l3out_ucastpkts": 0, - "eth_l3out_ucastbytes": 0, - "eth_l3out_mcastpkts": 0, - "eth_l3out_mcastbytes": 0, - "eth_inucast": 4, - "eth_inmcast": 0, - "eth_inbcast": 0, - "eth_inpkts": 4, - "eth_inbytes": 2496, - "eth_jumbo_inpkts": 0, - "eth_storm_supp": 0, - "eth_runts": 0, - "eth_giants": 0, - "eth_crc": 0, - "eth_nobuf": 0, - "eth_inerr": 0, - "eth_frame": 0, - "eth_overrun": 0, - "eth_underrun": 0, - "eth_ignored": 0, - "eth_watchdog": 0, - "eth_bad_eth": 0, - "eth_bad_proto": 0, - "eth_in_ifdown_drops": 0, - "eth_dribble": 0, - "eth_indiscard": 0, - "eth_inpause": 0, - "eth_outucast": 4, - "eth_outmcast": 0, - "eth_outbcast": 0, - "eth_outpkts": 4, - "eth_outbytes": 2496, - "eth_jumbo_outpkts": 0, - "eth_outerr": 0, - "eth_coll": 0, - "eth_deferred": 0, - "eth_latecoll": 0, - "eth_lostcarrier": 0, - "eth_nocarrier": 0, - "eth_babbles": 0, - "eth_outdiscard": 0, - "eth_outpause": 0 - } - ] - } -} diff --git a/test/units/modules/network/nxos/fixtures/nxos_interface/show_interface_Ethernet2_5 b/test/units/modules/network/nxos/fixtures/nxos_interface/show_interface_Ethernet2_5 deleted file mode 100644 index d09d35ef7dc..00000000000 --- a/test/units/modules/network/nxos/fixtures/nxos_interface/show_interface_Ethernet2_5 +++ /dev/null @@ -1,93 +0,0 @@ -{ - "TABLE_interface": { - "ROW_interface": { - "interface": "Ethernet2/5", - "state": "down", - "state_rsn_desc": "Administratively down", - "admin_state": "down", - "share_state": "Dedicated", - "eth_hw_desc": "Ethernet", - "eth_hw_addr": "0000.0000.002f", - "eth_bia_addr": "0000.0000.0000", - "eth_mtu": "1500", - "eth_bw": 1000000, - "eth_dly": 10, - "eth_reliability": "255", - "eth_txload": "1", - "eth_rxload": "1", - "medium": "broadcast", - "eth_mode": "routed", - "eth_duplex": "auto", - "eth_speed": "auto-speed", - "eth_beacon": "off", - "eth_autoneg": "off", - "eth_in_flowctrl": "off", - "eth_out_flowctrl": "off", - "eth_mdix": "off", - "eth_swt_monitor": "off", - "eth_ethertype": "0x8100", - "eth_eee_state": "n/a", - "eth_link_flapped": "never", - "eth_clear_counters": "never", - "eth_reset_cntr": 0, - "eth_load_interval1_rx": 0, - "eth_inrate1_bits": 0, - "eth_inrate1_pkts": 0, - "eth_load_interval1_tx": 0, - "eth_outrate1_bits": 0, - "eth_outrate1_pkts": 0, - "eth_inrate1_summary_bits": "0 bps", - "eth_inrate1_summary_pkts": "0 pps", - "eth_outrate1_summary_bits": "0 bps", - "eth_outrate1_summary_pkts": "0 pps", - "eth_load_interval2_rx": 0, - "eth_inrate2_bits": 0, - "eth_inrate2_pkts": 0, - "eth_load_interval2_tx": 0, - "eth_outrate2_bits": 0, - "eth_outrate2_pkts": 0, - "eth_inrate2_summary_bits": "0 bps", - "eth_inrate2_summary_pkts": "0 pps", - "eth_outrate2_summary_bits": "0 bps", - "eth_outrate2_summary_pkts": "0 pps", - "eth_inucast": 0, - "eth_inmcast": 0, - "eth_inbcast": 0, - "eth_inpkts": 0, - "eth_inbytes": 0, - "eth_jumbo_inpkts": 0, - "eth_storm_supp": 0, - "eth_runts": 0, - "eth_giants": 0, - "eth_crc": 0, - "eth_nobuf": 0, - "eth_inerr": 0, - "eth_frame": 0, - "eth_overrun": 0, - "eth_underrun": 0, - "eth_ignored": 0, - "eth_watchdog": 0, - "eth_bad_eth": 0, - "eth_bad_proto": 0, - "eth_in_ifdown_drops": 0, - "eth_dribble": 0, - "eth_indiscard": 0, - "eth_inpause": 0, - "eth_outucast": 0, - "eth_outmcast": 0, - "eth_outbcast": 0, - "eth_outpkts": 0, - "eth_outbytes": 0, - "eth_jumbo_outpkts": 0, - "eth_outerr": 0, - "eth_coll": 0, - "eth_deferred": 0, - "eth_latecoll": 0, - "eth_lostcarrier": 0, - "eth_nocarrier": 0, - "eth_babbles": 0, - "eth_outdiscard": 0, - "eth_outpause": 0 - } - } -} diff --git a/test/units/modules/network/nxos/fixtures/nxos_interface/show_interface_loopback0 b/test/units/modules/network/nxos/fixtures/nxos_interface/show_interface_loopback0 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/units/modules/network/nxos/fixtures/nxos_interface/show_run_interface_Ethernet2_5 b/test/units/modules/network/nxos/fixtures/nxos_interface/show_run_interface_Ethernet2_5 deleted file mode 100644 index c6139c3741b..00000000000 --- a/test/units/modules/network/nxos/fixtures/nxos_interface/show_run_interface_Ethernet2_5 +++ /dev/null @@ -1,11 +0,0 @@ - -!Command: show running-config interface Ethernet2/5 -!Time: Fri Nov 10 05:50:59 2017 - -version 7.3(0)D1(1) - -interface Ethernet2/5 - shutdown - no switchport - mac-address 0000.0000.002f - diff --git a/test/units/modules/network/nxos/fixtures/nxos_interface/show_run_interface_loopback0 b/test/units/modules/network/nxos/fixtures/nxos_interface/show_run_interface_loopback0 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/units/modules/network/nxos/test_nxos_interface.py b/test/units/modules/network/nxos/test_nxos_interface.py index f0dc10b239b..20e4cddf667 100644 --- a/test/units/modules/network/nxos/test_nxos_interface.py +++ b/test/units/modules/network/nxos/test_nxos_interface.py @@ -73,8 +73,3 @@ class TestNxosInterfaceModule(TestNxosModule): set_module_args(dict(interface='loopback0', state='absent')) result = self.execute_module(changed=False) self.assertEqual(result['commands'], []) - - def test_nxos_interface_mtu_change(self): - set_module_args(dict(interface='Ethernet2/5', mtu=1606, state='present')) - result = self.execute_module(changed=True) - self.assertEqual(result['commands'], ['interface Ethernet2/5', 'mtu 1606', 'no shutdown'])