diff options
author | Javier Jardón <javier.jardon@codethink.co.uk> | 2015-03-11 19:48:17 +0000 |
---|---|---|
committer | Javier Jardón <javier.jardon@codethink.co.uk> | 2015-03-16 18:02:23 +0000 |
commit | 2021f504c66ab367e4039ff91b49f97fd926779a (patch) | |
tree | f6478d4b7c28dfcc0fa0107fdd3cb563ba0d863a | |
parent | fe364c83daf5f66c685a00e3b368322d53139401 (diff) | |
download | definitions-2021f504c66ab367e4039ff91b49f97fd926779a.tar.gz |
simple-network.configure: Rename networkd file generated by systemd chunk
Rename instead removal in case the user is already using a
10-dhcp.network file
-rwxr-xr-x | simple-network.configure | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/simple-network.configure b/simple-network.configure index 7c078c93..a347ebf9 100755 --- a/simple-network.configure +++ b/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""" |