diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py
index 06b799cdef..0635f9171e 100644
--- a/src/sonic-config-engine/minigraph.py
+++ b/src/sonic-config-engine/minigraph.py
@@ -526,6 +526,13 @@ def parse_dpg(dpg, hname):
vlans = {}
vlan_members = {}
vlantype_name = ""
+ intf_vlan_mbr = defaultdict(list)
+ for vintf in vlanintfs.findall(str(QName(ns, "VlanInterface"))):
+ vlanid = vintf.find(str(QName(ns, "VlanID"))).text
+ vintfmbr = vintf.find(str(QName(ns, "AttachTo"))).text
+ vmbr_list = vintfmbr.split(';')
+ for i, member in enumerate(vmbr_list):
+ intf_vlan_mbr[member].append(vlanid)
for vintf in vlanintfs.findall(str(QName(ns, "VlanInterface"))):
vintfname = vintf.find(str(QName(ns, "Name"))).text
vlanid = vintf.find(str(QName(ns, "VlanID"))).text
@@ -539,6 +546,8 @@ def parse_dpg(dpg, hname):
sonic_vlan_member_name = "Vlan%s" % (vlanid)
if vlantype_name == "Tagged":
vlan_members[(sonic_vlan_member_name, vmbr_list[i])] = {'tagging_mode': 'tagged'}
+ elif len(intf_vlan_mbr[member]) > 1:
+ vlan_members[(sonic_vlan_member_name, vmbr_list[i])] = {'tagging_mode': 'tagged'}
else:
vlan_members[(sonic_vlan_member_name, vmbr_list[i])] = {'tagging_mode': 'untagged'}
diff --git a/src/sonic-config-engine/tests/simple-sample-graph.xml b/src/sonic-config-engine/tests/simple-sample-graph.xml
index 7215209da5..703a005ea5 100644
--- a/src/sonic-config-engine/tests/simple-sample-graph.xml
+++ b/src/sonic-config-engine/tests/simple-sample-graph.xml
@@ -173,6 +173,22 @@
Tagged
192.168.0.0/28
+
+ ab2
+ fortyGigE0/12
+ 192.0.0.1;192.0.0.2
+ 2000
+ 2000
+ 192.168.0.240/27
+
+
+ ab3
+ fortyGigE0/12
+ 192.0.0.1;192.0.0.2
+ 2001
+ 2001
+ 192.168.0.240/27
+
diff --git a/src/sonic-config-engine/tests/test_cfggen.py b/src/sonic-config-engine/tests/test_cfggen.py
index 3a85346de2..9fbf351c3a 100644
--- a/src/sonic-config-engine/tests/test_cfggen.py
+++ b/src/sonic-config-engine/tests/test_cfggen.py
@@ -121,6 +121,8 @@ class TestCfgGen(TestCase):
utils.to_dict(output.strip()),
utils.to_dict(
'{\n "Vlan1000|Ethernet8": {\n "tagging_mode": "untagged"\n },'
+ ' \n "Vlan2000|Ethernet12": {\n "tagging_mode": "tagged"\n },'
+ ' \n "Vlan2001|Ethernet12": {\n "tagging_mode": "tagged"\n },'
' \n "Vlan2020|Ethernet12": {\n "tagging_mode": "tagged"\n }\n}'
)
)
@@ -206,6 +208,8 @@ class TestCfgGen(TestCase):
utils.to_dict(output.strip()),
utils.to_dict(
"{'Vlan1000': {'alias': 'ab1', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '1000'}, "
+ "'Vlan2001': {'alias': 'ab3', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '2001'},"
+ "'Vlan2000': {'alias': 'ab2', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '2000'},"
"'Vlan2020': {'alias': 'kk1', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '2020'}}"
)
)
@@ -214,9 +218,13 @@ class TestCfgGen(TestCase):
argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v VLAN_MEMBER'
output = self.run_script(argument)
self.assertEqual(
- output.strip(),
- "{('Vlan1000', 'Ethernet8'): {'tagging_mode': 'untagged'}, "
- "('Vlan2020', 'Ethernet12'): {'tagging_mode': 'tagged'}}"
+ utils.to_dict(output.strip()),
+ utils.to_dict(
+ "{('Vlan2000', 'Ethernet12'): {'tagging_mode': 'tagged'}, "
+ "('Vlan1000', 'Ethernet8'): {'tagging_mode': 'untagged'}, "
+ "('Vlan2020', 'Ethernet12'): {'tagging_mode': 'tagged'}, "
+ "('Vlan2001', 'Ethernet12'): {'tagging_mode': 'tagged'}}"
+ )
)
def test_minigraph_vlan_interfaces(self):