def networkd_is_failed():
return call_quiet('systemctl is-failed -q systemd-networkd.service') != 1
-def stop_networkd(show_logs=True):
+def stop_networkd(show_logs=True, check_failed=True):
global show_journal
show_logs = show_logs and show_journal
if show_logs:
invocation_id = networkd_invocation_id()
- check_output('systemctl stop systemd-networkd.socket')
- check_output('systemctl stop systemd-networkd.service')
+
+ if check_failed:
+ check_output('systemctl stop systemd-networkd.socket')
+ check_output('systemctl stop systemd-networkd.service')
+ else:
+ call('systemctl stop systemd-networkd.socket')
+ call('systemctl stop systemd-networkd.service')
+
if show_logs:
print(read_networkd_log(invocation_id))
+
# Check if networkd exits cleanly.
- assert not networkd_is_failed()
+ if check_failed:
+ assert not networkd_is_failed()
def start_networkd():
check_output('systemctl start systemd-networkd')
flush_links()
# 5. stop networkd
- stop_networkd()
+ stop_networkd(check_failed=False)
# 6. remove configs
clear_network_units()
sys.stdout.flush()
check_output('journalctl --sync')
+ # 9. check the status of networkd
+ assert not networkd_is_failed()
+
def setUpModule():
rm_rf(networkd_ci_temp_dir)
cp_r(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'conf'), networkd_ci_temp_dir)