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 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): def get_portchannel_members(pchannel):
try: try:
members = pchannel['TABLE_member']['ROW_member'] members = pchannel['TABLE_member']['ROW_member']
@ -187,13 +171,13 @@ def get_portchannel_mode(interface, protocol, module, netcfg):
def get_portchannel(module, netcfg=None): def get_portchannel(module, netcfg=None):
command = 'show port-channel summary' command = 'show port-channel summary | json'
portchannel = {} portchannel = {}
portchannel_table = {} portchannel_table = {}
members = [] members = []
try: try:
body = execute_show_command(command, module)[0] body = run_commands(module, [command])[0]
pc_table = body['TABLE_channel']['ROW_channel'] pc_table = body['TABLE_channel']['ROW_channel']
if isinstance(pc_table, dict): if isinstance(pc_table, dict):

@ -133,13 +133,13 @@ def get_interface_mode(interface, module):
Returns: Returns:
str: 'layer2' or 'layer3' str: 'layer2' or 'layer3'
""" """
command = 'show interface ' + interface command = 'show interface {0} | json'.format(interface)
intf_type = get_interface_type(interface) intf_type = get_interface_type(interface)
mode = 'unknown' mode = 'unknown'
interface_table = {} interface_table = {}
try: try:
body = execute_show_command(command, module)[0] body = run_commands(module, [command])[0]
interface_table = body['TABLE_interface']['ROW_interface'] interface_table = body['TABLE_interface']['ROW_interface']
except (KeyError, AttributeError, IndexError): except (KeyError, AttributeError, IndexError):
return mode return mode
@ -167,9 +167,9 @@ def interface_is_portchannel(interface, module):
intf_type = get_interface_type(interface) intf_type = get_interface_type(interface)
if intf_type == 'ethernet': if intf_type == 'ethernet':
command = 'show interface ' + interface command = 'show interface {0} | json'.format(interface)
try: try:
body = execute_show_command(command, module)[0] body = run_commands(module, [command])[0]
interface_table = body['TABLE_interface']['ROW_interface'] interface_table = body['TABLE_interface']['ROW_interface']
except (KeyError, AttributeError, IndexError): except (KeyError, AttributeError, IndexError):
interface_table = None interface_table = None
@ -194,10 +194,10 @@ def get_switchport(port, module):
dictionary with k/v pairs for L2 vlan config 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: try:
body = execute_show_command(command, module)[0] body = run_commands(module, [command])[0]
sp_table = body['TABLE_interface']['ROW_interface'] sp_table = body['TABLE_interface']['ROW_interface']
except (KeyError, AttributeError, IndexError): except (KeyError, AttributeError, IndexError):
sp_table = None sp_table = None
@ -358,11 +358,11 @@ def vlan_range_to_list(vlans):
def get_list_of_vlans(module): def get_list_of_vlans(module):
command = 'show vlan' command = 'show vlan | json'
vlan_list = [] vlan_list = []
try: try:
body = execute_show_command(command, module)[0] body = run_commands(module, [command])[0]
vlan_table = body['TABLE_vlanbrief']['ROW_vlanbrief'] vlan_table = body['TABLE_vlanbrief']['ROW_vlanbrief']
except (KeyError, AttributeError, IndexError): except (KeyError, AttributeError, IndexError):
return [] return []
@ -405,21 +405,6 @@ def apply_value_map(value_map, resource):
return 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): def flatten_list(command_lists):
flat_command_list = [] flat_command_list = []
for command in command_lists: 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): elif key == 'ingress-replication protocol' and value != existing_commands.get(key):
evalue = existing_commands.get(key) evalue = existing_commands.get(key)
dvalue = PARAM_TO_DEFAULT_KEYMAP.get('ingress_replication', 'default') dvalue = PARAM_TO_DEFAULT_KEYMAP.get('ingress_replication', 'default')
if evalue: if value != dvalue:
if value != dvalue: if evalue and evalue != dvalue:
if evalue != dvalue: commands.append('no {0} {1}'.format(key, evalue))
commands.append('no {0} {1}'.format(key, evalue)) commands.append('{0} {1}'.format(key, value))
commands.append('{0} {1}'.format(key, value)) else:
else: if evalue:
commands.append('no {0} {1}'.format(key, evalue)) commands.append('no {0} {1}'.format(key, evalue))
elif value is True: elif value is True:

@ -9,7 +9,6 @@
wait_for: wait_for:
- "result[0] contains NX-OS" - "result[0] contains NX-OS"
- "result[1].TABLE_interface.ROW_interface.interface contains mgmt" - "result[1].TABLE_interface.ROW_interface.interface contains mgmt"
provider: "{{ connection }}"
register: result register: result
- assert: - 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' force: 'true'
provider: "{{ connection }}" provider: "{{ connection }}"
state: absent state: absent
timeout: 60
- block: - block:
- name: Configure port-channel mode active - name: Configure port-channel mode active
@ -45,7 +44,6 @@
force: 'true' force: 'true'
provider: "{{ connection }}" provider: "{{ connection }}"
state: present state: present
timeout: 60
register: result register: result
- assert: &true - assert: &true
@ -68,7 +66,6 @@
force: 'true' force: 'true'
provider: "{{ connection }}" provider: "{{ connection }}"
state: present state: present
timeout: 60
register: result register: result
- assert: *true - assert: *true
@ -91,7 +88,6 @@
feature: lacp feature: lacp
provider: "{{ connection }}" provider: "{{ connection }}"
state: disabled state: disabled
timeout: 60
always: always:
- name: Delete port-channel - name: Delete port-channel

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

Loading…
Cancel
Save