Skip to content

Commit dd8d903

Browse files
committed
VLAN fixture
Signed-off-by: Sebastien Marie <semarie@kapouay.eu.org>
1 parent cd09856 commit dd8d903

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

tests/network/conftest.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,27 @@ def empty_network(host: Host) -> Generator[Network, None, None]:
2222
finally:
2323
net.destroy()
2424

25+
26+
@pytest.fixture(params=["eth0"])
27+
def vlan_device(request: pytest.FixtureRequest) -> str:
28+
return request.param
29+
30+
@pytest.fixture(params=[0])
31+
def vlan_tag(request: pytest.FixtureRequest) -> int:
32+
return request.param
33+
34+
@pytest.fixture
35+
def vlan(host: Host, empty_network: Network, vlan_tag: int, vlan_device: str):
36+
logging.info(f"vlan: resolve PIF on {host.hostname_or_ip} using \
37+
{[(pif.network_uuid(), pif.param_get('device')) for pif in host.pifs()]}")
38+
39+
[pif] = host.pifs(device=vlan_device)
40+
vlan = host.vlan_create(empty_network, pif, vlan_tag)
41+
try:
42+
yield vlan
43+
finally:
44+
vlan.destroy()
45+
2546
@pytest.fixture(params=[])
2647
def bond_devices(request: pytest.FixtureRequest) -> list[str]:
2748
return request.param

0 commit comments

Comments
 (0)