From 6b31574c2df5d897818d7c414871fd7aff27d754 Mon Sep 17 00:00:00 2001 From: Javier Jardon Date: Mon, 23 Mar 2015 23:27:11 +0000 Subject: simple-network: only try to rename "10-dhcp.network" if it actually exist Change-Id: I1521c0bdec4d7a6812f8988a2349e66b08161de8 --- morphlib/exts/simple-network.configure | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'morphlib/exts/simple-network.configure') diff --git a/morphlib/exts/simple-network.configure b/morphlib/exts/simple-network.configure index 130b96c9..1ba94e86 100755 --- a/morphlib/exts/simple-network.configure +++ b/morphlib/exts/simple-network.configure @@ -81,12 +81,14 @@ class SimpleNetworkConfigurationExtension(cliapp.Application): """ 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 + + if os.path.isfile(file_path): + 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 config: DHCP in all the interfaces""" -- cgit v1.2.1