summaryrefslogtreecommitdiff
path: root/test/integration/targets/netapp_e_asup/tasks/run.yml
blob: e3325ac8a75dc22ebcd22993152761c8d3a0b146 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# Test code for the netapp_e_iscsi_interface module
# (c) 2018, NetApp, Inc
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

- name: NetApp Test ASUP module
  fail:
    msg: 'Please define netapp_e_api_username, netapp_e_api_password, netapp_e_api_host, and netapp_e_ssid.'
  when:  netapp_e_api_username is undefined or netapp_e_api_password is undefined
          or netapp_e_api_host is undefined or netapp_e_ssid is undefined
  vars: &vars
    credentials: &creds
      api_url: "https://{{ netapp_e_api_host }}/devmgr/v2"
      api_username: "{{ netapp_e_api_username }}"
      api_password: "{{ netapp_e_api_password }}"
      ssid: "{{ netapp_e_ssid }}"
      validate_certs: no

- name: set credentials
  set_fact:
    credentials: *creds

- name: Show some debug information
  debug:
    msg: "Using user={{ credentials.api_username }} on server={{ credentials.api_url }}."

# ****************************************************
# *** Enable auto-support using all default values ***
# ****************************************************
- name: Enable auto-support using default values
  netapp_e_asup:
    <<: *creds
    verbose: true

- name: Collect auto-support state information from the array
  uri:
    url: "{{ credentials.api_url }}/device-asup"
    user: "{{ credentials.api_username }}"
    password: "{{ credentials.api_password }}"
    body_format: json
    validate_certs: no
  register: current

- name: Validate auto-support expected default state
  assert:
    that: "{{ current.json.asupEnabled and
              current.json.onDemandEnabled and
              current.json.remoteDiagsEnabled and
              current.json.schedule.dailyMinTime == 0 and
              current.json.schedule.dailyMaxTime == 1439 }}"
    msg: "Unexpected auto-support state"

- name: Validate auto-support schedule
  assert:
    that: "{{ item in current.json.schedule.daysOfWeek }}"
    msg: "{{ item }} is missing from the schedule"
  loop: "{{ lookup('list', ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']) }}"

# ****************************
# *** Disable auto-support ***
# ****************************
- name: Disable auto-support
  netapp_e_asup:
    <<: *creds
    state: disabled

- name: Collect auto-support state information from the array
  uri:
    url: "{{ credentials.api_url }}/device-asup"
    user: "{{ credentials.api_username }}"
    password: "{{ credentials.api_password }}"
    body_format: json
    validate_certs: no
  register: current

- name: Validate auto-support is disabled
  assert:
    that: "{{ not current.json.asupEnabled }}"
    msg: "Auto-support failed to be disabled"

# ****************************************************
# *** Enable auto-support using specific values ***
# ****************************************************
- name: Enable auto-support using specific values
  netapp_e_asup:
    <<: *creds
    state: enabled
    active: true
    start: 22
    end: 24
    days:
      - friday
      - saturday
    verbose: true

- name: Collect auto-support state information from the array
  uri:
    url: "{{ credentials.api_url }}/device-asup"
    user: "{{ credentials.api_username }}"
    password: "{{ credentials.api_password }}"
    body_format: json
    validate_certs: no
  register: current

- name: Validate auto-support expected state
  assert:
    that: "{{ current.json.asupEnabled and
              current.json.onDemandEnabled and
              current.json.remoteDiagsEnabled and
              current.json.schedule.dailyMinTime == (22 * 60) and
              current.json.schedule.dailyMaxTime == (24 * 60 - 1) }}"
    msg: "Unexpected auto-support state"

- name: Validate auto-support schedule
  assert:
    that: "{{ item in current.json.schedule.daysOfWeek }}"
    msg: "{{ item }} is missing from the schedule"
  loop: "{{ lookup('list', ['friday', 'saturday']) }}"

# ***********************************
# *** Alter auto-support schedule ***
# ***********************************
- name: Auto auto-support schedule
  netapp_e_asup:
    <<: *creds
    state: enabled
    active: true
    start: 0
    end: 5
    days:
      - monday
      - thursday
      - sunday
    verbose: true

- name: Collect auto-support state information from the array
  uri:
    url: "{{ credentials.api_url }}/device-asup"
    user: "{{ credentials.api_username }}"
    password: "{{ credentials.api_password }}"
    body_format: json
    validate_certs: no
  register: current

- name: Validate auto-support expected state
  assert:
    that: "{{ current.json.asupEnabled and
              current.json.onDemandEnabled and
              current.json.remoteDiagsEnabled and
              current.json.schedule.dailyMinTime == (0 * 60) and
              current.json.schedule.dailyMaxTime == (5 * 60) }}"
    msg: "Unexpected auto-support state"

- name: Validate auto-support schedule
  assert:
    that: "{{ item in current.json.schedule.daysOfWeek }}"
    msg: "{{ item }} is missing from the schedule"
  loop: "{{ lookup('list', ['monday', 'thursday', 'sunday']) }}"

# *************************************************************
# *** Repeat previous test to verify state remains the same ***
# *************************************************************
- name: Repeat auto-support schedule change to verify idempotency
  netapp_e_asup:
    <<: *creds
    state: enabled
    active: true
    start: 0
    end: 5
    days:
      - monday
      - thursday
      - sunday
    verbose: true
  register: result

- name: Collect auto-support state information from the array
  uri:
    url: "{{ credentials.api_url }}/device-asup"
    user: "{{ credentials.api_username }}"
    password: "{{ credentials.api_password }}"
    body_format: json
    validate_certs: no
  register: current

- name: Validate auto-support expected state
  assert:
    that: "{{ current.json.asupEnabled and
              current.json.onDemandEnabled and
              current.json.remoteDiagsEnabled and
              current.json.schedule.dailyMinTime == (0 * 60) and
              current.json.schedule.dailyMaxTime == (5 * 60) }}"
    msg: "Unexpected auto-support state"

- name: Validate auto-support schedule
  assert:
    that: "{{ item in current.json.schedule.daysOfWeek }}"
    msg: "{{ item }} is missing from the schedule"
  loop: "{{ lookup('list', ['monday', 'thursday', 'sunday']) }}"

- name: Validate change was not detected
  assert:
    that: "{{ not result.changed }}"
    msg: "Invalid change was detected"

# ***********************************
# *** Disable auto-support active ***
# ***********************************
- name: Auto auto-support schedule
  netapp_e_asup:
    <<: *creds
    state: enabled
    active: false
    start: 0
    end: 5
    days:
      - monday
      - thursday
      - sunday
    verbose: true

- name: Collect auto-support state information from the array
  uri:
    url: "{{ credentials.api_url }}/device-asup"
    user: "{{ credentials.api_username }}"
    password: "{{ credentials.api_password }}"
    body_format: json
    validate_certs: no
  register: current

- name: Validate auto-support expected state
  assert:
    that: "{{ current.json.asupEnabled and not current.json.onDemandEnabled and not current.json.remoteDiagsEnabled }}"
    msg: "Unexpected auto-support state"