summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzdc <zdc@users.noreply.github.com>2021-02-15 17:28:27 +0200
committerGitHub <noreply@github.com>2021-02-15 17:28:27 +0200
commit393cc322629604843b98da970b0761965a7a268e (patch)
tree4d3826c19bd2a0b1a0f5103ffe7c7dfde5259c63
parent1078248cc645f801d732fcc4800dcae592ccc47e (diff)
parent054bb80a589e3f8d116ff6f4752c94c2d4d3606a (diff)
downloadvyos-cloud-init-393cc322629604843b98da970b0761965a7a268e.tar.gz
vyos-cloud-init-393cc322629604843b98da970b0761965a7a268e.zip
Merge pull request #33 from zdc/T2403-sagitta
MAC address: T2403: Added MAC processing to network-config
-rw-r--r--cloudinit/config/cc_vyos.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/cloudinit/config/cc_vyos.py b/cloudinit/config/cc_vyos.py
index 338f5507..45b1ca07 100644
--- a/cloudinit/config/cc_vyos.py
+++ b/cloudinit/config/cc_vyos.py
@@ -232,6 +232,13 @@ def set_config_interfaces_v1(config, iface_config):
# configure physical interfaces
if iface_config['type'] == 'physical':
iface_name = iface_config['name']
+
+ # configre MAC
+ if 'mac_address' in iface_config:
+ logger.debug("Setting MAC for {}: {}".format(iface_name, iface_config['mac_address']))
+ config.set(['interfaces', 'ethernet', iface_name, 'hw-id'], value=iface_config['mac_address'], replace=True)
+ config.set_tag(['interfaces', 'ethernet'])
+
# configre MTU
if 'mtu' in iface_config:
logger.debug("Setting MTU for {}: {}".format(iface_name, iface_config['mtu']))
@@ -345,6 +352,13 @@ def set_config_interfaces_v1(config, iface_config):
# configure interface from networking config version 2
def set_config_interfaces_v2(config, iface_name, iface_config):
logger.debug("Configuring network using Cloud-init networking config version 2")
+
+ # configure MAC
+ if 'match' in iface_config and 'macaddress' in iface_config['match']:
+ logger.debug("Setting MAC for {}: {}".format(iface_name, iface_config['match']['macaddress']))
+ config.set(['interfaces', 'ethernet', iface_name, 'hw-id'], value=iface_config['match']['macaddress'], replace=True)
+ config.set_tag(['interfaces', 'ethernet'])
+
# configure DHCP client
if 'dhcp4' in iface_config:
if iface_config['dhcp4'] is True:
@@ -370,7 +384,7 @@ def set_config_interfaces_v2(config, iface_name, iface_config):
config.set_tag(['protocols', 'static', 'route6'])
config.set_tag(['protocols', 'static', 'route6', '::/0', 'next-hop'])
- # configre MTU
+ # configure MTU
if 'mtu' in iface_config:
logger.debug("Setting MTU for {}: {}".format(iface_name, iface_config['mtu']))
config.set(['interfaces', 'ethernet', iface_name, 'mtu'], value=iface_config['mtu'], replace=True)