Merge lp:~smoser/cloud-init/trunk.net-cleanups into lp:~cloud-init-dev/cloud-init/trunk

Proposed by Scott Moser on 2016-03-29
Status: Merged
Merged at revision: 1191
Proposed branch: lp:~smoser/cloud-init/trunk.net-cleanups
Merge into: lp:~cloud-init-dev/cloud-init/trunk
Diff against target: 44 lines (+10/-2)
3 files modified
bin/cloud-init (+1/-0)
cloudinit/distros/debian.py (+2/-1)
cloudinit/stages.py (+7/-1)
To merge this branch: bzr merge lp:~smoser/cloud-init/trunk.net-cleanups
Reviewer Review Type Date Requested Status
Ryan Harper 2016-03-29 Approve on 2016-03-29
Review via email: mp+290346@code.launchpad.net

Commit Message

apply_network_config improvements

3 things here:
 a.) do not raise exception, only warn when trying to apply a network
     config for a distro that does not have an implementation.
     This is important since debian/ubuntu is the only one *with* an
     implementation at the moment
 b.) apply network config in 'cloud-init --local' even if there is
     no datasource found. This means that the fallback datasource has
     to get things right.
 c.) do not write 70-persistent-net.rules
     the code was writing both 70-persistent-net.rules and
     /etc/systemd/network/50-cloud-init-*.link files
     that would just be confusing.

To post a comment you must log in.
Ryan Harper (raharper) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/cloud-init'
2--- bin/cloud-init 2016-03-23 14:31:11 +0000
3+++ bin/cloud-init 2016-03-29 17:44:51 +0000
4@@ -259,6 +259,7 @@
5 util.logexc(LOG, ("No instance datasource found!"
6 " Likely bad things to come!"))
7 if not args.force:
8+ init.apply_network_config()
9 if args.local:
10 return (None, [])
11 else:
12
13=== modified file 'cloudinit/distros/debian.py'
14--- cloudinit/distros/debian.py 2016-03-23 15:00:37 +0000
15+++ cloudinit/distros/debian.py 2016-03-29 17:44:51 +0000
16@@ -82,7 +82,8 @@
17 ns = net.parse_net_config_data(netconfig)
18 net.render_network_state(target="/", network_state=ns,
19 eni=self.network_conf_fn,
20- links_prefix=self.links_prefix)
21+ links_prefix=self.links_prefix,
22+ netrules=None)
23 util.del_file("/etc/network/interfaces.d/eth0.cfg")
24 return []
25
26
27=== modified file 'cloudinit/stages.py'
28--- cloudinit/stages.py 2016-03-24 21:11:26 +0000
29+++ cloudinit/stages.py 2016-03-29 17:44:51 +0000
30@@ -596,7 +596,13 @@
31 return
32
33 LOG.info("Applying network configuration from %s: %s", src, netcfg)
34- return self.distro.apply_network_config(netcfg)
35+ try:
36+ return self.distro.apply_network_config(netcfg)
37+ except NotImplementedError:
38+ LOG.warn("distro '%s' does not implement apply_network_config. "
39+ "networking may not be configured properly." %
40+ self.distro)
41+ return
42
43
44 class Modules(object):