summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier Jardón <javier.jardon@codethink.co.uk>2015-03-11 19:48:17 +0000
committerJavier Jardón <javier.jardon@codethink.co.uk>2015-03-16 18:02:23 +0000
commita2436a93ed867b58f2c9ac2484041b119f09860a (patch)
tree3e879b1880b103bbe13ffb3d43d680e39e43c045
parentdacb812a9589f1dade8b9b66ae9c17947c2301d5 (diff)
downloadmorph-a2436a93ed867b58f2c9ac2484041b119f09860a.tar.gz
simple-network.configure: Rename networkd file generated by systemd chunkjjardon/simple-network-networkd2
Rename instead removal in case the user is already using a 10-dhcp.network file
-rwxr-xr-xmorphlib/exts/simple-network.configure29
1 files changed, 29 insertions, 0 deletions
diff --git a/morphlib/exts/simple-network.configure b/morphlib/exts/simple-network.configure
index 7c078c93..a347ebf9 100755
--- a/morphlib/exts/simple-network.configure
+++ b/morphlib/exts/simple-network.configure
@@ -47,6 +47,8 @@ class SimpleNetworkConfigurationExtension(cliapp.Application):
def process_args(self, args):
network_config = os.environ.get("NETWORK_CONFIG")
+ self.rename_networkd_chunk_file(args)
+
if network_config is None:
self.generate_default_network_config(args)
else:
@@ -57,6 +59,33 @@ class SimpleNetworkConfigurationExtension(cliapp.Application):
self.generate_interfaces_file(args, stanzas)
self.generate_networkd_files(args, stanzas)
+ def rename_networkd_chunk_file(self, args):
+ """Rename the 10-dchp.network file generated in the systemd chunk
+
+ The systemd chunk will place something in 10-dhcp.network, which will
+ have higher precedence than anything added in this extension (we
+ start at 50-*).
+
+ We should check for that file and rename it instead remove it in
+ case the file is being used by the user.
+
+ Until both the following happen, we should continue to rename that
+ default config file:
+
+ 1. simple-network.configure is always run when systemd is included
+ 2. We've been building systems without systemd including that default
+ networkd config for long enough that nobody should be including
+ that config file.
+ """
+ file_path = os.path.join(args[0], "etc", "systemd", "network",
+ "10-dhcp.network")
+ try:
+ os.rename(file_path, file_path + ".morph")
+ self.status(msg="Renaming networkd file from systemd chunk: %(f)s \
+ to %(f)s.morph", f=file_path)
+ except OSError:
+ pass
+
def generate_default_network_config(self, args):
"""Generate default network configuration: DHCP in all the interfaces"""