diff options
author | Scott Moser <smoser@ubuntu.com> | 2016-03-22 04:49:34 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2016-03-22 04:49:34 -0400 |
commit | ca00b0f1f8c8a40409328c595d44234bb61c24c4 (patch) | |
tree | c1c9b90a7d287ae541c76b35c3798fd2cfd3c1a3 /cloudinit/net/__init__.py | |
parent | c4c790ba368c4924332fdead19bb7024d9760c37 (diff) | |
download | vyos-cloud-init-ca00b0f1f8c8a40409328c595d44234bb61c24c4.tar.gz vyos-cloud-init-ca00b0f1f8c8a40409328c595d44234bb61c24c4.zip |
make NoCloud work for seeding network.
Tested now with the generated fallback config in an lxc container.
Had to change to return a config rather than a network state.
Also this makes nocloud look in nocloud-net's seed dir.
This way it will read the seed and clame the datasource but
not do anything other than apply networking and the init_modules early.
It is a change in behavior of the time that boothooks woudl run to do
this. May need to change that back.
Diffstat (limited to 'cloudinit/net/__init__.py')
-rw-r--r-- | cloudinit/net/__init__.py | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/cloudinit/net/__init__.py b/cloudinit/net/__init__.py index b45153f4..63fad2fa 100644 --- a/cloudinit/net/__init__.py +++ b/cloudinit/net/__init__.py @@ -448,11 +448,7 @@ def generate_fallback_config(): """Determine which attached net dev is most likely to have a connection and generate network state to run dhcp on that interface""" # by default use eth0 as primary interface - nconf = {'config': {'interfaces': {}, - 'dns': {'search': [], 'nameservers': []}, 'routes': [] - }, - 'version': 1 - } + nconf = {'config': [], 'version': 1} # get list of interfaces that could have connections invalid_interfaces = set(['lo']) @@ -506,21 +502,15 @@ def generate_fallback_config(): if DEFAULT_PRIMARY_INTERFACE in potential_interfaces: name = DEFAULT_PRIMARY_INTERFACE else: - potential_interfaces.sort( - key=lambda x: int(''.join(i for i in x if i in string.digits))) - name = potential_interfaces[0] + name = sorted(potential_interfaces)[0] sysfs_mac = os.path.join(SYS_CLASS_NET, name, 'address') mac = util.load_file(sysfs_mac).strip() target_name = name - # generate net config for interface - nconf['config']['interfaces'][target_name] = { - 'mac_address': mac, 'name': target_name, 'type': 'physical', - 'mode': 'manual', 'inet': 'inet', - 'subnets': [{'type': 'dhcp4'}, {'type': 'dhcp6'}] - } - + nconf['config'].append( + {'type': 'physical', 'name': target_name, + 'mac_address': mac, 'subnets': [{'type': 'dhcp4'}]}) return nconf |