]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
networkd-test: add write_config()
authorLennart Poettering <lennart@poettering.net>
Wed, 5 Dec 2018 19:53:51 +0000 (20:53 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 7 Dec 2018 11:25:24 +0000 (12:25 +0100)
The call was removed in ec89276c2ab345b84c2dab4c35826de41aa6fd0f, but is
still used. Not sure why noone noticed this.

test/networkd-test.py

index b6fe74e2c60de1fd57c3fe5cbd6573bd42735991..3f9d4b4dff45939adbb1d7b8bb61f94f6b00dace 100755 (executable)
@@ -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)])