Skip to content

Commit a639021

Browse files
[minigraph.py]: Parse VLAN MAC address from minigraph when present (#5726)
1 parent e0b09d0 commit a639021

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/sonic-config-engine/minigraph.py

+4
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,10 @@ def parse_dpg(dpg, hname):
383383
vdhcpserver_list = vintfdhcpservers.split(';')
384384
vlan_attributes['dhcp_servers'] = vdhcpserver_list
385385

386+
vlanmac = vintf.find(str(QName(ns, "MacAddress")))
387+
if vlanmac != None:
388+
vlan_attributes['mac'] = vlanmac.text
389+
386390
sonic_vlan_name = "Vlan%s" % vlanid
387391
if sonic_vlan_name != vintfname:
388392
vlan_attributes['alias'] = vintfname

src/sonic-config-engine/tests/simple-sample-graph-case.xml

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
<VlanID>1000</VlanID>
135135
<Tag>1000</Tag>
136136
<Subnets>192.168.0.0/27</Subnets>
137+
<MacAddress>00:aa:bb:cc:dd:ee</MacAddress>
137138
</VlanInterface>
138139
</VlanInterfaces>
139140
<IPInterfaces>

src/sonic-config-engine/tests/test_minigraph_case.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def test_minigraph_vlans(self):
8383
output = self.run_script(argument)
8484
self.assertEqual(
8585
utils.to_dict(output.strip()),
86-
utils.to_dict("{'Vlan1000': {'alias': 'ab1', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '1000'}}")
86+
utils.to_dict("{'Vlan1000': {'alias': 'ab1', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '1000', 'mac': '00:aa:bb:cc:dd:ee' }}")
8787
)
8888

8989
def test_minigraph_vlan_members(self):

0 commit comments

Comments
 (0)