Implement full support for network configuration - #196
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds end-to-end network configuration support to the fog-libvirt compute provider by introducing a richer Network model that can parse/build libvirt network XML and persist changes via full re-defines and (when possible) libvirt “section update” fragment updates.
Changes:
- Expanded
Fog::Libvirt::Compute::Networkto support most libvirt network XML features (parse + generate + incremental updates). - Added new compute requests to define/create/update networks, update autostart, and apply section updates.
- Replaced the old Shindo network model test with a comprehensive Minitest suite covering XML round-tripping, lifecycle, and fragment updates.
Reviewed changes
Copilot reviewed 35 out of 35 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/libvirt/models/compute/network_tests.rb | Removes legacy Shindo network model coverage (superseded by Minitest suite). |
| minitests/network/network_test.rb | Adds extensive Minitest coverage for network XML, lifecycle, and partial updates. |
| lib/fog/libvirt/requests/compute/update_network.rb | Implements full network replacement logic (destroy/undefine + create/define). |
| lib/fog/libvirt/requests/compute/update_network_section.rb | Adds libvirt network section update request wrapper (modify/add/delete). |
| lib/fog/libvirt/requests/compute/update_network_autostart.rb | Adds request to toggle network autostart flag. |
| lib/fog/libvirt/requests/compute/list_networks.rb | Enhances listing to include state flags and preloaded parsed XML attributes. |
| lib/fog/libvirt/requests/compute/define_network.rb | Adds request to define a persistent network from XML. |
| lib/fog/libvirt/requests/compute/create_network.rb | Adds request to create a transient network from XML. |
| lib/fog/libvirt/models/compute/util/util.rb | Adds XML/key normalization helpers and generic casting/compare utilities. |
| lib/fog/libvirt/models/compute/network/vlan.rb | Adds VLAN model + XML parse/build support. |
| lib/fog/libvirt/models/compute/network/vlan_tag.rb | Adds VLAN tag model + normalization. |
| lib/fog/libvirt/models/compute/network/virtualport.rb | Adds virtualport model + XML parse/build support. |
| lib/fog/libvirt/models/compute/network/route.rb | Adds route model + XML parse/build support. |
| lib/fog/libvirt/models/compute/network/portgroup.rb | Adds portgroup model with fragment-update support. |
| lib/fog/libvirt/models/compute/network/pci_address.rb | Adds PCI address model for forward/address sections. |
| lib/fog/libvirt/models/compute/network/nat.rb | Adds NAT model including range normalization for addresses/ports. |
| lib/fog/libvirt/models/compute/network/ip.rb | Adds IP model with nested DHCP + fragment-only detection. |
| lib/fog/libvirt/models/compute/network/forward.rb | Adds forward model with NAT/interfaces/addresses support and fragment updates. |
| lib/fog/libvirt/models/compute/network/forward_interface.rb | Adds forward interface model + fragment update behavior. |
| lib/fog/libvirt/models/compute/network/domain.rb | Adds domain model + XML parse/build support. |
| lib/fog/libvirt/models/compute/network/dnsmasq.rb | Adds dnsmasq namespace/options model. |
| lib/fog/libvirt/models/compute/network/dns.rb | Adds DNS model + fragment-update orchestration for hosts/txt/srv. |
| lib/fog/libvirt/models/compute/network/dns_txt.rb | Adds DNS TXT record model + fragment update support. |
| lib/fog/libvirt/models/compute/network/dns_srv.rb | Adds DNS SRV record model + fragment update support. |
| lib/fog/libvirt/models/compute/network/dns_host.rb | Adds DNS host record model + fragment update support. |
| lib/fog/libvirt/models/compute/network/dns_forwarder.rb | Adds DNS forwarder model + normalization. |
| lib/fog/libvirt/models/compute/network/dhcp.rb | Adds DHCP model (ranges/hosts/bootp) + fragment updates. |
| lib/fog/libvirt/models/compute/network/dhcp_range.rb | Adds DHCP range model + XML parse/build. |
| lib/fog/libvirt/models/compute/network/dhcp_lease.rb | Adds DHCP lease model + XML parse/build. |
| lib/fog/libvirt/models/compute/network/dhcp_host.rb | Adds DHCP host model + XML parse/build. |
| lib/fog/libvirt/models/compute/network/bridge.rb | Adds bridge model + XML parse/build. |
| lib/fog/libvirt/models/compute/network/bandwidth.rb | Adds bandwidth model + XML parse/build. |
| lib/fog/libvirt/models/compute/network.rb | Major network model expansion: attributes, XML round-trip, save/reload, fragment updates. |
| lib/fog/libvirt/models/compute/attribute_model.rb | Introduces base model for attribute-only nested objects + equality semantics. |
| lib/fog/libvirt/compute.rb | Registers new compute requests for network define/create/update operations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ekohl
left a comment
There was a problem hiding this comment.
This is a very large PR. I'd appreciate splitting it in 2 parts: first rewrite the existing network tests from shindo to minitest. Then the big addition of networking. That way we can first work out the test setup part and it's easier to verify the existing tests are rewritten.
For network tests there's basically nothing, look at tests/libvirt/models/compute/network_tests.rb that's only file I deleted. It doesn't really test much and I didn't touch |
c84047a to
0acc1dc
Compare
|
I just pushed updates:
Now I think this is complete. All tests pass :) |
This PR implements full support for network configuration.
I basically implemented pretty much all of libvirt Network functionality.
Example usage:
I also added comprehensive tests that exercise all functionality. By specifying
LIBVIRT_URI=qemu:///sessionenv var you can run them against actual libvirt instance (qemu:///systemalso works)