summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorWesley Wiedenmeier <wesley.wiedenmeier@gmail.com>2016-03-22 01:48:39 -0500
committerWesley Wiedenmeier <wesley.wiedenmeier@gmail.com>2016-03-22 01:48:39 -0500
commite66bcc8b2ea7648c15476cdd43d3753ee6c27ff1 (patch)
tree646c103a25a8ce2031a6673381f2c73b912a631c /cloudinit
parent3a7e3d198172f26b7b97707520d06fe5303fadbc (diff)
downloadvyos-cloud-init-e66bcc8b2ea7648c15476cdd43d3753ee6c27ff1.tar.gz
vyos-cloud-init-e66bcc8b2ea7648c15476cdd43d3753ee6c27ff1.zip
- Rename find_fallback_network_device to generate_fallback_config
- Removed systemd .link file generation, as it is not needed right now - Changed return of generate_fallback_config to be just ns dict - In distros.debian don't attempt to write .link file
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/distros/debian.py4
-rw-r--r--cloudinit/net/__init__.py23
2 files changed, 5 insertions, 22 deletions
diff --git a/cloudinit/distros/debian.py b/cloudinit/distros/debian.py
index 8e57f70e..0fa47274 100644
--- a/cloudinit/distros/debian.py
+++ b/cloudinit/distros/debian.py
@@ -85,9 +85,7 @@ class Distro(distros.Distro):
def _write_network_fallback(self):
# old fallback configuration is obsolete, disable it
util.disable_conf_file('/etc/network/interfaces.d/eth0.cfg')
- (ns, link_file, syslink_name) = net.find_fallback_network_device()
- if link_file is not None:
- util.write_file(syslink_name, link_file)
+ ns = net.generate_fallback_config()
if ns is not None:
net.render_network_state(network_state=ns, target="/")
return []
diff --git a/cloudinit/net/__init__.py b/cloudinit/net/__init__.py
index 2596b4f5..48b82a2c 100644
--- a/cloudinit/net/__init__.py
+++ b/cloudinit/net/__init__.py
@@ -21,7 +21,6 @@ import glob
import os
import re
import string
-import textwrap
from cloudinit import log as logging
from cloudinit import util
@@ -284,20 +283,12 @@ def parse_net_config(path):
return ns
-def find_fallback_network_device(rename_to_default=False):
+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
ns = {'interfaces': {}, 'dns': {'search': [], 'nameservers': []},
'routes': []}
- default_link_file = textwrap.dedent("""
- #cloud-init
- [Match]
- MACAddress={mac}
-
- [Link]
- Name={name}
- """)
# get list of interfaces that could have connections
invalid_interfaces = set(['lo'])
@@ -358,21 +349,15 @@ def find_fallback_network_device(rename_to_default=False):
sysfs_mac = os.path.join(SYS_CLASS_NET, name, 'address')
mac = util.load_file(sysfs_mac).strip()
target_name = name
- if rename_to_default:
- target_name = DEFAULT_PRIMARY_INTERFACE
- # generate net config for interface, rename interface to eth0 for backwards
- # compatibility, and attempt both dhcp4 and dhcp6
+
+ # generate net config for interface
ns['interfaces'][target_name] = {
'mac_address': mac, 'name': target_name, 'type': 'physical',
'mode': 'manual', 'inet': 'inet',
'subnets': [{'type': 'dhcp4'}, {'type': 'dhcp6'}]
}
- # insert params into link file
- link_file = default_link_file.format(name=target_name, mac=mac)
- syslink_name = "/etc/systemd/network/50-cloud-init-{}.link".format(
- target_name)
- return (ns, link_file, syslink_name)
+ return ns
def render_persistent_net(network_state):