Handle nxos platform diffs with cli conf implementation (#34020)

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
pull/34078/head
Trishna Guha 7 years ago committed by GitHub
parent 2db3d861e0
commit 27be2a0f5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -29,6 +29,8 @@ short_description: Handles the EVPN control plane for VXLAN.
description:
- Handles the EVPN control plane for VXLAN.
author: Gabriele Gerbino (@GGabriele)
notes:
- This module is not supported on Nexus 3000 series of switches.
options:
nv_overlay_evpn:
description:
@ -52,13 +54,10 @@ commands:
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.network.nxos.nxos import get_config, load_config
from ansible.module_utils.network.nxos.nxos import nxos_argument_spec
from ansible.module_utils.network.nxos.nxos import check_args as nxos_check_args
from ansible.module_utils.network.nxos.nxos import get_capabilities, nxos_argument_spec
def check_args(module, warnings):
nxos_check_args(module, warnings)
for key in ('include_defaults', 'config', 'save'):
if module.params[key] is not None:
warnings.append('argument %s is no longer supported, ignoring value' % key)
@ -88,6 +87,12 @@ def main():
config = get_config(module)
commands = list()
info = get_capabilities(module).get('device_info', {})
os_platform = info.get('network_os_platform', '')
if '3K' in os_platform:
module.fail_json(msg='This module is not supported on Nexus 3000 series')
if module.params['nv_overlay_evpn'] is True:
if 'nv overlay evpn' not in config:
commands.append('nv overlay evpn')

@ -73,13 +73,10 @@ import re
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.network.nxos.nxos import load_config, run_commands
from ansible.module_utils.network.nxos.nxos import nxos_argument_spec
from ansible.module_utils.network.nxos.nxos import check_args as nxos_check_args
from ansible.module_utils.network.nxos.nxos import get_capabilities, nxos_argument_spec
def check_args(module, warnings):
nxos_check_args(module, warnings)
for key in ('include_defaults', 'config', 'save'):
if module.params[key] is not None:
warnings.append('argument %s is no longer supported, ignoring value' % key)
@ -139,39 +136,73 @@ def validate_feature(module, mode='show'):
how they are configured'''
feature = module.params['feature']
feature_to_be_mapped = {
'show': {
'nv overlay': 'nve',
'vn-segment-vlan-based': 'vnseg_vlan',
'hsrp': 'hsrp_engine',
'fabric multicast': 'fabric_mcast',
'scp-server': 'scpServer',
'sftp-server': 'sftpServer',
'sla responder': 'sla_responder',
'sla sender': 'sla_sender',
'ssh': 'sshServer',
'tacacs+': 'tacacs',
'telnet': 'telnetServer',
'ethernet-link-oam': 'elo',
'port-security': 'eth_port_sec'
},
'config': {
'nve': 'nv overlay',
'vnseg_vlan': 'vn-segment-vlan-based',
'hsrp_engine': 'hsrp',
'fabric_mcast': 'fabric multicast',
'scpServer': 'scp-server',
'sftpServer': 'sftp-server',
'sla_sender': 'sla sender',
'sla_responder': 'sla responder',
'sshServer': 'ssh',
'tacacs': 'tacacs+',
'telnetServer': 'telnet',
'elo': 'ethernet-link-oam',
'eth_port_sec': 'port-security'
info = get_capabilities(module).get('device_info', {})
os_version = info.get('network_os_version', '')
if '8.1' in os_version:
feature_to_be_mapped = {
'show': {
'nv overlay': 'nve',
'vn-segment-vlan-based': 'vnseg_vlan',
'hsrp': 'hsrp_engine',
'fabric multicast': 'fabric_mcast',
'scp-server': 'scpServer',
'sftp-server': 'sftpServer',
'sla responder': 'sla_responder',
'sla sender': 'sla_sender',
'ssh': 'sshServer',
'tacacs+': 'tacacs',
'telnet': 'telnetServer',
'ethernet-link-oam': 'elo'
},
'config': {
'nve': 'nv overlay',
'vnseg_vlan': 'vn-segment-vlan-based',
'hsrp_engine': 'hsrp',
'fabric_mcast': 'fabric multicast',
'scpServer': 'scp-server',
'sftpServer': 'sftp-server',
'sla_sender': 'sla sender',
'sla_responder': 'sla responder',
'sshServer': 'ssh',
'tacacs': 'tacacs+',
'telnetServer': 'telnet',
'elo': 'ethernet-link-oam'
}
}
else:
feature_to_be_mapped = {
'show': {
'nv overlay': 'nve',
'vn-segment-vlan-based': 'vnseg_vlan',
'hsrp': 'hsrp_engine',
'fabric multicast': 'fabric_mcast',
'scp-server': 'scpServer',
'sftp-server': 'sftpServer',
'sla responder': 'sla_responder',
'sla sender': 'sla_sender',
'ssh': 'sshServer',
'tacacs+': 'tacacs',
'telnet': 'telnetServer',
'ethernet-link-oam': 'elo',
'port-security': 'eth_port_sec'
},
'config': {
'nve': 'nv overlay',
'vnseg_vlan': 'vn-segment-vlan-based',
'hsrp_engine': 'hsrp',
'fabric_mcast': 'fabric multicast',
'scpServer': 'scp-server',
'sftpServer': 'sftp-server',
'sla_sender': 'sla sender',
'sla_responder': 'sla responder',
'sshServer': 'ssh',
'tacacs': 'tacacs+',
'telnetServer': 'telnet',
'elo': 'ethernet-link-oam',
'eth_port_sec': 'port-security'
}
}
}
if feature in feature_to_be_mapped[mode]:
feature = feature_to_be_mapped[mode][feature]

@ -37,10 +37,15 @@ class TestNxosEvpnGlobalModule(TestNxosModule):
self.mock_load_config = patch('ansible.modules.network.nxos.nxos_evpn_global.load_config')
self.load_config = self.mock_load_config.start()
self.mock_get_capabilities = patch('ansible.modules.network.nxos.nxos_evpn_global.get_capabilities')
self.get_capabilities = self.mock_get_capabilities.start()
self.get_capabilities.return_value = {'network_api': 'cliconf'}
def tearDown(self):
super(TestNxosEvpnGlobalModule, self).tearDown()
self.mock_get_config.stop()
self.mock_load_config.stop()
self.mock_get_capabilities.stop()
def load_fixtures(self, commands=None, device=''):
self.load_config.return_value = None

@ -38,10 +38,15 @@ class TestNxosFeatureModule(TestNxosModule):
self.mock_load_config = patch('ansible.modules.network.nxos.nxos_feature.load_config')
self.load_config = self.mock_load_config.start()
self.mock_get_capabilities = patch('ansible.modules.network.nxos.nxos_feature.get_capabilities')
self.get_capabilities = self.mock_get_capabilities.start()
self.get_capabilities.return_value = {'network_api': 'cliconf'}
def tearDown(self):
super(TestNxosFeatureModule, self).tearDown()
self.mock_run_commands.stop()
self.mock_load_config.stop()
self.mock_get_capabilities.stop()
def load_fixtures(self, commands=None, device=''):
def load_from_file(*args, **kwargs):

Loading…
Cancel
Save