| 1 |
# Test code for the MSO modules |
| 2 |
# Copyright: (c) 2024, Anvitha Jain (@anvjain) <[email protected]> |
| 3 |
# Copyright: (c) 2025, Samita Bhattacharjee (@samiib) <[email protected]> |
| 4 |
|
| 5 |
# GNU General Public License v3[0]+ (see LICENSE or https://www.gnu.org/licenses/gpl-3[0].txt) |
| 6 |
|
| 7 |
- name: Test that we have an ACI MultiSite host, username and password |
| 8 |
ansible.builtin.fail: |
| 9 |
msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' |
| 10 |
when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined |
| 11 |
|
| 12 |
# CLEAN ENVIRONMENT |
| 13 |
- name: Set vars |
| 14 |
ansible.builtin.set_fact: |
| 15 |
mso_info: &mso_info |
| 16 |
host: '{{ mso_hostname }}' |
| 17 |
username: '{{ mso_username }}' |
| 18 |
password: '{{ mso_password }}' |
| 19 |
validate_certs: '{{ mso_validate_certs | default(false) }}' |
| 20 |
use_ssl: '{{ mso_use_ssl | default(true) }}' |
| 21 |
use_proxy: '{{ mso_use_proxy | default(true) }}' |
| 22 |
output_level: '{{ mso_output_level | default("debug") }}' |
| 23 |
|
| 24 |
# QUERY VERSION |
| 25 |
- name: Query MSO version |
| 26 |
cisco.mso.mso_version: |
| 27 |
<<: *mso_info |
| 28 |
state: query |
| 29 |
register: version |
| 30 |
|
| 31 |
- name: Execute tasks only for MSO version >= 4.4 |
| 32 |
when: version.current.version is version('4.4', '>=') |
| 33 |
block: |
| 34 |
- name: Remove fabric resource policy template |
| 35 |
cisco.mso.ndo_template: &template_absent |
| 36 |
<<: *mso_info |
| 37 |
name: ansible_fabric_resource_policy_template |
| 38 |
type: fabric_resource |
| 39 |
state: absent |
| 40 |
|
| 41 |
- name: Add fabric resource policy template |
| 42 |
cisco.mso.ndo_template: |
| 43 |
<<: *template_absent |
| 44 |
state: present |
| 45 |
|
| 46 |
# Create interface policy group in fabric policy template |
| 47 |
- name: Remove fabric policy template |
| 48 |
cisco.mso.ndo_template: &fabric_policy_template_absent |
| 49 |
<<: *mso_info |
| 50 |
name: ansible_fabric_policy_template |
| 51 |
type: fabric_policy |
| 52 |
state: absent |
| 53 |
|
| 54 |
- name: Create a fabric policy template |
| 55 |
cisco.mso.ndo_template: |
| 56 |
<<: *fabric_policy_template_absent |
| 57 |
state: present |
| 58 |
|
| 59 |
- name: Create interface policy group (physical policy) |
| 60 |
cisco.mso.ndo_interface_setting: &add_interface_policy_group |
| 61 |
<<: *mso_info |
| 62 |
template: ansible_fabric_policy_template |
| 63 |
name: ansible_interface_policy_group |
| 64 |
interface_type: physical |
| 65 |
state: present |
| 66 |
register: add_interface_policy_group |
| 67 |
|
| 68 |
- name: Create another interface policy group |
| 69 |
cisco.mso.ndo_interface_setting: |
| 70 |
<<: *add_interface_policy_group |
| 71 |
name: ansible_interface_policy_group_2 |
| 72 |
register: add_interface_policy_group_2 |
| 73 |
|
| 74 |
# CREATE |
| 75 |
|
| 76 |
# Create Physical Interface of type physical with physical policy UUID |
| 77 |
- name: Create Physical Interface of type 'physical' (check mode) |
| 78 |
cisco.mso.ndo_physical_interface: &add_physical_interface |
| 79 |
<<: *mso_info |
| 80 |
template: ansible_fabric_resource_policy_template |
| 81 |
name: ansible_physical_interface |
| 82 |
nodes: [103, 101-102] |
| 83 |
interfaces: ['1/3'] |
| 84 |
physical_interface_type: physical |
| 85 |
physical_policy_uuid: '{{ add_interface_policy_group.current.uuid }}' |
| 86 |
state: present |
| 87 |
check_mode: true |
| 88 |
register: cm_physical_interface |
| 89 |
|
| 90 |
- name: Create Physical Interface of type 'physical' |
| 91 |
cisco.mso.ndo_physical_interface: |
| 92 |
<<: *add_physical_interface |
| 93 |
register: nm_physical_interface |
| 94 |
|
| 95 |
- name: Create Physical Interface of type 'physical' again |
| 96 |
cisco.mso.ndo_physical_interface: |
| 97 |
<<: *add_physical_interface |
| 98 |
register: nm_physical_interface_again |
| 99 |
|
| 100 |
- name: Assert Physical Interface of type 'physical' is created |
| 101 |
ansible.builtin.assert: |
| 102 |
that: |
| 103 |
- cm_physical_interface is changed |
| 104 |
- nm_physical_interface is changed |
| 105 |
- cm_physical_interface.previous == nm_physical_interface.previous == {} |
| 106 |
- cm_physical_interface.current.name == nm_physical_interface.current.name == "ansible_physical_interface" |
| 107 |
- nm_physical_interface.current.description == "" |
| 108 |
- cm_physical_interface.current.policyGroupType == nm_physical_interface.current.policyGroupType == "physical" |
| 109 |
- cm_physical_interface.current.nodes | length == nm_physical_interface.current.nodes | length == 2 |
| 110 |
- cm_physical_interface.current.nodes[0] == nm_physical_interface.current.nodes[0] == "103" |
| 111 |
- cm_physical_interface.current.nodes[1] == nm_physical_interface.current.nodes[1] == "101-102" |
| 112 |
- cm_physical_interface.current.interfaces == nm_physical_interface.current.interfaces == "1/3" |
| 113 |
- cm_physical_interface.current.policy == nm_physical_interface.current.policy |
| 114 |
- nm_physical_interface_again is not changed |
| 115 |
- nm_physical_interface_again.previous.name == nm_physical_interface_again.current.name == "ansible_physical_interface" |
| 116 |
- nm_physical_interface_again.previous.policyGroupType == nm_physical_interface_again.current.policyGroupType == "physical" |
| 117 |
- nm_physical_interface_again.previous.nodes | length == nm_physical_interface_again.current.nodes | length == 2 |
| 118 |
- nm_physical_interface_again.previous.nodes[0] == nm_physical_interface_again.current.nodes[0] == "103" |
| 119 |
- nm_physical_interface_again.previous.nodes[1] == nm_physical_interface_again.current.nodes[1] == "101-102" |
| 120 |
- nm_physical_interface_again.previous.interfaces == nm_physical_interface_again.current.interfaces == "1/3" |
| 121 |
- nm_physical_interface_again.previous.policy == nm_physical_interface_again.current.policy |
| 122 |
- nm_physical_interface_again.previous.uuid == nm_physical_interface.current.uuid |
| 123 |
- nm_physical_interface_again.current.uuid is defined |
| 124 |
|
| 125 |
- name: Create Physical Interface of type 'physical' with physical policy |
| 126 |
cisco.mso.ndo_physical_interface: &add_physical_interface3 |
| 127 |
<<: *mso_info |
| 128 |
template: ansible_fabric_resource_policy_template |
| 129 |
name: ansible_physical_interface_with_policy |
| 130 |
nodes: 109 |
| 131 |
interfaces: ['1/9'] |
| 132 |
physical_interface_type: physical |
| 133 |
physical_policy: |
| 134 |
template: ansible_fabric_policy_template |
| 135 |
name: ansible_interface_policy_group |
| 136 |
state: present |
| 137 |
register: add_physical_interface_with_policy |
| 138 |
|
| 139 |
- name: Assert Physical Interface of type 'physical' is created with policy |
| 140 |
ansible.builtin.assert: |
| 141 |
that: |
| 142 |
- add_physical_interface_with_policy is changed |
| 143 |
- add_physical_interface_with_policy.previous == {} |
| 144 |
- add_physical_interface_with_policy.current.name == "ansible_physical_interface_with_policy" |
| 145 |
- add_physical_interface_with_policy.current.policyGroupType == "physical" |
| 146 |
- add_physical_interface_with_policy.current.nodes | length == 1 |
| 147 |
- add_physical_interface_with_policy.current.nodes[0] == "109" |
| 148 |
- add_physical_interface_with_policy.current.interfaces == "1/9" |
| 149 |
- add_physical_interface_with_policy.current.policy is defined |
| 150 |
- add_physical_interface_with_policy.current.uuid is defined |
| 151 |
|
| 152 |
- name: Create Physical Interface of type 'breakout' (check mode) |
| 153 |
cisco.mso.ndo_physical_interface: &add_physical_interface_breakout |
| 154 |
<<: *mso_info |
| 155 |
template: ansible_fabric_resource_policy_template |
| 156 |
name: ansible_physical_interface_2 |
| 157 |
description: "Breakout type Physical Interface" |
| 158 |
nodes: [101, 102] |
| 159 |
interfaces: |
| 160 |
- 1/1 |
| 161 |
- 1/2-4 |
| 162 |
physical_interface_type: breakout |
| 163 |
breakout_mode: 4x10G |
| 164 |
state: present |
| 165 |
interface_descriptions: |
| 166 |
- interface_id: "1/1" |
| 167 |
description: "First interface" |
| 168 |
check_mode: true |
| 169 |
register: cm_physical_interface_2 |
| 170 |
|
| 171 |
- name: Create Physical Interface of type 'breakout' |
| 172 |
cisco.mso.ndo_physical_interface: |
| 173 |
<<: *add_physical_interface_breakout |
| 174 |
register: nm_physical_interface_2 |
| 175 |
|
| 176 |
- name: Assert Physical Interface of type 'breakout' is created |
| 177 |
ansible.builtin.assert: |
| 178 |
that: |
| 179 |
- cm_physical_interface_2 is changed |
| 180 |
- nm_physical_interface_2 is changed |
| 181 |
- cm_physical_interface_2.previous == nm_physical_interface_2.previous == {} |
| 182 |
- cm_physical_interface_2.current.name == nm_physical_interface_2.current.name == "ansible_physical_interface_2" |
| 183 |
- cm_physical_interface_2.current.description == nm_physical_interface_2.current.description == "Breakout type Physical Interface" |
| 184 |
- cm_physical_interface_2.current.policyGroupType == nm_physical_interface_2.current.policyGroupType == "breakout" |
| 185 |
- cm_physical_interface_2.current.nodes | length == nm_physical_interface_2.current.nodes | length == 2 |
| 186 |
- cm_physical_interface_2.current.nodes[0] == nm_physical_interface_2.current.nodes[0] == "101" |
| 187 |
- cm_physical_interface_2.current.nodes[1] == nm_physical_interface_2.current.nodes[1] == "102" |
| 188 |
- cm_physical_interface_2.current.interfaces == nm_physical_interface_2.current.interfaces == "1/1,1/2-4" |
| 189 |
- cm_physical_interface_2.current.breakoutMode == nm_physical_interface_2.current.breakoutMode == "4x10G" |
| 190 |
- cm_physical_interface_2.current.interfaceDescriptions | length == nm_physical_interface_2.current.interfaceDescriptions | length == 1 |
| 191 |
- cm_physical_interface_2.current.interfaceDescriptions[0].interfaceID == nm_physical_interface_2.current.interfaceDescriptions[0].interfaceID == "1/1" |
| 192 |
- cm_physical_interface_2.current.interfaceDescriptions[0].description == nm_physical_interface_2.current.interfaceDescriptions[0].description == "First interface" |
| 193 |
- nm_physical_interface_2.current.uuid is defined |
| 194 |
|
| 195 |
# UPDATE |
| 196 |
- name: Update Physical Interface of type 'physical' (check mode) |
| 197 |
cisco.mso.ndo_physical_interface: &update_physical_interface |
| 198 |
<<: *add_physical_interface |
| 199 |
description: "Updated Physical Interface" |
| 200 |
nodes: 105 |
| 201 |
interfaces: |
| 202 |
- 1/5 |
| 203 |
- 2/3-5 |
| 204 |
physical_policy_uuid: '{{ add_interface_policy_group_2.current.uuid }}' |
| 205 |
interface_descriptions: |
| 206 |
- interface_id: "2/5" |
| 207 |
description: "Updated interface description" |
| 208 |
- interface_id: "2/3" |
| 209 |
description: "test description" |
| 210 |
state: present |
| 211 |
check_mode: true |
| 212 |
register: cm_physical_interface_update |
| 213 |
|
| 214 |
- name: Update Physical Interface of type 'physical' |
| 215 |
cisco.mso.ndo_physical_interface: |
| 216 |
<<: *update_physical_interface |
| 217 |
register: nm_physical_interface_update |
| 218 |
|
| 219 |
- name: Update Physical Interface of type 'physical' again |
| 220 |
cisco.mso.ndo_physical_interface: |
| 221 |
<<: *update_physical_interface |
| 222 |
register: nm_physical_interface_update_again |
| 223 |
|
| 224 |
- name: Assert Physical Interface of type 'physical' is updated |
| 225 |
ansible.builtin.assert: |
| 226 |
that: |
| 227 |
- cm_physical_interface_update is changed |
| 228 |
- nm_physical_interface_update is changed |
| 229 |
- cm_physical_interface_update.previous == nm_physical_interface_update.previous |
| 230 |
- cm_physical_interface_update.previous.name == nm_physical_interface_update.previous.name == "ansible_physical_interface" |
| 231 |
- cm_physical_interface_update.current.name == nm_physical_interface_update.current.name == "ansible_physical_interface" |
| 232 |
- cm_physical_interface_update.previous.description == nm_physical_interface_update.previous.description == "" |
| 233 |
- cm_physical_interface_update.current.description == nm_physical_interface_update.current.description == "Updated Physical Interface" |
| 234 |
- cm_physical_interface_update.previous.policyGroupType == nm_physical_interface_update.previous.policyGroupType == "physical" |
| 235 |
- cm_physical_interface_update.current.policyGroupType == nm_physical_interface_update.current.policyGroupType == "physical" |
| 236 |
- cm_physical_interface_update.previous.nodes | length == nm_physical_interface_update.previous.nodes | length == 2 |
| 237 |
- cm_physical_interface_update.current.nodes | length == nm_physical_interface_update.current.nodes | length == 1 |
| 238 |
- cm_physical_interface_update.current.nodes[0] == nm_physical_interface_update.current.nodes[0] == "105" |
| 239 |
- cm_physical_interface_update.previous.interfaces == nm_physical_interface_update.previous.interfaces == "1/3" |
| 240 |
- cm_physical_interface_update.current.interfaces == nm_physical_interface_update.current.interfaces == "1/5,2/3-5" |
| 241 |
- cm_physical_interface_update.previous.policy == nm_physical_interface_update.previous.policy |
| 242 |
- cm_physical_interface_update.current.policy == nm_physical_interface_update.current.policy |
| 243 |
- cm_physical_interface_update.current.policy != cm_physical_interface_update.previous.policy |
| 244 |
- nm_physical_interface_update.current.policy != nm_physical_interface_update.previous.policy |
| 245 |
- cm_physical_interface_update.previous.interfaceDescriptions == nm_physical_interface_update.previous.interfaceDescriptions == None |
| 246 |
- cm_physical_interface_update.current.interfaceDescriptions | length == nm_physical_interface_update.current.interfaceDescriptions | length == 2 |
| 247 |
- cm_physical_interface_update.current.interfaceDescriptions[0].interfaceID == nm_physical_interface_update.current.interfaceDescriptions[0].interfaceID == "2/5" |
| 248 |
- cm_physical_interface_update.current.interfaceDescriptions[0].description == nm_physical_interface_update.current.interfaceDescriptions[0].description == "Updated interface description" |
| 249 |
- cm_physical_interface_update.current.interfaceDescriptions[1].interfaceID == nm_physical_interface_update.current.interfaceDescriptions[1].interfaceID == "2/3" |
| 250 |
- cm_physical_interface_update.current.interfaceDescriptions[1].description == nm_physical_interface_update.current.interfaceDescriptions[1].description == "test description" |
| 251 |
- cm_physical_interface_update.current.uuid is defined |
| 252 |
- nm_physical_interface_update_again is not changed |
| 253 |
- nm_physical_interface_update_again.previous.name == nm_physical_interface_update_again.current.name == "ansible_physical_interface" |
| 254 |
- nm_physical_interface_update_again.previous.description == nm_physical_interface_update_again.current.description == "Updated Physical Interface" |
| 255 |
- nm_physical_interface_update_again.previous.policyGroupType == nm_physical_interface_update_again.current.policyGroupType == "physical" |
| 256 |
- nm_physical_interface_update_again.previous.nodes | length == nm_physical_interface_update_again.current.nodes | length == 1 |
| 257 |
- nm_physical_interface_update_again.previous.interfaces == nm_physical_interface_update_again.current.interfaces == "1/5,2/3-5" |
| 258 |
- nm_physical_interface_update_again.previous.interfaceDescriptions | length == nm_physical_interface_update_again.current.interfaceDescriptions | length == 2 |
| 259 |
- nm_physical_interface_update_again.previous.policy == nm_physical_interface_update_again.current.policy |
| 260 |
- nm_physical_interface_update_again.previous.uuid == nm_physical_interface_update.current.uuid |
| 261 |
- nm_physical_interface_update_again.current.uuid is defined |
| 262 |
|
| 263 |
- name: Update name Physical Interface of type 'breakout' with UUID and change breakout mode |
| 264 |
cisco.mso.ndo_physical_interface: &update_physical_interface_uuid |
| 265 |
<<: *add_physical_interface_breakout |
| 266 |
name: "ansible_physical_interface_changed" |
| 267 |
uuid: "{{ nm_physical_interface_2.current.uuid }}" |
| 268 |
breakout_mode: 4x25G |
| 269 |
register: update_physical_interface_name |
| 270 |
|
| 271 |
- name: Assert Physical Interface of type 'breakout' is updated breakout_mode and name with UUID |
| 272 |
ansible.builtin.assert: |
| 273 |
that: |
| 274 |
- update_physical_interface_name is changed |
| 275 |
- update_physical_interface_name.previous.name == "ansible_physical_interface_2" |
| 276 |
- update_physical_interface_name.current.name == "ansible_physical_interface_changed" |
| 277 |
- update_physical_interface_name.previous.breakoutMode == "4x10G" |
| 278 |
- update_physical_interface_name.current.breakoutMode == "4x25G" |
| 279 |
- update_physical_interface_name.previous.description == update_physical_interface_name.current.description == "Breakout type Physical Interface" |
| 280 |
- update_physical_interface_name.previous.policyGroupType == update_physical_interface_name.current.policyGroupType == "breakout" |
| 281 |
- update_physical_interface_name.previous.nodes | length == update_physical_interface_name.current.nodes | length == 2 |
| 282 |
- update_physical_interface_name.previous.interfaces == update_physical_interface_name.current.interfaces == "1/1,1/2-4" |
| 283 |
- update_physical_interface_name.previous.uuid is defined |
| 284 |
- update_physical_interface_name.current.uuid is defined |
| 285 |
|
| 286 |
# QUERY |
| 287 |
- name: Query one Physical Interface with name |
| 288 |
cisco.mso.ndo_physical_interface: |
| 289 |
<<: *mso_info |
| 290 |
template: ansible_fabric_resource_policy_template |
| 291 |
name: ansible_physical_interface |
| 292 |
state: query |
| 293 |
register: query_physical_interface_with_name |
| 294 |
|
| 295 |
- name: Query one Physical Interface with UUID |
| 296 |
cisco.mso.ndo_physical_interface: |
| 297 |
<<: *mso_info |
| 298 |
template: ansible_fabric_resource_policy_template |
| 299 |
uuid: '{{update_physical_interface_name.current.uuid}}' |
| 300 |
state: query |
| 301 |
register: query_physical_interface_with_uuid |
| 302 |
|
| 303 |
- name: Query all physical interfaces in ansible_fabric_resource_policy_template |
| 304 |
cisco.mso.ndo_physical_interface: &query_all_physical_interface |
| 305 |
<<: *mso_info |
| 306 |
template: ansible_fabric_resource_policy_template |
| 307 |
state: query |
| 308 |
register: query_all_physical_interfaces |
| 309 |
|
| 310 |
- name: Assert Physical Interface of type 'physical' is queried |
| 311 |
ansible.builtin.assert: |
| 312 |
that: |
| 313 |
- query_physical_interface_with_name is not changed |
| 314 |
- query_physical_interface_with_uuid is not changed |
| 315 |
- query_all_physical_interfaces is not changed |
| 316 |
- query_physical_interface_with_name.current.name == "ansible_physical_interface" |
| 317 |
- query_physical_interface_with_name.current.description == "Updated Physical Interface" |
| 318 |
- query_physical_interface_with_name.current.policyGroupType == "physical" |
| 319 |
- query_physical_interface_with_name.current.nodes | length == 1 |
| 320 |
- query_physical_interface_with_name.current.nodes[0] == "105" |
| 321 |
- query_physical_interface_with_name.current.interfaces == "1/5,2/3-5" |
| 322 |
- query_physical_interface_with_name.current.uuid is defined |
| 323 |
- query_physical_interface_with_name.current.policy is defined |
| 324 |
- query_physical_interface_with_name.current.interfaceDescriptions | length == 2 |
| 325 |
- query_physical_interface_with_uuid.current.name == "ansible_physical_interface_changed" |
| 326 |
- query_physical_interface_with_uuid.current.breakoutMode == "4x25G" |
| 327 |
- query_physical_interface_with_uuid.current.description == "Breakout type Physical Interface" |
| 328 |
- query_physical_interface_with_uuid.current.policyGroupType == "breakout" |
| 329 |
- query_physical_interface_with_uuid.current.nodes | length == 2 |
| 330 |
- query_physical_interface_with_uuid.current.nodes[0] == "101" |
| 331 |
- query_physical_interface_with_uuid.current.nodes[1] == "102" |
| 332 |
- query_physical_interface_with_uuid.current.interfaces == "1/1,1/2-4" |
| 333 |
- query_physical_interface_with_uuid.current.interfaceDescriptions | length == 1 |
| 334 |
- query_physical_interface_with_uuid.current.interfaceDescriptions[0].interfaceID == "1/1" |
| 335 |
- query_physical_interface_with_uuid.current.interfaceDescriptions[0].description == "First interface" |
| 336 |
- query_physical_interface_with_uuid.current.uuid is defined |
| 337 |
- query_all_physical_interfaces.current | length == 3 |
| 338 |
- query_all_physical_interfaces.current[0].name == "ansible_physical_interface" |
| 339 |
- query_all_physical_interfaces.current[1].name == "ansible_physical_interface_with_policy" |
| 340 |
- query_all_physical_interfaces.current[2].name == "ansible_physical_interface_changed" |
| 341 |
|
| 342 |
- name: Update interface descriptions of Physical Interface of type 'breakout' |
| 343 |
cisco.mso.ndo_physical_interface: |
| 344 |
<<: *update_physical_interface_uuid |
| 345 |
interface_descriptions: |
| 346 |
- interface_id: "1/1" |
| 347 |
description: "Updated interface description" |
| 348 |
- interface_id: "1/2" |
| 349 |
description: "Updated interface description 2" |
| 350 |
register: update_interface_description |
| 351 |
|
| 352 |
- name: Assert updating with interface descriptions of Physical Interface of type 'breakout' |
| 353 |
ansible.builtin.assert: |
| 354 |
that: |
| 355 |
- update_interface_description is changed |
| 356 |
- update_interface_description.previous.name == "ansible_physical_interface_changed" |
| 357 |
- update_interface_description.current.name == "ansible_physical_interface_changed" |
| 358 |
- update_interface_description.previous.breakoutMode == "4x25G" |
| 359 |
- update_interface_description.current.breakoutMode == "4x25G" |
| 360 |
- update_interface_description.previous.interfaceDescriptions | length == 1 |
| 361 |
- update_interface_description.current.interfaceDescriptions | length == 2 |
| 362 |
- update_interface_description.current.interfaceDescriptions[0].interfaceID == "1/1" |
| 363 |
- update_interface_description.current.interfaceDescriptions[0].description == "Updated interface description" |
| 364 |
- update_interface_description.current.interfaceDescriptions[1].interfaceID == "1/2" |
| 365 |
- update_interface_description.current.interfaceDescriptions[1].description == "Updated interface description 2" |
| 366 |
|
| 367 |
# Remove interface descriptions |
| 368 |
- name: Update Physical Interface of type 'breakout' by removing interface interface_descriptions |
| 369 |
cisco.mso.ndo_physical_interface: |
| 370 |
<<: *update_physical_interface_uuid |
| 371 |
interface_descriptions: [] |
| 372 |
register: rm_physical_interface_name_interface_descriptions |
| 373 |
|
| 374 |
- name: Assert Physical Interface of type 'breakout' is updated by removing interface interface_descriptions |
| 375 |
ansible.builtin.assert: |
| 376 |
that: |
| 377 |
- rm_physical_interface_name_interface_descriptions is changed |
| 378 |
- rm_physical_interface_name_interface_descriptions.previous.name == "ansible_physical_interface_changed" |
| 379 |
- rm_physical_interface_name_interface_descriptions.current.name == "ansible_physical_interface_changed" |
| 380 |
- rm_physical_interface_name_interface_descriptions.previous.breakoutMode == "4x25G" |
| 381 |
- rm_physical_interface_name_interface_descriptions.current.breakoutMode == "4x25G" |
| 382 |
- rm_physical_interface_name_interface_descriptions.previous.interfaceDescriptions | length == 2 |
| 383 |
- rm_physical_interface_name_interface_descriptions.previous.uuid is defined |
| 384 |
- rm_physical_interface_name_interface_descriptions.current.uuid is defined |
| 385 |
- rm_physical_interface_name_interface_descriptions.current.interfaceDescriptions == None |
| 386 |
|
| 387 |
# Errors |
| 388 |
|
| 389 |
# Create errors |
| 390 |
- name: Create Physical Interface without nodes |
| 391 |
cisco.mso.ndo_physical_interface: |
| 392 |
<<: *mso_info |
| 393 |
template: ansible_fabric_resource_policy_template |
| 394 |
name: ansible_physical_interface_invalid |
| 395 |
interfaces: ['1/1'] |
| 396 |
state: present |
| 397 |
ignore_errors: true |
| 398 |
register: create_physical_interface_without_nodes |
| 399 |
|
| 400 |
- name: Set error message for create_physical_interface_without_nodes |
| 401 |
ansible.builtin.set_fact: |
| 402 |
error_message_create_physical_interface_without_nodes: "ERROR: Missing 'nodes' for creating a Physical Interface." |
| 403 |
|
| 404 |
- name: Assert creating Physical Interface with invalid attributes |
| 405 |
ansible.builtin.assert: |
| 406 |
that: |
| 407 |
- create_physical_interface_without_nodes is failed |
| 408 |
- create_physical_interface_without_nodes.msg == error_message_create_physical_interface_without_nodes |
| 409 |
|
| 410 |
- name: Create Physical Interface without_interface_type |
| 411 |
cisco.mso.ndo_physical_interface: |
| 412 |
<<: *mso_info |
| 413 |
template: ansible_fabric_resource_policy_template |
| 414 |
name: ansible_physical_interface_invalid |
| 415 |
nodes: 103 |
| 416 |
interfaces: ['1/1'] |
| 417 |
state: present |
| 418 |
ignore_errors: true |
| 419 |
register: create_physical_interface_without_interface_type |
| 420 |
|
| 421 |
- name: Set error message for create_physical_interface_without_interface_type |
| 422 |
ansible.builtin.set_fact: |
| 423 |
error_message_create_physical_interface_without_interface_type: "ERROR: Missing Physical Interface type for creating a Physical Interface." |
| 424 |
|
| 425 |
- name: Assert creating Physical Interface with invalid attributes |
| 426 |
ansible.builtin.assert: |
| 427 |
that: |
| 428 |
- create_physical_interface_without_interface_type is failed |
| 429 |
- create_physical_interface_without_interface_type.msg == error_message_create_physical_interface_without_interface_type |
| 430 |
|
| 431 |
# Update errors |
| 432 |
- name: Update interfaces without updating the Physical Interface type |
| 433 |
cisco.mso.ndo_physical_interface: |
| 434 |
<<: *update_physical_interface |
| 435 |
physical_interface_type: breakout |
| 436 |
ignore_errors: true |
| 437 |
register: create_physical_interface_invalid_type |
| 438 |
|
| 439 |
- name: Set error message for create_physical_interface_invalid_type |
| 440 |
ansible.builtin.set_fact: |
| 441 |
error_message_create_physical_interface_invalid_type: "ERROR: Physical Interface type cannot be changed." |
| 442 |
|
| 443 |
- name: Assert updating interfaces without updating the Physical Interface type |
| 444 |
ansible.builtin.assert: |
| 445 |
that: |
| 446 |
- create_physical_interface_invalid_type is failed |
| 447 |
- create_physical_interface_invalid_type.msg == error_message_create_physical_interface_invalid_type |
| 448 |
|
| 449 |
# DELETE |
| 450 |
- name: Delete Physical Interface of type 'physical' (check mode) |
| 451 |
cisco.mso.ndo_physical_interface: &delete_physical_interface |
| 452 |
<<: *mso_info |
| 453 |
template: ansible_fabric_resource_policy_template |
| 454 |
name: ansible_physical_interface |
| 455 |
state: absent |
| 456 |
check_mode: true |
| 457 |
register: cm_delete_physical_interface |
| 458 |
|
| 459 |
- name: Delete Physical Interface of type 'physical' |
| 460 |
cisco.mso.ndo_physical_interface: |
| 461 |
<<: *delete_physical_interface |
| 462 |
register: nm_delete_physical_interface |
| 463 |
|
| 464 |
- name: Delete Physical Interface of type 'physical' again |
| 465 |
cisco.mso.ndo_physical_interface: |
| 466 |
<<: *delete_physical_interface |
| 467 |
register: nm_delete_physical_interface_again |
| 468 |
|
| 469 |
- name: Assert Physical Interface of type 'physical' is deleted |
| 470 |
ansible.builtin.assert: |
| 471 |
that: |
| 472 |
- cm_delete_physical_interface is changed |
| 473 |
- nm_delete_physical_interface is changed |
| 474 |
- cm_delete_physical_interface.current == nm_delete_physical_interface.current == {} |
| 475 |
- cm_delete_physical_interface.previous == nm_delete_physical_interface.previous |
| 476 |
- cm_delete_physical_interface.previous.name == nm_delete_physical_interface.previous.name == "ansible_physical_interface" |
| 477 |
- cm_delete_physical_interface.previous.policyGroupType == nm_delete_physical_interface.previous.policyGroupType == "physical" |
| 478 |
- cm_delete_physical_interface.previous.uuid is defined |
| 479 |
- nm_delete_physical_interface_again is not changed |
| 480 |
- nm_delete_physical_interface_again.previous == nm_delete_physical_interface_again.current == {} |
| 481 |
- nm_delete_physical_interface_again.current.uuid is not defined |
| 482 |
|
| 483 |
- name: Delete Physical Interface of type 'breakout' with UUID |
| 484 |
cisco.mso.ndo_physical_interface: |
| 485 |
<<: *mso_info |
| 486 |
template: ansible_fabric_resource_policy_template |
| 487 |
uuid: "{{ rm_physical_interface_name_interface_descriptions.current.uuid }}" |
| 488 |
state: absent |
| 489 |
register: delete_physical_interface_uuid |
| 490 |
|
| 491 |
- name: Assert Physical Interface of type 'breakout' is deleted with UUID |
| 492 |
ansible.builtin.assert: |
| 493 |
that: |
| 494 |
- delete_physical_interface_uuid is changed |
| 495 |
- delete_physical_interface_uuid.previous.name == "ansible_physical_interface_changed" |
| 496 |
- delete_physical_interface_uuid.current == {} |
| 497 |
- delete_physical_interface_uuid.previous.policyGroupType == "breakout" |
| 498 |
- delete_physical_interface_uuid.previous.uuid is defined |
| 499 |
|
| 500 |
# Errors and no policies found |
| 501 |
- name: Delete Physical Interface of type 'physical' when all are deleted |
| 502 |
cisco.mso.ndo_physical_interface: |
| 503 |
<<: *add_physical_interface3 |
| 504 |
state: absent |
| 505 |
register: nm_delete_last_physical_interface |
| 506 |
|
| 507 |
- name: Query all Physical Interface in the template when all are deleted |
| 508 |
cisco.mso.ndo_physical_interface: |
| 509 |
<<: *query_all_physical_interface |
| 510 |
register: query_all_none |
| 511 |
|
| 512 |
- name: Update Physical Interface with non-existing UUID |
| 513 |
cisco.mso.ndo_physical_interface: |
| 514 |
<<: *mso_info |
| 515 |
template: ansible_fabric_resource_policy_template |
| 516 |
uuid: non-existing-uuid |
| 517 |
state: present |
| 518 |
ignore_errors: true |
| 519 |
register: update_non_existing_uuid |
| 520 |
|
| 521 |
- name: Set error message for non_existing_uuid |
| 522 |
ansible.builtin.set_fact: |
| 523 |
error_message_non_existing_uuid: "Physical Interface Profile with the UUID: 'non-existing-uuid' not found" |
| 524 |
|
| 525 |
- name: Assert no Physical Interface found |
| 526 |
assert: |
| 527 |
that: |
| 528 |
- nm_delete_last_physical_interface is changed |
| 529 |
- nm_delete_last_physical_interface.previous.name == "ansible_physical_interface_with_policy" |
| 530 |
- nm_delete_last_physical_interface.previous.policyGroupType == "physical" |
| 531 |
- nm_delete_last_physical_interface.current == {} |
| 532 |
- query_all_none is not changed |
| 533 |
- query_all_none.current == [] |
| 534 |
- update_non_existing_uuid is failed |
| 535 |
- update_non_existing_uuid.msg == error_message_non_existing_uuid |
| 536 |
|
| 537 |
# CLEANUP TEMPLATE |
| 538 |
|
| 539 |
- name: Ensure fabric resource policy template do not exist |
| 540 |
cisco.mso.ndo_template: |
| 541 |
<<: *template_absent |
| 542 |
|
| 543 |
- name: Ensure fabric policy template does not exist |
| 544 |
cisco.mso.ndo_template: |
| 545 |
<<: *fabric_policy_template_absent |