[sonic-cfggen] Multi-key should be in form of (a,b) instead of 'a|b' (#2337)
This commit is contained in:
parent
d96660972b
commit
aedfd6e708
@ -60,8 +60,7 @@ def
|
|||||||
{%- else %}
|
{%- else %}
|
||||||
{%- if switch_role.lower() == 'torrouter' %}
|
{%- if switch_role.lower() == 'torrouter' %}
|
||||||
{%- for local_port in VLAN_MEMBER %}
|
{%- for local_port in VLAN_MEMBER %}
|
||||||
{%- set vlan_port = local_port.split("|") %}
|
{%- if local_port[1] == port_name %}
|
||||||
{%- if vlan_port[1] == port_name %}
|
|
||||||
{%- set roles3 = switch_role + '_' + 'server' %}
|
{%- set roles3 = switch_role + '_' + 'server' %}
|
||||||
{%- set roles3 = roles3 | lower %}
|
{%- set roles3 = roles3 | lower %}
|
||||||
{%- if roles3 in ports2cable %}
|
{%- if roles3 in ports2cable %}
|
||||||
|
@ -25,7 +25,6 @@ ns = "Microsoft.Search.Autopilot.Evolution"
|
|||||||
ns1 = "http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"
|
ns1 = "http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"
|
||||||
ns2 = "Microsoft.Search.Autopilot.NetMux"
|
ns2 = "Microsoft.Search.Autopilot.NetMux"
|
||||||
ns3 = "http://www.w3.org/2001/XMLSchema-instance"
|
ns3 = "http://www.w3.org/2001/XMLSchema-instance"
|
||||||
KEY_SEPARATOR = '|'
|
|
||||||
|
|
||||||
class minigraph_encoder(json.JSONEncoder):
|
class minigraph_encoder(json.JSONEncoder):
|
||||||
def default(self, obj):
|
def default(self, obj):
|
||||||
@ -187,7 +186,7 @@ def parse_dpg(dpg, hname):
|
|||||||
for i, member in enumerate(pcmbr_list):
|
for i, member in enumerate(pcmbr_list):
|
||||||
pcmbr_list[i] = port_alias_map.get(member, member)
|
pcmbr_list[i] = port_alias_map.get(member, member)
|
||||||
intfs_inpc.append(pcmbr_list[i])
|
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:
|
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)))}
|
pcs[pcintfname] = {'members': pcmbr_list, 'fallback': pcintf.find(str(QName(ns, "Fallback"))).text, 'min_links': str(int(math.ceil(len() * 0.75)))}
|
||||||
else:
|
else:
|
||||||
@ -204,8 +203,8 @@ def parse_dpg(dpg, hname):
|
|||||||
vmbr_list = vintfmbr.split(';')
|
vmbr_list = vintfmbr.split(';')
|
||||||
for i, member in enumerate(vmbr_list):
|
for i, member in enumerate(vmbr_list):
|
||||||
vmbr_list[i] = port_alias_map.get(member, member)
|
vmbr_list[i] = port_alias_map.get(member, member)
|
||||||
sonic_vlan_member_name = "Vlan%s%s%s" % (vlanid, KEY_SEPARATOR, vmbr_list[i])
|
sonic_vlan_member_name = "Vlan%s" % (vlanid)
|
||||||
vlan_members[sonic_vlan_member_name] = {'tagging_mode': 'untagged'}
|
vlan_members[(sonic_vlan_member_name, vmbr_list[i])] = {'tagging_mode': 'untagged'}
|
||||||
|
|
||||||
vlan_attributes = {'vlanid': vlanid}
|
vlan_attributes = {'vlanid': vlanid}
|
||||||
|
|
||||||
@ -548,7 +547,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
|
|||||||
ports.get(port[0])['admin_status'] = 'up'
|
ports.get(port[0])['admin_status'] = 'up'
|
||||||
|
|
||||||
for member in pc_members.keys() + vlan_members.keys():
|
for member in pc_members.keys() + vlan_members.keys():
|
||||||
port = ports.get(member.split(KEY_SEPARATOR)[1])
|
port = ports.get(member[1])
|
||||||
if port:
|
if port:
|
||||||
port['admin_status'] = 'up'
|
port['admin_status'] = 'up'
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ class TestCfgGen(TestCase):
|
|||||||
def test_minigraph_vlan_members(self):
|
def test_minigraph_vlan_members(self):
|
||||||
argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v VLAN_MEMBER'
|
argument = '-m "' + self.sample_graph_simple + '" -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'}}")
|
self.assertEqual(output.strip(), "{('Vlan1000', 'Ethernet8'): {'tagging_mode': 'untagged'}}")
|
||||||
|
|
||||||
def test_minigraph_vlan_interfaces(self):
|
def test_minigraph_vlan_interfaces(self):
|
||||||
argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v "VLAN_INTERFACE.keys()"'
|
argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v "VLAN_INTERFACE.keys()"'
|
||||||
@ -130,7 +130,7 @@ class TestCfgGen(TestCase):
|
|||||||
def test_minigraph_portchannel_members(self):
|
def test_minigraph_portchannel_members(self):
|
||||||
argument = '-m "' + self.sample_graph_pc_test + '" -p "' + self.port_config + '" -v "PORTCHANNEL_MEMBER.keys()"'
|
argument = '-m "' + self.sample_graph_pc_test + '" -p "' + self.port_config + '" -v "PORTCHANNEL_MEMBER.keys()"'
|
||||||
output = self.run_script(argument)
|
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):
|
def test_minigraph_portchannel_interfaces(self):
|
||||||
argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v "PORTCHANNEL_INTERFACE.keys()"'
|
argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v "PORTCHANNEL_INTERFACE.keys()"'
|
||||||
|
@ -77,7 +77,7 @@ class TestCfgGenCaseInsensitive(TestCase):
|
|||||||
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'}}")
|
self.assertEqual(output.strip(), "{('Vlan1000', 'Ethernet8'): {'tagging_mode': 'untagged'}}")
|
||||||
|
|
||||||
def test_minigraph_vlan_interfaces(self):
|
def test_minigraph_vlan_interfaces(self):
|
||||||
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "VLAN_INTERFACE.keys()"'
|
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "VLAN_INTERFACE.keys()"'
|
||||||
|
Loading…
Reference in New Issue
Block a user