-
Couldn't load subscription status.
- Fork 47
Implement gathering of Interface and Mac from powered off domain #190
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ac80433
added the ability to get interfaces names and mac addresses from doma…
stratus-ss 2524ae3
added doc fragments and changelogs
stratus-ss f00179b
pep8 fixes
stratus-ss dd4328b
pep8 fixes
stratus-ss 752ce7f
added the pci bus information to the dict
stratus-ss 4509042
fixed variable name to reflect pci bus and not slot
stratus-ss 22111b9
pep8 fixes
stratus-ss 37034d3
adding integration tests for the network_interfaces
stratus-ss 226848b
updated the get_interfaces() to handle macvtap and nat interfaces better
stratus-ss 02f4a66
linting fix
stratus-ss a7e0e68
more linting fixes
stratus-ss a3241cd
more linting fixes
stratus-ss 6b36bc9
python 2.7 support
stratus-ss 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| minor_changes: | ||
| - virt - implement the gathering of Dom interface names and mac addresses as per FR https://github.com/ansible-collections/community.libvirt/issues/189 |
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
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,8 @@ | ||
| --- | ||
| vm_name: fedora-test | ||
| vm_ram_mb: 256 | ||
| vm_vcpus: 1 | ||
| libvirt_disk_path: "/var/lib/libvirt/images" | ||
| libvirt_disk_size: "1" | ||
| libvirt_pool_name: "default" | ||
| mac_address: "52:54:00:94:e4:a0" |
36 changes: 36 additions & 0 deletions
36
tests/integration/targets/virt_interfaces/files/Dockerfile_Fedora
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,36 @@ | ||
| FROM fedora:latest | ||
|
|
||
| RUN dnf install @virtualization -y | ||
|
|
||
| RUN dnf update -y && \ | ||
| dnf install -y \ | ||
| bridge-utils \ | ||
| dmidecode \ | ||
| dnsmasq \ | ||
| ebtables \ | ||
| iproute \ | ||
| iptables \ | ||
| edk2-ovmf \ | ||
| qemu-kvm \ | ||
| tini \ | ||
| python3-pip \ | ||
| python3-libvirt \ | ||
| python3-lxml \ | ||
| && \ | ||
| dnf clean all | ||
|
|
||
| RUN ln -s /usr/bin/qemu-system-x86_64 /usr/libexec/qemu-kvm | ||
|
|
||
| RUN sed -i '/^#stdio_handler/ a\stdio_handler = "file"' /etc/libvirt/qemu.conf | ||
|
|
||
| COPY config/pools/* /etc/libvirt/storage/ | ||
| COPY config/networks/* /etc/libvirt/qemu/networks/ | ||
| RUN mkdir -p /etc/libvirt/storage/autostart /etc/libvirt/qemu/networks/autostart && \ | ||
| for pool in /etc/libvirt/storage/*.xml; do \ | ||
| ln -sf "../${pool##*/}" /etc/libvirt/storage/autostart/; \ | ||
| done && \ | ||
| for net in /etc/libvirt/qemu/networks/*.xml; do \ | ||
| ln -sf "../${net##*/}" /etc/libvirt/qemu/networks/autostart/; \ | ||
| done | ||
|
|
||
| CMD ["/usr/bin/tini", "/usr/sbin/libvirtd"] |
37 changes: 37 additions & 0 deletions
37
tests/integration/targets/virt_interfaces/files/Dockerfile_Ubuntu
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,37 @@ | ||
| FROM ubuntu:24.04 | ||
|
|
||
| RUN export DEBIAN_FRONTEND=noninteractive && \ | ||
| apt-get update && \ | ||
| apt-get -y install \ | ||
| bridge-utils \ | ||
| dmidecode \ | ||
| dnsmasq \ | ||
| ebtables \ | ||
| iproute2 \ | ||
| iptables \ | ||
| libvirt-clients \ | ||
| libvirt-daemon-system \ | ||
| ovmf \ | ||
| # qemu-efi \ | ||
| qemu-kvm \ | ||
| tini \ | ||
| && \ | ||
| apt-get clean | ||
|
|
||
| RUN apt install python3-pip python3-libvirt python3-lxml -y | ||
|
|
||
| RUN ln -s /usr/bin/qemu-system-amd64 /usr/libexec/qemu-kvm | ||
|
|
||
| RUN sed -i '/^#stdio_handler/ a\stdio_handler = "file"' /etc/libvirt/qemu.conf | ||
|
|
||
| COPY config/pools/* /etc/libvirt/storage/ | ||
| COPY config/networks/* /etc/libvirt/qemu/networks/ | ||
| RUN mkdir -p /etc/libvirt/storage/autostart /etc/libvirt/qemu/networks/autostart && \ | ||
| for pool in /etc/libvirt/storage/*.xml; do \ | ||
| ln -sf "../${pool##*/}" /etc/libvirt/storage/autostart/; \ | ||
| done && \ | ||
| for net in /etc/libvirt/qemu/networks/*.xml; do \ | ||
| ln -sf "../${net##*/}" /etc/libvirt/qemu/networks/autostart/; \ | ||
| done | ||
|
|
||
| CMD ["/usr/bin/tini", "/usr/sbin/libvirtd"] |
57 changes: 57 additions & 0 deletions
57
tests/integration/targets/virt_interfaces/files/vm_template.xml.j2
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,57 @@ | ||
| <domain type='kvm'> | ||
| <name>{{ vm_name }}</name> | ||
| <memory unit='MiB'>{{ vm_ram_mb }}</memory> | ||
| <vcpu placement='static'>{{ vm_vcpus }}</vcpu> | ||
| <os> | ||
| <type arch='x86_64' machine='q35'>hvm</type> | ||
| <boot dev='hd'/> | ||
| </os> | ||
| <cpu mode="host-passthrough" check="none" migratable="on"/> | ||
| <on_poweroff>destroy</on_poweroff> | ||
| <on_reboot>restart</on_reboot> | ||
| <on_crash>destroy</on_crash> | ||
| <clock offset="utc"> | ||
| <timer name="rtc" tickpolicy="catchup"/> | ||
| <timer name="pit" tickpolicy="delay"/> | ||
| <timer name="hpet" present="no"/> | ||
| </clock> | ||
| <devices> | ||
| <emulator>/usr/libexec/qemu-kvm</emulator> | ||
| <disk type='file' device='disk'> | ||
| <driver name='qemu' type='qcow2'/> | ||
| <source file='{{ libvirt_disk_path }}/{{ vm_name }}.qcow2'/> | ||
| <target dev='vda' bus='virtio'/> | ||
| <address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/> | ||
| </disk> | ||
| <channel type="unix"> | ||
| <target type="virtio" name="org.qemu.guest_agent.0"/> | ||
| <address type="virtio-serial" controller="0" bus="0" port="1"/> | ||
| </channel> | ||
| <input type='tablet' bus='usb'> | ||
| <address type='usb' bus='0' port='1'/> | ||
| </input> | ||
| <input type='mouse' bus='ps2'/> | ||
| <input type='keyboard' bus='ps2'/> | ||
| <graphics type="vnc" port="-1" autoport="yes"> | ||
| <listen type="address"/> | ||
| </graphics> | ||
| <video> | ||
| <model type="virtio" heads="1" primary="yes"/> | ||
| <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x0"/> | ||
| </video> | ||
| <memballoon model='virtio'> | ||
| <address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/> | ||
| </memballoon> | ||
| <rng model='virtio'> | ||
| <backend model='random'>/dev/urandom</backend> | ||
| <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/> | ||
| </rng> | ||
| <interface type="network"> | ||
| <mac address='{{ mac_address }}'/> | ||
| <source network="default"/> | ||
| <model type="virtio"/> | ||
| <address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/> | ||
| </interface> | ||
|
|
||
| </devices> | ||
| </domain> | ||
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,37 @@ | ||
| --- | ||
| - name: Create VM XML definition | ||
| template: | ||
| src: files/vm_template.xml.j2 | ||
| dest: "/tmp/{{ vm_name }}.xml" | ||
|
|
||
| - name: Define VM | ||
| community.libvirt.virt: | ||
| command: define | ||
| xml: "{{ lookup('file', '/tmp/' + vm_name + '.xml') }}" | ||
| uri: qemu:///system | ||
|
|
||
| - name: Validate the VM | ||
| community.libvirt.virt: | ||
| command: list_vms | ||
| register: vm_list | ||
|
|
||
| - name: Show VMs | ||
| debug: | ||
| var: vm_list | ||
|
|
||
| - name: register vm info | ||
| community.libvirt.virt: | ||
| command: get_interfaces | ||
| name: "{{ vm_name }}" | ||
| register: vminfo | ||
|
|
||
| - name: debug result | ||
| debug: | ||
| msg: "{{ vminfo }}" | ||
|
|
||
| - name: Assert Mac Address present | ||
| assert: | ||
| that: | ||
| - "vminfo['network_interfaces']['null']['mac'] == mac_address" | ||
| fail_msg: "Mac address does not match or is missing. Expected: {{ mac_address }}, Got: {{ vminfo['network_interfaces']['null']['mac'] }}" | ||
| success_msg: "Original variable from defaults: {{ mac_address }} found in netowrking output" |
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.