From fef740aed354098af505c300bed13fdf0f251064 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 5 Dec 2018 20:53:51 +0100 Subject: [PATCH] networkd-test: add write_config() The call was removed in ec89276c2ab345b84c2dab4c35826de41aa6fd0f, but is still used. Not sure why noone noticed this. --- test/networkd-test.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/test/networkd-test.py b/test/networkd-test.py index b6fe74e2c6..3f9d4b4dff 100755 --- a/test/networkd-test.py +++ b/test/networkd-test.py @@ -111,13 +111,17 @@ class NetworkdTestingUtilities: list(peer_options)) self.addCleanup(subprocess.call, ['ip', 'link', 'del', 'dev', peer]) + def write_config(self, path, contents): + """"Write a configuration file, and queue it to be removed.""" + + with open(path, 'w') as f: + f.write(contents) + + self.addCleanup(os.remove, path) + def write_network(self, unit_name, contents): """Write a network unit file, and queue it to be removed.""" - unit_path = os.path.join(NETWORK_UNITDIR, unit_name) - - with open(unit_path, 'w') as unit: - unit.write(contents) - self.addCleanup(os.remove, unit_path) + self.write_config(os.path.join(NETWORK_UNITDIR, unit_name), contents) def write_network_dropin(self, unit_name, dropin_name, contents): """Write a network unit drop-in, and queue it to be removed.""" @@ -738,7 +742,7 @@ Domains= ~company ~lab''') orig_hostname = socket.gethostname() self.addCleanup(socket.sethostname, orig_hostname) if not os.path.exists('/etc/hostname'): - self.writeConfig('/etc/hostname', orig_hostname) + self.write_config('/etc/hostname', orig_hostname) subprocess.check_call(['systemctl', 'stop', 'systemd-hostnamed.service']) self.create_iface(dnsmasq_opts=['--dhcp-host={},192.168.5.210,testgreen'.format(self.iface_mac)])