Skip to content

Commit

Permalink
fix ios_interfaces (ansible#60687)
Browse files Browse the repository at this point in the history
  • Loading branch information
justjais authored Aug 16, 2019
1 parent 064cd63 commit 585bfea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
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

Expand Down Expand Up @@ -234,8 +234,8 @@ def _set_config(self, want, have):
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:
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/module_utils/network/ios/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
18 changes: 11 additions & 7 deletions lib/ansible/modules/network/ios/ios_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
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
Expand Down Expand Up @@ -273,12 +275,12 @@
# 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
Expand All @@ -289,7 +291,6 @@
ios_interfaces:
config:
- name: GigabitEthernet0/2
- name: GigabitEthernet0/3
state: deleted
# After state:
Expand All @@ -305,9 +306,12 @@
# 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)"
Expand All @@ -321,12 +325,12 @@
# 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
Expand Down

0 comments on commit 585bfea

Please sign in to comment.