Skip to content

Commit dc9bf0d

Browse files
authored
Merge pull request #680 from xcp-ng/srt/no-sdn-controller
host_no_sdn_controller: do not fail, but reconfigure the host.
2 parents 49cac15 + a10e76e commit dc9bf0d

1 file changed

Lines changed: 28 additions & 4 deletions

File tree

tests/network/conftest.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,42 @@
55
import logging
66

77
from data import HOST_FREE_NICS
8-
from lib.common import PackageManagerEnum
8+
from lib.common import PackageManagerEnum, safe_split
99
from lib.host import Host
1010
from lib.network import Network
1111
from lib.vm import VM
1212

1313
from typing import Generator
1414

1515
@pytest.fixture(scope='package')
16-
def host_no_sdn_controller(host: Host) -> None:
16+
def host_no_sdn_controller(host: Host) -> Generator[Host, None, None]:
1717
""" An XCP-ng with no SDN controller. """
18-
if host.xe('sdn-controller-list', minimal=True):
19-
pytest.fail("This test requires an XCP-ng with no SDN controller")
18+
sdn_configured: list[dict[str, str | bool | dict[str, str]]] = []
19+
20+
for uuid in safe_split(host.xe('sdn-controller-list', minimal=True), ','):
21+
logging.info(f"Forgetting sdn-controller: {uuid}")
22+
23+
sdn_configured.append({
24+
'protocol': host.xe('sdn-controller-param-get', {'uuid': uuid, 'param-name': 'protocol'}),
25+
'address': host.xe('sdn-controller-param-get', {'uuid': uuid, 'param-name': 'address'}),
26+
'tcp-port': host.xe('sdn-controller-param-get', {'uuid': uuid, 'param-name': 'port'}),
27+
})
28+
29+
host.xe('sdn-controller-forget', {'uuid': uuid})
30+
31+
# when using sdn-controller, we are usually using OpenFlow11 only
32+
# but allow-id is using OpenFlow10 and it fails to sets rules if OpenFlow11 is enabled only.
33+
host.ssh("set -o pipefail; ovs-vsctl list-br "
34+
"| xargs -n1 -d '\n' -r -I{} ovs-vsctl add bridge {} protocols OpenFlow10")
35+
36+
yield host
37+
38+
host.ssh("set -o pipefail; ovs-vsctl list-br "
39+
"| xargs -n1 -d '\n' -r -I{} ovs-vsctl remove bridge {} protocols OpenFlow10")
40+
41+
for cfg in sdn_configured:
42+
logging.info("Re-introducing sdn-controller")
43+
host.xe('sdn-controller-introduce', cfg)
2044

2145
# a clone of imported_vm in which we've added tcpdump
2246
# not to be used by tests directly

0 commit comments

Comments
 (0)