Clean up connection profile after running pytest

Running the pytest with nm provider failed in the downstream testing
because the "NM_CONTROLLED=no" appeared in
`/etc/sysconfig/network-scripts/ifcfg-testeth` which caused the veth
`testeth` strictly unmanaged by NetworkManager. To fix it, clean up
such a connection profile at the end when running the pytest.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
This commit is contained in:
Wen Liang 2022-03-09 15:39:03 -05:00 committed by Fernando Fernández Mancera
parent d3a7124f07
commit db4bf873cb

View file

@ -78,6 +78,15 @@ def testnic1():
yield veth_name
finally:
subprocess.call(["ip", "link", "delete", veth_name])
if os.path.isfile("/etc/sysconfig/network-scripts/ifcfg-" + veth_name):
os.unlink("/etc/sysconfig/network-scripts/ifcfg-" + veth_name)
subprocess.call(
[
"nmcli",
"con",
"reload",
]
)
def _get_ip_addresses(interface):