|
2 | 2 |
|
3 | 3 | import pytest |
4 | 4 |
|
| 5 | +import logging |
| 6 | + |
5 | 7 | from lib.common import safe_split |
6 | 8 | from lib.host import Host |
7 | 9 | from lib.network import Network |
| 10 | +from lib.vlan import VLAN |
8 | 11 | from lib.vm import VM |
9 | 12 | from lib.xo import xo_cli |
10 | 13 |
|
@@ -276,5 +279,41 @@ def test_networkRule(self, connected_hosts_with_xo: list[Host], hostA2: Host, lo |
276 | 279 | 'protocol': 'icmp', |
277 | 280 | }) |
278 | 281 |
|
279 | | - assert count_of(hostA1, hostBr) == 0, "1 OF after migrate (on hostA1)" |
280 | | - assert count_of(hostA2, hostBr) == 0, "1 OF after migrate (on hostA2)" |
| 282 | + assert count_of(hostA1, hostBr) == 0, "no OF at end (on hostA1)" |
| 283 | + assert count_of(hostA2, hostBr) == 0, "no OF at end (on hostA2)" |
| 284 | + |
| 285 | +@pytest.mark.complex_prerequisites |
| 286 | +@pytest.mark.small_vm |
| 287 | +@pytest.mark.parametrize("vlan_device", ["eth1"]) |
| 288 | +@pytest.mark.parametrize("vlan_tag", [42]) |
| 289 | +class TestVLAN: |
| 290 | + def test_vifRule(self, connected_hosts_with_xo: list[Host], imported_vm: VM, empty_network: Network, vlan: VLAN): |
| 291 | + host = connected_hosts_with_xo[0] |
| 292 | + network = empty_network |
| 293 | + vm = imported_vm.clone() |
| 294 | + |
| 295 | + # get bridge of the network of the tagged PIF |
| 296 | + hostBr = Network(host, vlan.tagged_PIF().network_uuid()).bridge() |
| 297 | + logging.info(f"host bridge for vlan: {hostBr}") |
| 298 | + |
| 299 | + try: |
| 300 | + vif = vm.create_vif(1, network_uuid=network.uuid) |
| 301 | + |
| 302 | + vm.start() |
| 303 | + |
| 304 | + xo_cli('sdnController.addRule', { |
| 305 | + 'vifId': vif.uuid, |
| 306 | + 'ipRange': '0.0.0.0/0', |
| 307 | + 'direction': 'to', |
| 308 | + 'protocol': 'tcp', |
| 309 | + 'port': 'json:81', |
| 310 | + 'allow': 'true', |
| 311 | + }) |
| 312 | + |
| 313 | + vm.wait_for_os_booted() |
| 314 | + |
| 315 | + assert count_of(host, hostBr) == 1, "1 OF after started" |
| 316 | + finally: |
| 317 | + vm.destroy() |
| 318 | + |
| 319 | + assert count_of(host, hostBr) == 0, "no OF at end" |
0 commit comments