=== modified file 'cloudinit/net/__init__.py'
--- cloudinit/net/__init__.py 2016-04-13 15:48:38 +0000
+++ cloudinit/net/__init__.py 2016-04-14 15:23:47 +0000
@@ -303,7 +303,7 @@
return data
-def _klibc_to_config_entry(content, mac_addrs=None):
+def _klibc_to_config_entry(content, mac_addrs=None, control="manual"):
"""Convert a klibc writtent shell content file to a 'config' entry
When ip= is seen on the kernel command line in debian initramfs
and networking is brought up, ipconfig will populate
@@ -341,6 +341,8 @@
'name': name,
'subnets': [],
}
+ if control:
+ iface['control'] = control
if name in mac_addrs:
iface['mac_address'] = mac_addrs[name]
@@ -379,7 +381,8 @@
return name, iface
-def config_from_klibc_net_cfg(files=None, mac_addrs=None):
+def config_from_klibc_net_cfg(files=None, mac_addrs=None,
+ control="manual"):
if files is None:
files = glob.glob('/run/net*.conf')
@@ -387,7 +390,8 @@
names = {}
for cfg_file in files:
name, entry = _klibc_to_config_entry(util.load_file(cfg_file),
- mac_addrs=mac_addrs)
+ mac_addrs=mac_addrs,
+ control=control)
if name in names:
raise ValueError(
"device '%s' defined multiple times: %s and %s" % (
@@ -531,7 +535,11 @@
content += "\n"
for iface in sorted(interfaces.values(),
key=lambda k: (order[k['type']], k['name'])):
- content += "auto {name}\n".format(**iface)
+
+ # valid values for 'control' would be: 'auto', 'hotplug', None
+ control = iface.get('control', 'auto')
+ if control and control != 'manual':
+ content += "allow-{control} {name}\n".format(**iface)
subnets = iface.get('subnets', {})
if subnets:
=== modified file 'tests/unittests/test_net.py'
--- tests/unittests/test_net.py 2016-03-24 19:46:52 +0000
+++ tests/unittests/test_net.py 2016-04-14 15:27:36 +0000
@@ -32,6 +32,7 @@
DHCP_EXPECTED_1 = {
'name': 'eth0',
'type': 'physical',
+ 'control': 'manual',
'subnets': [{'broadcast': '192.168.122.255',
'gateway': '192.168.122.1',
'dns_search': ['foo.com'],
@@ -58,6 +59,7 @@
STATIC_EXPECTED_1 = {
'name': 'eth1',
+ 'control': 'manual',
'type': 'physical',
'subnets': [{'broadcast': '10.0.0.255', 'gateway': '10.0.0.1',
'dns_search': ['foo.com'], 'type': 'static',