1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-02-04 07:51:50 +00:00

nmcli: allow VxLan multicast and bridge port (#11182)

VxLan virtual devices can be added to bridge ports, like any other
devices. And when using multicast remote addresses,
NetworkManager need to know the parent device as well.

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Tiziano Müller 2025-12-02 21:34:34 +01:00 committed by GitHub
parent 8d51c5f666
commit 76589bd97a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 95 additions and 0 deletions

View file

@ -843,6 +843,34 @@ vxlan.local: 192.168.225.5
vxlan.remote: 192.168.225.6
"""
TESTCASE_VXLAN_MULTICAST = [
{
"type": "vxlan",
"conn_name": "vxlan_multicast_test",
"ifname": "vxlan-device",
"vxlan_id": 17,
"vxlan_parent": "eth1",
"vxlan_local": "192.168.1.2",
"vxlan_remote": "239.192.0.17",
"slave_type": "bridge",
"master": "br0",
"state": "present",
"_ansible_check_mode": False,
}
]
TESTCASE_VXLAN_MULTICAST_SHOW_OUTPUT = """\
connection.id: vxlan_multicast_test
connection.interface-name: vxlan-device
connection.autoconnect: yes
connection.slave-type: bridge
connection.master: br0
vxlan.id: 17
vxlan.parent: eth1
vxlan.local: 192.168.1.2
vxlan.remote: 239.192.0.17
"""
TESTCASE_GRE = [
{
"type": "gre",
@ -2912,6 +2940,51 @@ def test_vxlan_connection_unchanged(mocked_vxlan_connection_unchanged, capfd):
assert not results["changed"]
@pytest.mark.parametrize("patch_ansible_module", TESTCASE_VXLAN_MULTICAST, indirect=["patch_ansible_module"])
def test_create_vxlan_multicast(mocked_generic_connection_create, capfd):
"""
Test if vxlan with multicast and parent device created
"""
with pytest.raises(SystemExit):
nmcli.main()
assert nmcli.Nmcli.execute_command.call_count == 1
arg_list = nmcli.Nmcli.execute_command.call_args_list
args, kwargs = arg_list[0]
assert args[0][0] == "/usr/bin/nmcli"
assert args[0][1] == "con"
assert args[0][2] == "add"
assert args[0][3] == "type"
assert args[0][4] == "vxlan"
assert args[0][5] == "con-name"
assert args[0][6] == "vxlan_multicast_test"
args_text = list(map(to_text, args[0]))
for param in [
"connection.interface-name",
"vxlan-device",
"vxlan.local",
"192.168.1.2",
"vxlan.remote",
"239.192.0.17",
"vxlan.id",
"17",
"vxlan.parent",
"eth1",
"connection.slave-type",
"bridge",
"connection.master",
"br0",
]:
assert param in args_text
out, err = capfd.readouterr()
results = json.loads(out)
assert not results.get("failed")
assert results["changed"]
@pytest.mark.parametrize("patch_ansible_module", TESTCASE_IPIP, indirect=["patch_ansible_module"])
def test_create_ipip(mocked_generic_connection_create, capfd):
"""