← Back to team overview

curtin-dev team mailing list archive

[Merge] ~mwhudson/curtin:no-etc-network-is-ok into curtin:master

 

Michael Hudson-Doyle has proposed merging ~mwhudson/curtin:no-etc-network-is-ok into curtin:master.

Commit message:
curthooks: do not unconditionally copy e/n/interfaces to target

When I tried to install a more-minimal server image using curtin, it
failed in copy_interfaces because the image did not have an /etc/network
directory at all (full ubuntu-server images have this directory because
ethtool installs files in there). Fix this by shuffling around how the
$state_dir/interfaces file is handled a bit: basically it used to always
be created by the install commmand and then updated by the net-meta
command. Change this to have the file only be created by net-meta, then
curthooks can copy it if and only if it exists.


Requested reviews:
  curtin developers (curtin-dev)

For more details, see:
https://code.launchpad.net/~mwhudson/curtin/+git/curtin/+merge/406613
-- 
Your team curtin developers is requested to review the proposed merge of ~mwhudson/curtin:no-etc-network-is-ok into curtin:master.
diff --git a/curtin/commands/curthooks.py b/curtin/commands/curthooks.py
index 539e233..f78bd21 100644
--- a/curtin/commands/curthooks.py
+++ b/curtin/commands/curthooks.py
@@ -941,7 +941,6 @@ def copy_zkey_repository(zkey_repository, target,
 
 def apply_networking(target, state):
     netconf = state.get('network_config')
-    interfaces = state.get('interfaces')
 
     def is_valid_src(infile):
         with open(infile, 'r') as fp:
@@ -955,11 +954,11 @@ def apply_networking(target, state):
         apply_net.apply_net(target, network_state=None, network_config=netconf)
     else:
         LOG.debug("copying interfaces")
-        copy_interfaces(interfaces, target)
+        copy_interfaces(state.get('interfaces'), target)
 
 
 def copy_interfaces(interfaces, target):
-    if not interfaces:
+    if not interfaces or not os.path.exists(interfaces):
         LOG.warn("no interfaces file to copy!")
         return
     eni = os.path.sep.join([target, 'etc/network/interfaces'])
diff --git a/curtin/commands/install.py b/curtin/commands/install.py
index a3471f6..0e20e41 100644
--- a/curtin/commands/install.py
+++ b/curtin/commands/install.py
@@ -140,7 +140,7 @@ class WorkingDir(object):
             json.dump(config, fp)
 
         # just touch these files to make sure they exist
-        for f in (interfaces_f, config_f, fstab_f, netconf_f, netstate_f):
+        for f in (config_f, fstab_f, netconf_f, netstate_f):
             with open(f, "ab") as fp:
                 pass
 

Follow ups