Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sonic-cfggen] Multi-key should be in form of (a,b) instead of 'a|b' #2337

Merged
merged 1 commit into from
Dec 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions files/build_templates/buffers_config.j2
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ def
{%- else %}
{%- if switch_role.lower() == 'torrouter' %}
{%- for local_port in VLAN_MEMBER %}
{%- set vlan_port = local_port.split("|") %}
{%- if vlan_port[1] == port_name %}
{%- if local_port[1] == port_name %}
{%- set roles3 = switch_role + '_' + 'server' %}
{%- set roles3 = roles3 | lower %}
{%- if roles3 in ports2cable %}
Expand Down
9 changes: 4 additions & 5 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
ns1 = "http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"
ns2 = "Microsoft.Search.Autopilot.NetMux"
ns3 = "http://www.w3.org/2001/XMLSchema-instance"
KEY_SEPARATOR = '|'

class minigraph_encoder(json.JSONEncoder):
def default(self, obj):
Expand Down Expand Up @@ -187,7 +186,7 @@ def parse_dpg(dpg, hname):
for i, member in enumerate(pcmbr_list):
pcmbr_list[i] = port_alias_map.get(member, member)
intfs_inpc.append(pcmbr_list[i])
pc_members[pcintfname + KEY_SEPARATOR + pcmbr_list[i]] = {'NULL': 'NULL'}
pc_members[(pcintfname, pcmbr_list[i])] = {'NULL': 'NULL'}
if pcintf.find(str(QName(ns, "Fallback"))) != None:
pcs[pcintfname] = {'members': pcmbr_list, 'fallback': pcintf.find(str(QName(ns, "Fallback"))).text, 'min_links': str(int(math.ceil(len() * 0.75)))}
else:
Expand All @@ -204,8 +203,8 @@ def parse_dpg(dpg, hname):
vmbr_list = vintfmbr.split(';')
for i, member in enumerate(vmbr_list):
vmbr_list[i] = port_alias_map.get(member, member)
sonic_vlan_member_name = "Vlan%s%s%s" % (vlanid, KEY_SEPARATOR, vmbr_list[i])
vlan_members[sonic_vlan_member_name] = {'tagging_mode': 'untagged'}
sonic_vlan_member_name = "Vlan%s" % (vlanid)
vlan_members[(sonic_vlan_member_name, vmbr_list[i])] = {'tagging_mode': 'untagged'}

vlan_attributes = {'vlanid': vlanid}

Expand Down Expand Up @@ -543,7 +542,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
ports.get(port[0])['admin_status'] = 'up'

for member in pc_members.keys() + vlan_members.keys():
port = ports.get(member.split(KEY_SEPARATOR)[1])
port = ports.get(member[1])
if port:
port['admin_status'] = 'up'

Expand Down
4 changes: 2 additions & 2 deletions src/sonic-config-engine/tests/test_cfggen.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_minigraph_vlans(self):
def test_minigraph_vlan_members(self):
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'}}")
self.assertEqual(output.strip(), "{('Vlan1000', 'Ethernet8'): {'tagging_mode': 'untagged'}}")

def test_minigraph_vlan_interfaces(self):
argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v "VLAN_INTERFACE.keys()"'
Expand All @@ -130,7 +130,7 @@ def test_minigraph_portchannel_with_more_member(self):
def test_minigraph_portchannel_members(self):
argument = '-m "' + self.sample_graph_pc_test + '" -p "' + self.port_config + '" -v "PORTCHANNEL_MEMBER.keys()"'
output = self.run_script(argument)
self.assertEqual(output.strip(), "['PortChannel01|Ethernet112', 'PortChannel01|Ethernet124', 'PortChannel01|Ethernet116', 'PortChannel01|Ethernet120']")
self.assertEqual(output.strip(), "[('PortChannel01', 'Ethernet120'), ('PortChannel01', 'Ethernet116'), ('PortChannel01', 'Ethernet124'), ('PortChannel01', 'Ethernet112')]")

def test_minigraph_portchannel_interfaces(self):
argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v "PORTCHANNEL_INTERFACE.keys()"'
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-config-engine/tests/test_minigraph_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def test_minigraph_vlans(self):
def test_minigraph_vlan_members(self):
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v VLAN_MEMBER'
output = self.run_script(argument)
self.assertEqual(output.strip(), "{'Vlan1000|Ethernet8': {'tagging_mode': 'untagged'}}")
self.assertEqual(output.strip(), "{('Vlan1000', 'Ethernet8'): {'tagging_mode': 'untagged'}}")

def test_minigraph_vlan_interfaces(self):
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "VLAN_INTERFACE.keys()"'
Expand Down