nxos CI failures bugfix (#42240)

* fix nxos_portchannel and remove deprecated param in test

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* fix _nxos_switchport CI failures

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* fix nxapi nxos_command test

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* remove unsupported param nxos_smoke test

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* fix nxos_vxlan_vtep_vni

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* syntax error

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
pull/42374/head
Trishna Guha 6 years ago committed by GitHub
parent 0e05425b32
commit 805d13f287
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -138,22 +138,6 @@ def get_custom_value(arg, config, module):
return value
def execute_show_command(command, module):
device_info = get_capabilities(module)
network_api = device_info.get('network_api', 'nxapi')
if network_api == 'cliconf':
if 'show port-channel summary' in command:
command += ' | json'
cmds = [command]
body = run_commands(module, cmds)
elif network_api == 'nxapi':
cmds = [command]
body = run_commands(module, cmds)
return body
def get_portchannel_members(pchannel):
try:
members = pchannel['TABLE_member']['ROW_member']
@ -187,13 +171,13 @@ def get_portchannel_mode(interface, protocol, module, netcfg):
def get_portchannel(module, netcfg=None):
command = 'show port-channel summary'
command = 'show port-channel summary | json'
portchannel = {}
portchannel_table = {}
members = []
try:
body = execute_show_command(command, module)[0]
body = run_commands(module, [command])[0]
pc_table = body['TABLE_channel']['ROW_channel']
if isinstance(pc_table, dict):

@ -133,13 +133,13 @@ def get_interface_mode(interface, module):
Returns:
str: 'layer2' or 'layer3'
"""
command = 'show interface ' + interface
command = 'show interface {0} | json'.format(interface)
intf_type = get_interface_type(interface)
mode = 'unknown'
interface_table = {}
try:
body = execute_show_command(command, module)[0]
body = run_commands(module, [command])[0]
interface_table = body['TABLE_interface']['ROW_interface']
except (KeyError, AttributeError, IndexError):
return mode
@ -167,9 +167,9 @@ def interface_is_portchannel(interface, module):
intf_type = get_interface_type(interface)
if intf_type == 'ethernet':
command = 'show interface ' + interface
command = 'show interface {0} | json'.format(interface)
try:
body = execute_show_command(command, module)[0]
body = run_commands(module, [command])[0]
interface_table = body['TABLE_interface']['ROW_interface']
except (KeyError, AttributeError, IndexError):
interface_table = None
@ -194,10 +194,10 @@ def get_switchport(port, module):
dictionary with k/v pairs for L2 vlan config
"""
command = 'show interface {0} switchport'.format(port)
command = 'show interface {0} switchport | json'.format(port)
try:
body = execute_show_command(command, module)[0]
body = run_commands(module, [command])[0]
sp_table = body['TABLE_interface']['ROW_interface']
except (KeyError, AttributeError, IndexError):
sp_table = None
@ -358,11 +358,11 @@ def vlan_range_to_list(vlans):
def get_list_of_vlans(module):
command = 'show vlan'
command = 'show vlan | json'
vlan_list = []
try:
body = execute_show_command(command, module)[0]
body = run_commands(module, [command])[0]
vlan_table = body['TABLE_vlanbrief']['ROW_vlanbrief']
except (KeyError, AttributeError, IndexError):
return []
@ -405,21 +405,6 @@ def apply_value_map(value_map, resource):
return resource
def execute_show_command(command, module, command_type='cli_show'):
device_info = get_capabilities(module)
network_api = device_info.get('network_api', 'nxapi')
if network_api == 'cliconf':
command += ' | json'
cmds = [command]
body = run_commands(module, cmds)
elif network_api == 'nxapi':
cmds = [command]
body = run_commands(module, cmds)
return body
def flatten_list(command_lists):
flat_command_list = []
for command in command_lists:

@ -212,12 +212,12 @@ def state_present(module, existing, proposed, candidate):
elif key == 'ingress-replication protocol' and value != existing_commands.get(key):
evalue = existing_commands.get(key)
dvalue = PARAM_TO_DEFAULT_KEYMAP.get('ingress_replication', 'default')
if evalue:
if value != dvalue:
if evalue != dvalue:
commands.append('no {0} {1}'.format(key, evalue))
commands.append('{0} {1}'.format(key, value))
else:
if value != dvalue:
if evalue and evalue != dvalue:
commands.append('no {0} {1}'.format(key, evalue))
commands.append('{0} {1}'.format(key, value))
else:
if evalue:
commands.append('no {0} {1}'.format(key, evalue))
elif value is True:

@ -9,7 +9,6 @@
wait_for:
- "result[0] contains NX-OS"
- "result[1].TABLE_interface.ROW_interface.interface contains mgmt"
provider: "{{ connection }}"
register: result
- assert:

@ -0,0 +1,19 @@
---
- debug: msg="START common/contains.yaml on connection={{ ansible_connection }}"
- name: test contains operator
nxos_command:
commands:
- { command: 'show version', output: 'text' }
- { command: 'show interface mgmt0', output: 'json' }
wait_for:
- "result[0] contains NX-OS"
- "result[1].TABLE_interface.ROW_interface.interface contains mgmt"
provider: "{{ connection }}"
register: result
- assert:
that:
- "result.changed == false"
- debug: msg="END common/contains.yaml on connection={{ ansible_connection }}"

@ -34,7 +34,6 @@
force: 'true'
provider: "{{ connection }}"
state: absent
timeout: 60
- block:
- name: Configure port-channel mode active
@ -45,7 +44,6 @@
force: 'true'
provider: "{{ connection }}"
state: present
timeout: 60
register: result
- assert: &true
@ -68,7 +66,6 @@
force: 'true'
provider: "{{ connection }}"
state: present
timeout: 60
register: result
- assert: *true
@ -91,7 +88,6 @@
feature: lacp
provider: "{{ connection }}"
state: disabled
timeout: 60
always:
- name: Delete port-channel

@ -30,7 +30,6 @@
- name: delete backup files
file:
path: "{{ item.path }}"
provider: "{{ connection }}"
state: absent
with_items: "{{backup_files.files|default([])}}"

Loading…
Cancel
Save