-
Notifications
You must be signed in to change notification settings - Fork 138
libvirt_manager: Add boot_order configuration support #3413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hjensas
wants to merge
1
commit into
openstack-k8s-operators:main
Choose a base branch
from
hjensas:boot-order
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
# Copyright 2025 Red Hat, Inc. | ||
# All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
- name: Cleanup | ||
vars: | ||
molecule_scenario: boot_order | ||
ansible.builtin.import_playbook: ../deploy_layout/cleanup.yml |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,238 @@ | ||
--- | ||
# Copyright 2025 Red Hat, Inc. | ||
# All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
- name: Test boot_order configuration | ||
hosts: instance | ||
gather_facts: true | ||
vars_files: | ||
- vars/net-def.yml | ||
vars: | ||
ansible_user_dir: "{{ lookup('env', 'HOME') }}" | ||
cifmw_basedir: "/opt/basedir" | ||
cifmw_libvirt_manager_configuration: | ||
vms: | ||
# Test VM with disk first, then network boot | ||
disk_first: | ||
amount: 1 | ||
disksize: 10 | ||
memory: 1 | ||
cpus: 1 | ||
disk_file_name: 'blank' | ||
boot_order: | ||
- hd | ||
- network | ||
nets: | ||
- public | ||
- osp_trunk | ||
# Test VM with network first, then disk boot | ||
net_first: | ||
amount: 1 | ||
disksize: 10 | ||
memory: 1 | ||
cpus: 1 | ||
disk_file_name: 'blank' | ||
boot_order: | ||
- network | ||
- disk | ||
nets: | ||
- public | ||
- osp_trunk | ||
# Test VM with only network boot | ||
net_only: | ||
amount: 1 | ||
disksize: 10 | ||
memory: 1 | ||
cpus: 1 | ||
disk_file_name: 'blank' | ||
boot_order: | ||
- network | ||
nets: | ||
- public | ||
# Test VM without boot_order (should not have boot order attributes) | ||
no_boot_order: | ||
amount: 1 | ||
disksize: 10 | ||
memory: 1 | ||
cpus: 1 | ||
disk_file_name: 'blank' | ||
nets: | ||
- public | ||
networks: | ||
public: |- | ||
<network> | ||
<name>public</name> | ||
<forward mode='nat'/> | ||
<bridge name='public' stp='on' delay='0'/> | ||
<dns enable="no"/> | ||
<ip | ||
family='ipv4' | ||
address='{{ _networks.public.range | ansible.utils.nthhost(1) }}' | ||
prefix='24'> | ||
</ip> | ||
</network> | ||
osp_trunk: |- | ||
<network> | ||
<name>osp_trunk</name> | ||
<forward mode='nat'/> | ||
<bridge name='osp_trunk' stp='on' delay='0'/> | ||
<dns enable="no"/> | ||
<ip | ||
family='ipv4' | ||
address='{{ _networks.osp_trunk.range | ansible.utils.nthhost(1) }}' | ||
prefix='24'> | ||
</ip> | ||
</network> | ||
tasks: | ||
- name: Load networking definition | ||
ansible.builtin.include_vars: | ||
file: input.yml | ||
name: cifmw_networking_definition | ||
|
||
- name: Deploy layout with boot_order configurations | ||
ansible.builtin.import_role: | ||
name: libvirt_manager | ||
tasks_from: deploy_layout | ||
|
||
- name: Verify boot_order configurations | ||
block: | ||
# Test 1: Verify disk-first VM has correct boot order | ||
- name: Get disk_first VM XML | ||
register: _disk_first_xml | ||
community.libvirt.virt: | ||
command: "get_xml" | ||
name: "cifmw-disk-first-0" | ||
uri: "qemu:///system" | ||
|
||
- name: Check disk boot order in disk-first VM | ||
register: _disk_first_disk_boot | ||
community.general.xml: | ||
xmlstring: "{{ _disk_first_xml.get_xml }}" | ||
xpath: "/domain/devices/disk[@device='disk']/boot" | ||
content: "attribute" | ||
|
||
- name: Check interface boot order in disk-first VM | ||
register: _disk_first_net_boot | ||
community.general.xml: | ||
xmlstring: "{{ _disk_first_xml.get_xml }}" | ||
xpath: "/domain/devices/interface[1]/boot" | ||
content: "attribute" | ||
|
||
- name: Assert disk-first VM has correct boot order | ||
ansible.builtin.assert: | ||
that: | ||
- _disk_first_disk_boot.matches[0].boot.order == "1" | ||
- _disk_first_net_boot.matches[0].boot.order == "2" | ||
quiet: true | ||
msg: >- | ||
Expected disk boot order=1 and network boot order=2, | ||
got disk={{ _disk_first_disk_boot.matches[0].boot.order }} | ||
and network={{ _disk_first_net_boot.matches[0].boot.order }} | ||
|
||
# Test 2: Verify network-first VM has correct boot order | ||
- name: Get net_first VM XML | ||
register: _net_first_xml | ||
community.libvirt.virt: | ||
command: "get_xml" | ||
name: "cifmw-net-first-0" | ||
uri: "qemu:///system" | ||
|
||
- name: Check disk boot order in network-first VM | ||
register: _net_first_disk_boot | ||
community.general.xml: | ||
xmlstring: "{{ _net_first_xml.get_xml }}" | ||
xpath: "/domain/devices/disk[@device='disk']/boot" | ||
content: "attribute" | ||
|
||
- name: Check interface boot order in network-first VM | ||
register: _net_first_net_boot | ||
community.general.xml: | ||
xmlstring: "{{ _net_first_xml.get_xml }}" | ||
xpath: "/domain/devices/interface[1]/boot" | ||
content: "attribute" | ||
|
||
- name: Assert network-first VM has correct boot order | ||
ansible.builtin.assert: | ||
that: | ||
- _net_first_net_boot.matches[0].boot.order == "1" | ||
- _net_first_disk_boot.matches[0].boot.order == "2" | ||
quiet: true | ||
msg: >- | ||
Expected network boot order=1 and disk boot order=2, | ||
got network={{ _net_first_net_boot.matches[0].boot.order }} | ||
and disk={{ _net_first_disk_boot.matches[0].boot.order }} | ||
|
||
# Test 3: Verify network-only VM has only network boot | ||
- name: Get net_only VM XML | ||
register: _net_only_xml | ||
community.libvirt.virt: | ||
command: "get_xml" | ||
name: "cifmw-net-only-0" | ||
uri: "qemu:///system" | ||
|
||
- name: Check interface boot order in network-only VM | ||
register: _net_only_net_boot | ||
community.general.xml: | ||
xmlstring: "{{ _net_only_xml.get_xml }}" | ||
xpath: "/domain/devices/interface[1]/boot" | ||
content: "attribute" | ||
|
||
- name: Check disk boot order in network-only VM (should not exist) | ||
register: _net_only_disk_boot | ||
failed_when: false | ||
community.general.xml: | ||
xmlstring: "{{ _net_only_xml.get_xml }}" | ||
xpath: "/domain/devices/disk[@device='disk']/boot" | ||
content: "attribute" | ||
|
||
- name: Assert network-only VM has correct boot order | ||
ansible.builtin.assert: | ||
that: | ||
- _net_only_net_boot.matches[0].boot.order == "1" | ||
- _net_only_disk_boot.matches | default([]) | length == 0 | ||
quiet: true | ||
msg: >- | ||
Expected only network boot with order=1, | ||
got network={{ _net_only_net_boot.matches[0].boot.order }} | ||
and disk boot count={{ _net_only_disk_boot.matches | default([]) | length }} | ||
|
||
# Test 4: Verify VM without boot_order has no boot order attributes | ||
- name: Get no_boot_order VM XML | ||
register: _no_boot_order_xml | ||
community.libvirt.virt: | ||
command: "get_xml" | ||
name: "cifmw-no-boot-order-0" | ||
uri: "qemu:///system" | ||
|
||
- name: Check for any boot order attributes in no-boot-order VM | ||
register: _no_boot_order_check | ||
failed_when: false | ||
community.general.xml: | ||
xmlstring: "{{ _no_boot_order_xml.get_xml }}" | ||
xpath: "/domain/devices//boot" | ||
content: "attribute" | ||
|
||
- name: Assert no-boot-order VM has no boot order attributes | ||
ansible.builtin.assert: | ||
that: | ||
- _no_boot_order_check.matches | default([]) | length == 0 | ||
quiet: true | ||
msg: >- | ||
Expected no boot order attributes, | ||
but found {{ _no_boot_order_check.matches | default([]) | length }} boot elements | ||
|
||
- name: Output success message | ||
ansible.builtin.debug: | ||
msg: "All boot_order validations passed successfully!" |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
log: true | ||
|
||
provisioner: | ||
name: ansible | ||
log: true |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
# Copyright 2025 Red Hat, Inc. | ||
# All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
|
||
- name: Prepare | ||
ansible.builtin.import_playbook: ../deploy_layout/prepare.yml |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
# Copyright 2025 Red Hat, Inc. | ||
# All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
networks: | ||
ctlplane: | ||
network: "192.168.140.0/24" | ||
gateway: "192.168.140.1" | ||
mtu: 1500 | ||
group-templates: | ||
disk_firsts: | ||
network-template: | ||
range: | ||
start: 10 | ||
length: 1 | ||
networks: | ||
ctlplane: {} | ||
net_firsts: | ||
network-template: | ||
range: | ||
start: 20 | ||
length: 1 | ||
networks: | ||
ctlplane: {} | ||
net_onlys: | ||
network-template: | ||
range: | ||
start: 30 | ||
length: 1 | ||
networks: | ||
ctlplane: {} | ||
no_boot_orders: | ||
network-template: | ||
range: | ||
start: 40 | ||
length: 1 | ||
networks: | ||
ctlplane: {} |
23 changes: 23 additions & 0 deletions
23
roles/libvirt_manager/molecule/boot_order/vars/net-def.yml
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
# Copyright 2025 Red Hat, Inc. | ||
# All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
_networks: | ||
osp_trunk: | ||
default: true | ||
range: "192.168.140.0/24" | ||
mtu: 1500 | ||
public: | ||
range: "192.168.110.0/24" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.