aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-12-05 20:53:51 +0100
committerLennart Poettering <lennart@poettering.net>2018-12-07 12:25:24 +0100
commitfef740aed354098af505c300bed13fdf0f251064 (patch)
tree32ec8f769e871f98e218aba06d8c33943d2e9c74 /test
parentnetworkd-test: set right access modes for /run/systemd/netif (diff)
downloadsystemd-fef740aed354098af505c300bed13fdf0f251064.tar.gz
systemd-fef740aed354098af505c300bed13fdf0f251064.tar.bz2
systemd-fef740aed354098af505c300bed13fdf0f251064.zip
networkd-test: add write_config()
The call was removed in ec89276c2ab345b84c2dab4c35826de41aa6fd0f, but is still used. Not sure why noone noticed this.
Diffstat (limited to 'test')
-rwxr-xr-xtest/networkd-test.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/test/networkd-test.py b/test/networkd-test.py
index b6fe74e2c..3f9d4b4df 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)])