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
#
# This file is part of Ansible
#
# 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/>.
#
# -*- coding: utf-8 -*-
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
@ -404,6 +391,8 @@ def map_obj_to_commands(updates, module):
elif state == 'present':
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'):
add_command_to_interface(interface, 'switchport', commands)
elif mode == 'layer3' and mode != obj_in_have.get('mode'):
@ -444,6 +433,8 @@ def map_obj_to_commands(updates, module):
else:
commands.append(interface)
# Don't run switchport command for loopback and svi interfaces
if get_interface_type(name) in ('ethernet', 'portchannel'):
if mode == 'layer2':
commands.append('switchport')
elif mode == 'layer3':