diff --git a/conftest.py b/conftest.py index 3c176a49c..d4368530b 100644 --- a/conftest.py +++ b/conftest.py @@ -233,6 +233,11 @@ def host_no_ipv6(host): if is_ipv6(host.hostname_or_ip): pytest.skip(f"This test requires an IPv4 XCP-ng") +@pytest.fixture(scope='session') +def host_ipv6(host): + if not is_ipv6(host.hostname_or_ip): + pytest.skip(f"This test requires an IPv6 XCP-ng") + @pytest.fixture(scope='session') def local_sr_on_hostA1(hostA1): """ A local SR on the pool's master. """ diff --git a/lib/host.py b/lib/host.py index dad43cb2d..5a12df236 100644 --- a/lib/host.py +++ b/lib/host.py @@ -7,6 +7,7 @@ from packaging import version import lib.commands as commands +import lib.pif as pif from lib.common import _param_add, _param_clear, _param_get, _param_remove, _param_set from lib.common import safe_split, strip_suffix, to_xapi_bool, wait_for, wait_for_not @@ -420,6 +421,10 @@ def reboot(self, verify=False): def management_network(self): return self.xe('network-list', {'bridge': self.inventory['MANAGEMENT_INTERFACE']}, minimal=True) + def management_pif(self): + uuid = self.xe('pif-list', {'management': True, 'host-uuid': self.uuid}, minimal=True) + return pif.PIF(uuid, self) + def disks(self): """ List of SCSI disks, e.g ['sda', 'sdb', 'nvme0n1']. """ disks = self.ssh(['lsblk', '-nd', '-I', '8,259', '--output', 'NAME']).splitlines() diff --git a/tests/network/test_management_disable_address_type.py b/tests/network/test_management_disable_address_type.py new file mode 100644 index 000000000..d744e9811 --- /dev/null +++ b/tests/network/test_management_disable_address_type.py @@ -0,0 +1,23 @@ +import pytest + +# Requirements: +# - one XCP-ng host (--host) (>= 8.3 for IPv6 test) + +def _test_management_disable_type(host, type): + management_pif = host.management_pif() + assert management_pif.param_get("primary-address-type").lower() == type + + host.xe("host-management-disable") + assert management_pif.param_get("primary-address-type").lower() == type + + host.xe("host-management-reconfigure", {"pif-uuid": management_pif.uuid}) + assert management_pif.param_get("primary-address-type").lower() == type + +class TestManagementDisableAddressType: + @pytest.mark.usefixtures("host_no_ipv6") + def test_management_disable_ipv4(self, host): + _test_management_disable_type(host, "ipv4") + + @pytest.mark.usefixtures("host_ipv6") + def test_management_disable_ipv6(self, host): + _test_management_disable_type(host, "ipv6")