[minigraph] Check for null VLAN MAC (#7854)
Explicitly check for null VLAN MAC in minigraph parser before setting it - if it is null, do not set the VLAN MAC attribute
This commit is contained in:
parent
a2e729122d
commit
11b2a607f8
@ -547,7 +547,7 @@ def parse_dpg(dpg, hname):
|
|||||||
vlan_attributes['dhcp_servers'] = vdhcpserver_list
|
vlan_attributes['dhcp_servers'] = vdhcpserver_list
|
||||||
|
|
||||||
vlanmac = vintf.find(str(QName(ns, "MacAddress")))
|
vlanmac = vintf.find(str(QName(ns, "MacAddress")))
|
||||||
if vlanmac != None:
|
if vlanmac is not None and vlanmac.text is not None:
|
||||||
vlan_attributes['mac'] = vlanmac.text
|
vlan_attributes['mac'] = vlanmac.text
|
||||||
|
|
||||||
sonic_vlan_name = "Vlan%s" % vlanid
|
sonic_vlan_name = "Vlan%s" % vlanid
|
||||||
|
@ -139,6 +139,14 @@
|
|||||||
<Subnets>192.168.0.0/27</Subnets>
|
<Subnets>192.168.0.0/27</Subnets>
|
||||||
<MacAddress>00:aa:bb:cc:dd:ee</MacAddress>
|
<MacAddress>00:aa:bb:cc:dd:ee</MacAddress>
|
||||||
</VlanInterface>
|
</VlanInterface>
|
||||||
|
<VlanInterface>
|
||||||
|
<Name>ab2</Name>
|
||||||
|
<AttachTo>fortyGigE0/4</AttachTo>
|
||||||
|
<DhcpRelays>192.0.0.1</DhcpRelays>
|
||||||
|
<VlanID>2000</VlanID>
|
||||||
|
<Tag>2000</Tag>
|
||||||
|
<MacAddress i:nil="true"/>
|
||||||
|
</VlanInterface>
|
||||||
</VlanInterfaces>
|
</VlanInterfaces>
|
||||||
<IPInterfaces>
|
<IPInterfaces>
|
||||||
<IPInterface>
|
<IPInterface>
|
||||||
|
@ -92,15 +92,38 @@ class TestCfgGenCaseInsensitive(TestCase):
|
|||||||
def test_minigraph_vlans(self):
|
def test_minigraph_vlans(self):
|
||||||
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v VLAN'
|
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v VLAN'
|
||||||
output = self.run_script(argument)
|
output = self.run_script(argument)
|
||||||
|
|
||||||
|
expected = {
|
||||||
|
'Vlan1000': {
|
||||||
|
'alias': 'ab1',
|
||||||
|
'dhcp_servers': ['192.0.0.1', '192.0.0.2'],
|
||||||
|
'vlanid': '1000',
|
||||||
|
'mac': '00:aa:bb:cc:dd:ee',
|
||||||
|
'members': ['Ethernet8']
|
||||||
|
},
|
||||||
|
'Vlan2000': {
|
||||||
|
'alias': 'ab2',
|
||||||
|
'dhcp_servers': ['192.0.0.1'],
|
||||||
|
'members': ['Ethernet4'],
|
||||||
|
'vlanid': '2000'
|
||||||
|
}
|
||||||
|
}
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
utils.to_dict(output.strip()),
|
utils.to_dict(output.strip()),
|
||||||
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', 'members': ['Ethernet8'] }}")
|
expected
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_minigraph_vlan_members(self):
|
def test_minigraph_vlan_members(self):
|
||||||
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v VLAN_MEMBER'
|
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v VLAN_MEMBER'
|
||||||
output = self.run_script(argument)
|
output = self.run_script(argument)
|
||||||
self.assertEqual(output.strip(), "{('Vlan1000', 'Ethernet8'): {'tagging_mode': 'untagged'}}")
|
expected = {
|
||||||
|
'Vlan1000|Ethernet8': {'tagging_mode': 'untagged'},
|
||||||
|
'Vlan2000|Ethernet4': {'tagging_mode': 'untagged'}
|
||||||
|
}
|
||||||
|
self.assertEqual(
|
||||||
|
utils.to_dict(output.strip()),
|
||||||
|
expected
|
||||||
|
)
|
||||||
|
|
||||||
def test_minigraph_vlan_interfaces_keys(self):
|
def test_minigraph_vlan_interfaces_keys(self):
|
||||||
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "VLAN_INTERFACE.keys()|list"'
|
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "VLAN_INTERFACE.keys()|list"'
|
||||||
|
Reference in New Issue
Block a user