fix ios_interfaces (#60687)

This commit is contained in:
Sumit Jaiswal 2019-08-16 19:25:28 +05:30 committed by GitHub
parent 064cd63f3d
commit 585bfead75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 11 deletions

View file

@ -17,7 +17,7 @@ __metaclass__ = type
from ansible.module_utils.network.common.cfg.base import ConfigBase
from ansible.module_utils.network.common.utils import to_list
from ansible.module_utils.network.ios.facts.facts import Facts
from ansible.module_utils.network.ios.utils.utils import get_interface_type, dict_diff
from ansible.module_utils.network.ios.utils.utils import get_interface_type, dict_to_set
from ansible.module_utils.network.ios.utils.utils import remove_command_from_config_list, add_command_to_config_list
from ansible.module_utils.network.ios.utils.utils import filter_dict_having_none_value, remove_duplicate_interface
@ -234,8 +234,8 @@ class Interfaces(ConfigBase):
interface = 'interface ' + want['name']
# Get the diff b/w want and have
want_dict = dict_diff(want)
have_dict = dict_diff(have)
want_dict = dict_to_set(want)
have_dict = dict_to_set(have)
diff = want_dict - have_dict
if diff:

View file

@ -27,7 +27,7 @@ def add_command_to_config_list(interface, cmd, commands):
commands.append(cmd)
def dict_diff(sample_dict):
def dict_to_set(sample_dict):
# Generate a set with passed dictionary for comparison
test_dict = {}
for k, v in iteritems(sample_dict):

View file

@ -43,6 +43,8 @@ description: This module manages the interface attributes of Cisco IOS network d
author: Sumit Jaiswal (@justjais)
notes:
- Tested against Cisco IOSv Version 15.2 on VIRL
- This module works with connection C(network_cli).
See L(IOS Platform Options,../network/user_guide/platform_ios.html).
options:
config:
description: A dictionary of interface options
@ -273,12 +275,12 @@ EXAMPLES = """
# duplex auto
# speed auto
# interface GigabitEthernet0/2
# description Configured and Overridden by Ansible Network
# description Configured by Ansible Network
# no ip address
# duplex auto
# speed 1000
# interface GigabitEthernet0/3
# description Configured and Replaced by Ansible Network
# description Configured by Ansible Network
# mtu 2500
# no ip address
# shutdown
@ -289,7 +291,6 @@ EXAMPLES = """
ios_interfaces:
config:
- name: GigabitEthernet0/2
- name: GigabitEthernet0/3
state: deleted
# After state:
@ -305,9 +306,12 @@ EXAMPLES = """
# duplex auto
# speed auto
# interface GigabitEthernet0/3
# description Configured by Ansible Network
# mtu 2500
# no ip address
# duplex auto
# speed auto
# shutdown
# duplex full
# speed 1000
# Using Deleted without any config passed
#"(NOTE: This will delete all of configured resource module attributes from each configured interface)"
@ -321,12 +325,12 @@ EXAMPLES = """
# duplex auto
# speed auto
# interface GigabitEthernet0/2
# description Configured and Overridden by Ansible Network
# description Configured by Ansible Network
# no ip address
# duplex auto
# speed 1000
# interface GigabitEthernet0/3
# description Configured and Replaced by Ansible Network
# description Configured by Ansible Network
# mtu 2500
# no ip address
# shutdown