summaryrefslogtreecommitdiff
path: root/test/integration/targets/prepare_nxos_tests/tasks/main.yml
blob: bd9abf9e8fa82bb64bef339f5b8c7d7ca1c8a842 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
---
# There is a bug currently where the nxapi server can get
# stuck in a bad state when enabling/disabling rapidly by
# the integration tests.
#
# Toggle the command off/on as mitigation.
- name: Toggle feature nxapi - Disable
  nxos_config:
    lines:
      - no feature nxapi
    provider: "{{ cli }}"
  ignore_errors: yes

# Pause after disabling nxapi
- pause:
    seconds: 3

- name: Toggle feature nxapi - Enable
  nxos_config:
    lines:
      - feature nxapi
    provider: "{{ cli }}"
  ignore_errors: yes

# Pause after enabling nxapi
- pause:
    seconds: 3

# Gather the list of interfaces on this device and make the list
# available for integration tests that need them.
#
# Usage in integration test playbook:
#
#   - set_fact: testint="{{ nxos_int1 }}"
#
#   - name: "Interface selected for this test"
#     debug: msg="{{ testint }}"
#
- name: "Collect interface list"
  nxos_command:
    commands: ['show interface brief | json']
    provider: "{{ nxapi }}"
    timeout: 60
  register: intout

- set_fact: intdataraw="{{ intout.stdout_lines[0]['TABLE_interface']['ROW_interface'] }}"
- set_fact: nxos_int1="{{ intdataraw[1].interface }}"
- set_fact: nxos_int2="{{ intdataraw[2].interface }}"
- set_fact: nxos_int3="{{ intdataraw[3].interface }}"

# Get platform information for this device
#
# Usage in integration test playbook:
#
#   - name: "nxos platform "
#     debug: msg="{{ platform }}"
#
- name: "Gather platform info"
  nxos_command:
    commands: ['sh inventory | json']
    provider: "{{ cli }}"
  register: nxos_inventory_output

- set_fact: platform="{{ nxos_inventory_output.stdout_lines[0]['TABLE_inv']['ROW_inv'][0]['productid'].split('-')[0] }}"

# Check if platform is fretta
- set_fact: fretta={% for row in nxos_inventory_output.stdout_lines[0]['TABLE_inv']['ROW_inv'] if 'FM-R' in row['productid'] %}"true"{% endfor %}
  when: platform | match("N9K")

# Set platform to N9K-F for fretta
- set_fact: platform="N9K-F"
  when: (platform | match("N9K")) and (fretta | search("true"))

# Check if platform is titanium
- set_fact: titanium={% for row in nxos_inventory_output.stdout_lines[0]['TABLE_inv']['ROW_inv'] if 'NX-OSv' in row['desc']%}"true"{% endfor %}
  when: platform | match("N7K")