Merge ~xnox/cloud-init:vlan-macaddress into cloud-init:master

Proposed by Dimitri John Ledkov
Status: Merged
Approved by: Scott Moser
Approved revision: 7ffcb99f599216e69d6efc76b4dbccc909e45755
Merged at revision: d059d480c3a5bbeb3bb2e8ff2350f85d64721c11
Proposed branch: ~xnox/cloud-init:vlan-macaddress
Merge into: cloud-init:master
Diff against target: 43 lines (+6/-1)
2 files modified
cloudinit/net/netplan.py (+3/-1)
tests/unittests/test_net.py (+3/-0)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Scott Moser Needs Fixing
Review via email: mp+324021@code.launchpad.net

Commit message

netplan: pass macaddress, when specified, for vlans

LP: #1690388

Description of the change

netplan: pass macaddress, when specified, for vlans

LP: #1690388

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ryan Harper (raharper) wrote :

We should update the netplan unittest to include a vlan mac_address.

Revision history for this message
Scott Moser (smoser) wrote :

Can you
a.) add a unit test
b.) attach the network_json that you had in your openstack instance to the bug.

review: Needs Fixing
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

b) attached network_json to the bug report as is.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

* xnox recommends to use "physical_address" for MAC in v3 yaml

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

test added. bot should test this soon.

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/net/netplan.py b/cloudinit/net/netplan.py
2index 56b41be..9b71de9 100644
3--- a/cloudinit/net/netplan.py
4+++ b/cloudinit/net/netplan.py
5@@ -345,7 +345,9 @@ class Renderer(renderer.Renderer):
6 'id': ifcfg.get('vlan_id'),
7 'link': ifcfg.get('vlan-raw-device')
8 }
9-
10+ macaddr = ifcfg.get('mac_address', None)
11+ if macaddr is not None:
12+ vlan['macaddress'] = macaddr.lower()
13 _extract_addresses(ifcfg, vlan)
14 vlans.update({ifname: vlan})
15
16diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
17index d36d0e7..68a0157 100644
18--- a/tests/unittests/test_net.py
19+++ b/tests/unittests/test_net.py
20@@ -558,6 +558,7 @@ iface eth0.101 inet static
21 dns-nameservers 192.168.0.10 10.23.23.134
22 dns-search barley.maas sacchromyces.maas brettanomyces.maas
23 gateway 192.168.0.1
24+ hwaddress aa:bb:cc:dd:ee:11
25 mtu 1500
26 vlan-raw-device eth0
27 vlan_id 101
28@@ -680,6 +681,7 @@ pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true
29 gateway4: 192.168.0.1
30 id: 101
31 link: eth0
32+ macaddress: aa:bb:cc:dd:ee:11
33 nameservers:
34 addresses:
35 - 192.168.0.10
36@@ -723,6 +725,7 @@ pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true
37 name: eth0.101
38 vlan_link: eth0
39 vlan_id: 101
40+ mac_address: aa:bb:cc:dd:ee:11
41 mtu: 1500
42 subnets:
43 - type: static

Subscribers

People subscribed via source and target branches