summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorRyan Harper <ryan.harper@canonical.com>2017-07-20 14:46:30 -0500
committerScott Moser <smoser@brickies.net>2017-07-20 17:52:53 -0400
commit7e41b2a773b81452f14a18ec8c4f3316a66d3f5e (patch)
tree0f6932210420bdaece5d1999f8cbdd56821cd3d1 /cloudinit
parent811ce49d74afb158b2626a201ef5c714d5c9b059 (diff)
downloadvyos-cloud-init-7e41b2a773b81452f14a18ec8c4f3316a66d3f5e.tar.gz
vyos-cloud-init-7e41b2a773b81452f14a18ec8c4f3316a66d3f5e.zip
sysconfig: use MACADDR on bonds/bridges to configure mac_address
Previously, sysconfig rendered HWADDR for all interface types, but that value is only used to identify physical devices. Instead use MACADDR to configure the MAC on virtual devices, like bonds and bridges. - Sort bond slave list to ensure consistent ordering in sysconfig rendered files. - Add unittests for sysconfig rendering of bonds/bridges with mac_address LP: #1701417
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/net/sysconfig.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
index c7df36c0..9184bce6 100644
--- a/cloudinit/net/sysconfig.py
+++ b/cloudinit/net/sysconfig.py
@@ -264,6 +264,9 @@ class Renderer(renderer.Renderer):
for (old_key, new_key) in [('mac_address', 'HWADDR'), ('mtu', 'MTU')]:
old_value = iface.get(old_key)
if old_value is not None:
+ # only set HWADDR on physical interfaces
+ if old_key == 'mac_address' and iface['type'] != 'physical':
+ continue
iface_cfg[new_key] = old_value
@classmethod
@@ -430,6 +433,9 @@ class Renderer(renderer.Renderer):
master_cfg['BONDING_MASTER'] = True
master_cfg.kind = 'bond'
+ if iface.get('mac_address'):
+ iface_cfg['MACADDR'] = iface.get('mac_address')
+
iface_subnets = iface.get("subnets", [])
route_cfg = iface_cfg.routes
cls._render_subnets(iface_cfg, iface_subnets)
@@ -441,6 +447,7 @@ class Renderer(renderer.Renderer):
[slave_iface['name'] for slave_iface in
network_state.iter_interfaces(slave_filter)
if slave_iface['bond-master'] == iface_name])
+
for index, bond_slave in enumerate(bond_slaves):
slavestr = 'BONDING_SLAVE%s' % index
iface_cfg[slavestr] = bond_slave
@@ -499,6 +506,10 @@ class Renderer(renderer.Renderer):
for old_key, new_key in cls.bridge_opts_keys:
if old_key in iface:
iface_cfg[new_key] = iface[old_key]
+
+ if iface.get('mac_address'):
+ iface_cfg['MACADDR'] = iface.get('mac_address')
+
# Is this the right key to get all the connected interfaces?
for bridged_iface_name in iface.get('bridge_ports', []):
# Ensure all bridged interfaces are correctly tagged