Debian Codegraph @

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

raw
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_mac_pool:
14 <<: *api_info
15 name: "{{ item }}"
16 state: absent
17 loop:
18 - test_mac_pool
19 - test_mac_pool_2
20
21 - name: Create mac pool - check-mode
22 cisco.intersight.intersight_mac_pool:
23 <<: *api_info
24 name: test_mac_pool
25 description: "Test mac pool description"
26 tags:
27 - "Key": "Site"
28 "Value": "Test"
29 - "Key": "Site2"
30 "Value": "Test3"
31 mac_blocks:
32 - "address_from": "00:25:B5:00:00:00"
33 "size": 20
34 check_mode: true
35 register: creation_res_check_mode
36
37 - name: Verify mac pool was not created - check-mode
38 ansible.builtin.assert:
39 that:
40 - creation_res_check_mode is changed
41 - creation_res_check_mode.api_response == {}
42
43 - name: Create mac pool
44 cisco.intersight.intersight_mac_pool:
45 <<: *api_info
46 name: test_mac_pool
47 description: "Test mac pool description"
48 tags:
49 - "Key": "Site"
50 "Value": "Test"
51 - "Key": "Site2"
52 "Value": "Test3"
53 mac_blocks:
54 - "address_from": "00:25:B5:00:00:00"
55 "size": 20
56 register: creation_res
57
58 - name: Fetch info after creation
59 cisco.intersight.intersight_mac_pool_info:
60 <<: *api_info
61 name: test_mac_pool
62 register: creation_info_res
63
64 - name: Verify mac pool creation by info
65 ansible.builtin.assert:
66 that:
67 - creation_res.changed
68 - creation_info_res.api_response[0].Name == 'test_mac_pool'
69 - creation_info_res.api_response[0].MacBlocks[0]["Size"] == 20
70 - creation_info_res.api_response[0].MacBlocks[0]["From"] == '00:25:B5:00:00:00'
71
72 - name: Verify mac pool creation response aligns with info response
73 ansible.builtin.assert:
74 that:
75 - creation_res.api_response.Name == creation_info_res.api_response[0].Name
76 - creation_res.api_response.MacBlocks[0]["Size"] == creation_info_res.api_response[0].MacBlocks[0]["Size"]
77 - creation_res.api_response.MacBlocks[0]["From"] == creation_info_res.api_response[0].MacBlocks[0]["From"]
78
79 - name: Create mac pool (idempotency check)
80 cisco.intersight.intersight_mac_pool:
81 <<: *api_info
82 name: test_mac_pool
83 description: "Test mac pool description"
84 tags:
85 - "Key": "Site"
86 "Value": "Test"
87 - "Key": "Site2"
88 "Value": "Test3"
89 mac_blocks:
90 - "address_from": "00:25:B5:00:00:00"
91 "size": 20
92 register: creation_res_ide
93
94 - name: Verify mac pool creation (idempotency check)
95 ansible.builtin.assert:
96 that:
97 - not creation_res_ide.changed
98
99 - name: Validate failure due to missing mac_blocks
100 cisco.intersight.intersight_mac_pool:
101 <<: *api_info
102 name: test_mac_pool_validate
103 description: "Test mac pool description"
104 tags:
105 - "Key": "Site"
106 "Value": "Test"
107 - "Key": "Site2"
108 "Value": "Test3"
109 state: present
110 register: failure_res
111 failed_when:
112 - "'mac_blocks parameter must be provided and contain at least one block' not in failure_res.msg"
113
114 - name: Create another mac pool
115 cisco.intersight.intersight_mac_pool:
116 <<: *api_info
117 name: test_mac_pool_2
118 description: "Test mac pool description"
119 tags:
120 - "Key": "Site"
121 "Value": "Test"
122 - "Key": "Site2"
123 "Value": "Test3"
124 mac_blocks:
125 - "address_from": "00:25:B5:00:00:00"
126 "size": 20
127 register: creation_res_b
128
129 - name: Fetch all mac pools under default organization
130 cisco.intersight.intersight_mac_pool_info:
131 <<: *api_info
132 register: creation_info_res_b
133
134 - name: Check that there are at least 2 mac pools under this organization
135 ansible.builtin.assert:
136 that:
137 - creation_info_res_b.api_response | length > 1
138
139 always:
140 - name: Remove mac pools
141 cisco.intersight.intersight_mac_pool:
142 <<: *api_info
143 name: "{{ item }}"
144 state: absent
145 loop:
146 - test_mac_pool
147 - test_mac_pool_2