1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

nxos_interface: Disable switchport for loopback/svi (#40314)

* nxos_interface: Disable switchport for loopback/svi

* Replace interface_type with get_interface_type(name)
This commit is contained in:
Dag Wieers 2018-05-24 05:21:17 +02:00 committed by Trishna Guha
parent d4b2252d8b
commit d04a989bd2

View file

@ -1,20 +1,7 @@
#!/usr/bin/python #!/usr/bin/python
# # -*- coding: utf-8 -*-
# This file is part of Ansible
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
ANSIBLE_METADATA = {'metadata_version': '1.1', ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'], 'status': ['preview'],
@ -404,6 +391,8 @@ def map_obj_to_commands(updates, module):
elif state == 'present': elif state == 'present':
if obj_in_have: if obj_in_have:
# Don't run switchport command for loopback and svi interfaces
if get_interface_type(name) in ('ethernet', 'portchannel'):
if mode == 'layer2' and mode != obj_in_have.get('mode'): if mode == 'layer2' and mode != obj_in_have.get('mode'):
add_command_to_interface(interface, 'switchport', commands) add_command_to_interface(interface, 'switchport', commands)
elif mode == 'layer3' and mode != obj_in_have.get('mode'): elif mode == 'layer3' and mode != obj_in_have.get('mode'):
@ -444,6 +433,8 @@ def map_obj_to_commands(updates, module):
else: else:
commands.append(interface) commands.append(interface)
# Don't run switchport command for loopback and svi interfaces
if get_interface_type(name) in ('ethernet', 'portchannel'):
if mode == 'layer2': if mode == 'layer2':
commands.append('switchport') commands.append('switchport')
elif mode == 'layer3': elif mode == 'layer3':