Debian Codegraph @

ansible_collections/cisco/intersight/tests/integration/targets/intersight_thermal_policy/tasks/tests.yml

raw symbols SCIP
1 ---
2 - block:
3 - name: Define anchor for Intersight API login info
4 ansible.builtin.set_fact:
5 api_info: &api_info
6 api_private_key: "{{ api_private_key }}"
7 api_key_id: "{{ api_key_id }}"
8 api_uri: "{{ api_uri | default(omit) }}"
9 validate_certs: "{{ validate_certs | default(omit) }}"
10 organization: "{{ organization }}"
11
12 - name: Make sure Env is clean
13 cisco.intersight.intersight_thermal_policy:
14 <<: *api_info
15 name: "{{ item }}"
16 state: absent
17 loop:
18 - test_thermal_policy
19 - test_thermal_policy_2
20
21 - name: Create thermal policy - check-mode
22 cisco.intersight.intersight_thermal_policy:
23 <<: *api_info
24 name: test_thermal_policy
25 description: "Test thermal policy description"
26 tags:
27 - Key: Site
28 Value: Test
29 - Key: Site2
30 Value: Test2
31 fan_control_mode: "LowPower"
32 check_mode: true
33 register: creation_res_check_mode
34
35 - name: Verify thermal policy was not created - check-mode
36 ansible.builtin.assert:
37 that:
38 - creation_res_check_mode is changed
39 - creation_res_check_mode.api_response == {}
40
41 - name: Create thermal policy
42 cisco.intersight.intersight_thermal_policy:
43 <<: *api_info
44 name: test_thermal_policy
45 description: "Test thermal policy description"
46 tags:
47 - Key: Site
48 Value: Test
49 - Key: Site2
50 Value: Test2
51 fan_control_mode: "LowPower"
52 register: creation_res
53
54 - name: Fetch info after creation
55 cisco.intersight.intersight_thermal_policy_info:
56 <<: *api_info
57 name: test_thermal_policy
58 register: creation_info_res
59
60 - name: Verify thermal policy creation by info
61 ansible.builtin.assert:
62 that:
63 - creation_res.changed
64 - creation_info_res.api_response[0].Name == 'test_thermal_policy'
65 - creation_info_res.api_response[0].FanControlMode == 'LowPower'
66
67 - name: Verify thermal policy creation response aligns with info response
68 ansible.builtin.assert:
69 that:
70 - creation_res.api_response.Name == creation_info_res.api_response[0].Name
71 - creation_res.api_response.FanControlMode == creation_info_res.api_response[0].FanControlMode
72
73 - name: Create thermal policy (idempotency check)
74 cisco.intersight.intersight_thermal_policy:
75 <<: *api_info
76 name: test_thermal_policy
77 description: "Test thermal policy description"
78 tags:
79 - Key: Site
80 Value: Test
81 - Key: Site2
82 Value: Test2
83 fan_control_mode: "LowPower"
84 register: creation_res_ide
85
86 - name: Verify thermal policy creation (idempotency check)
87 ansible.builtin.assert:
88 that:
89 - not creation_res_ide.changed
90
91 - name: Change fan control mode to an existing thermal policy
92 cisco.intersight.intersight_thermal_policy:
93 <<: *api_info
94 name: test_thermal_policy
95 fan_control_mode: "HighPower"
96 register: changed_res
97
98 - name: Fetch info after change
99 cisco.intersight.intersight_thermal_policy_info:
100 <<: *api_info
101 name: test_thermal_policy
102 register: change_info_res
103
104 - name: Verify thermal policy change by info
105 ansible.builtin.assert:
106 that:
107 - changed_res.changed
108 - change_info_res.api_response[0].Name == 'test_thermal_policy'
109 - change_info_res.api_response[0].FanControlMode == 'HighPower'
110
111 - name: Create another thermal policy
112 cisco.intersight.intersight_thermal_policy:
113 <<: *api_info
114 name: test_thermal_policy_2
115 description: "Test another thermal policy description"
116 fan_control_mode: "Balanced"
117 register: creation_res_b
118
119 - name: Fetch all thermal policies under selected organization
120 cisco.intersight.intersight_thermal_policy_info:
121 <<: *api_info
122 register: creation_info_res_b
123
124 - name: Check that there are at least thermal policies under this organization
125 ansible.builtin.assert:
126 that:
127 - creation_info_res_b.api_response | length > 1
128
129 always:
130 - name: Remove thermal policies
131 cisco.intersight.intersight_thermal_policy:
132 <<: *api_info
133 name: "{{ item }}"
134 state: absent
135 loop:
136 - test_thermal_policy
137 - test_thermal_policy_2