-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve network assertions in reproducer
We now ensure all VMs have attached networks, and we also output the built layout in case of failure. This should help debugging issues without the need to dig into the whole scenario tree.
- Loading branch information
1 parent
165952f
commit 1e197cb
Showing
2 changed files
with
58 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,58 @@ | ||
--- | ||
- name: Shared variables | ||
vars: | ||
_attached: >- | ||
{{ | ||
_cifmw_libvirt_manager_layout.vms | dict2items | | ||
map(attribute='value.nets') | flatten | unique | ||
}} | ||
_spine: >- | ||
{{ | ||
_cifmw_libvirt_manager_layout.vms | dict2items | | ||
map(attribute='value.spineleafnets', default=[]) | flatten | unique | ||
}} | ||
_all_nets: "{{ _attached + _spine }}" | ||
_defined: "{{ _cifmw_libvirt_manager_layout.networks.keys() }}" | ||
- name: Try/catch block | ||
block: | ||
- name: Ensure all standard attached networks are defined | ||
- name: Ensure all VM types have defined nets parameter | ||
ansible.builtin.assert: | ||
quiet: true | ||
that: | ||
- _all_nets | difference(_defined) | length == 0 | ||
- item.value.nets is defined | ||
msg: >- | ||
Inconsistency detected: ensure you're defining all of the | ||
attached networks. Those nets don't seem to be defined: | ||
{{ _all_nets | difference(_defined) }} | ||
Inconsistency detected: VM type "{{ item.key }}" | ||
doesn't seem to have any network. | ||
loop: "{{ _cifmw_libvirt_manager_layout.vms | dict2items }}" | ||
loop_control: | ||
label: "{{ item.key }}" | ||
|
||
- name: Ensure we don't have extra network defined | ||
ansible.builtin.assert: | ||
that: | ||
- _defined | difference(_all_nets) | length == 0 | ||
- name: Shared variables | ||
vars: | ||
_attached: >- | ||
{{ | ||
_cifmw_libvirt_manager_layout.vms | dict2items | | ||
map(attribute='value.nets') | flatten | unique | ||
}} | ||
_spine: >- | ||
{{ | ||
_cifmw_libvirt_manager_layout.vms | dict2items | | ||
map(attribute='value.spineleafnets', default=[]) | flatten | unique | ||
}} | ||
_all_nets: "{{ _attached + _spine }}" | ||
_defined: "{{ _cifmw_libvirt_manager_layout.networks.keys() }}" | ||
block: | ||
- name: Ensure all standard attached networks are defined | ||
ansible.builtin.assert: | ||
quiet: true | ||
that: | ||
- _all_nets | difference(_defined) | length == 0 | ||
msg: >- | ||
Inconsistency detected: ensure you're defining all of the | ||
attached networks. Those nets don't seem to be defined: | ||
{{ _all_nets | difference(_defined) }} | ||
- name: Ensure we don't have extra network defined | ||
ansible.builtin.assert: | ||
that: | ||
- _defined | difference(_all_nets) | length == 0 | ||
msg: >- | ||
Inconsistency detected: ensure you're attaching all of the | ||
defined networks. Those nets don't seem to be attached: | ||
{{ _defined | difference(_all_nets) }} | ||
rescue: | ||
- name: Dump built layout | ||
ansible.builtin.debug: | ||
var: _cifmw_libvirt_manager_layout | ||
|
||
- name: Fail for good | ||
ansible.builtin.fail: | ||
msg: >- | ||
Inconsistency detected: ensure you're attaching all of the | ||
defined networks. Those nets don't seem to be attached: | ||
{{ _defined | difference(_all_nets) }} | ||
Error detected, please check assertions and | ||
debugging output above. |