Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
No build reason found for standard:aarch64
systemsmanagement:Uyuni:Master:Debian11-Uyuni-Client-Tools
venv-salt-minion
virt.network_update-handle-missing-ipv4-netmask...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File virt.network_update-handle-missing-ipv4-netmask-attr.patch of Package venv-salt-minion
From c0a9915e44d4b1cbc09b5d52e7ed41ec7c29abcf Mon Sep 17 00:00:00 2001 From: Cedric Bosdonnat <cbosdonnat@suse.com> Date: Wed, 10 Mar 2021 09:29:12 +0100 Subject: [PATCH] virt.network_update: handle missing ipv4 netmask attribute (#328) In the libvirt definition, the IPv4 netmask XML attribute may be replaced by the prefix one. Handle this situation gracefully rather than miserably failing. --- changelog/59692.fixed | 1 + salt/modules/virt.py | 2 +- tests/pytests/unit/modules/virt/test_network.py | 13 +++++++++---- 3 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 changelog/59692.fixed diff --git a/changelog/59692.fixed b/changelog/59692.fixed new file mode 100644 index 0000000000..b4f4533ccc --- /dev/null +++ b/changelog/59692.fixed @@ -0,0 +1 @@ +Don't fail updating network without netmask ip attribute diff --git a/salt/modules/virt.py b/salt/modules/virt.py index 35711fcef4..6409089109 100644 --- a/salt/modules/virt.py +++ b/salt/modules/virt.py @@ -7415,7 +7415,7 @@ def network_update( if node.get("family", "ipv4") == "ipv4" ] for ip_node in ipv4_nodes: - netmask = ip_node.attrib.pop("netmask") + netmask = ip_node.attrib.pop("netmask", None) if netmask: address = ipaddress.ip_network( "{}/{}".format(ip_node.get("address"), netmask), strict=False diff --git a/tests/pytests/unit/modules/virt/test_network.py b/tests/pytests/unit/modules/virt/test_network.py index 52aadc9519..0def5e5c32 100644 --- a/tests/pytests/unit/modules/virt/test_network.py +++ b/tests/pytests/unit/modules/virt/test_network.py @@ -365,8 +365,11 @@ def test_update_nat_nochange(make_mock_network): define_mock.assert_not_called() -@pytest.mark.parametrize("test", [True, False]) -def test_update_nat_change(make_mock_network, test): +@pytest.mark.parametrize( + "test, netmask", + [(True, "netmask='255.255.255.0'"), (True, "prefix='24'"), (False, "prefix='24'")], +) +def test_update_nat_change(make_mock_network, test, netmask): """ Test updating a NAT network with changes """ @@ -379,13 +382,15 @@ def test_update_nat_change(make_mock_network, test): <bridge name='virbr0' stp='on' delay='0'/> <mac address='52:54:00:cd:49:6b'/> <domain name='my.lab' localOnly='yes'/> - <ip address='192.168.122.1' netmask='255.255.255.0'> + <ip address='192.168.122.1' {}> <dhcp> <range start='192.168.122.2' end='192.168.122.254'/> </dhcp> </ip> </network> - """ + """.format( + netmask + ) ) assert virt.network_update( "default", -- 2.30.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor