summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cloudinit/net/__init__.py20
-rw-r--r--tests/unittests/test_net.py2
2 files changed, 18 insertions, 4 deletions
diff --git a/cloudinit/net/__init__.py b/cloudinit/net/__init__.py
index e13ca470..7af9b03a 100644
--- a/cloudinit/net/__init__.py
+++ b/cloudinit/net/__init__.py
@@ -304,6 +304,19 @@ def _load_shell_content(content, add_empty=False, empty_val=None):
def _klibc_to_config_entry(content, mac_addrs=None):
+ """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
+ /run/net-<name>.cfg.
+
+ The files are shell style syntax, and examples are in the tests
+ provided here. There is no good documentation on this unfortunately.
+
+ DEVICE=<name> is expected/required and PROTO should indicate if
+ this is 'static' or 'dhcp'.
+ """
+
+
if mac_addrs is None:
mac_addrs = {}
@@ -575,11 +588,12 @@ def is_disabled_cfg(cfg):
def sys_netdev_info(name, field):
if not os.path.exists(os.path.join(SYS_CLASS_NET, name)):
- raise OSError("%s: interface does not exist in /sys" % name)
+ raise OSError("%s: interface does not exist in %s" %
+ (name, SYS_CLASS_NET))
fname = os.path.join(SYS_CLASS_NET, name, field)
if not os.path.exists(fname):
- raise OSError("%s: %s does not exist in /sys" % (name, fname))
+ raise OSError("%s: could not find sysfs entry: %s" % (name, fname))
data = util.load_file(fname)
if data[-1] == '\n':
data = data[:-1]
@@ -647,7 +661,7 @@ def generate_fallback_config():
nconf['config'].append(
{'type': 'physical', 'name': target_name,
- 'mac_address': mac, 'subnets': [{'type': 'dhcp4'}]})
+ 'mac_address': mac, 'subnets': [{'type': 'dhcp'}]})
return nconf
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
index 16c44588..dfb31710 100644
--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -70,7 +70,7 @@ class TestNetConfigParsing(TestCase):
simple_cfg = {
'config': [{"type": "physical", "name": "eth0",
"mac_address": "c0:d6:9f:2c:e8:80",
- "subnets": [{"type": "dhcp4"}]}]}
+ "subnets": [{"type": "dhcp"}]}]}
def test_klibc_convert_dhcp(self):
found = net._klibc_to_config_entry(DHCP_CONTENT_1)