Skip to content

Commit

Permalink
Fix for show vxlan tunnel command display issue #11902 (#2391)
Browse files Browse the repository at this point in the history
* Issue: Only one vni to vlan map entry in the output of show vxlan tunnel command Fix:
Fix: Added fix to display all vni to vlan map entries for "show vxlan tunnel" and "show vxlan name commands.
  • Loading branch information
skbhava authored and yxieca committed Oct 3, 2022
1 parent e1d827e commit f41e4d1
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 8 deletions.
30 changes: 22 additions & 8 deletions show/vxlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,17 @@ def name(vxlan_name):
vxlan_map_keys = config_db.keys(config_db.CONFIG_DB,
'VXLAN_TUNNEL_MAP{}{}{}*'.format(config_db.KEY_SEPARATOR, vxlan_name, config_db.KEY_SEPARATOR))
if vxlan_map_keys:
vxlan_map_mapping = config_db.get_all(config_db.CONFIG_DB, vxlan_map_keys[0])
r.append(vxlan_map_keys[0].split(config_db.KEY_SEPARATOR, 2)[2])
r.append("{} -> {}".format(vxlan_map_mapping.get('vni'), vxlan_map_mapping.get('vlan')))
table.append(r)
for key in natsorted(vxlan_map_keys):
vxlan_map_mapping = config_db.get_all(config_db.CONFIG_DB, key)
r.append(key.split(config_db.KEY_SEPARATOR, 2)[2])
r.append("{} -> {}".format(vxlan_map_mapping.get('vni'), vxlan_map_mapping.get('vlan')))
table.append(r)
r = []
r.append(' ')
r.append(' ')
r.append(' ')
else:
table.append(r)

click.echo(tabulate(table, header))

Expand All @@ -59,10 +66,17 @@ def tunnel():
vxlan_map_keys = config_db.keys(config_db.CONFIG_DB,
'VXLAN_TUNNEL_MAP{}{}{}*'.format(config_db.KEY_SEPARATOR, k, config_db.KEY_SEPARATOR))
if vxlan_map_keys:
vxlan_map_mapping = config_db.get_all(config_db.CONFIG_DB, vxlan_map_keys[0])
r.append(vxlan_map_keys[0].split(config_db.KEY_SEPARATOR, 2)[2])
r.append("{} -> {}".format(vxlan_map_mapping.get('vni'), vxlan_map_mapping.get('vlan')))
table.append(r)
for key in natsorted(vxlan_map_keys):
vxlan_map_mapping = config_db.get_all(config_db.CONFIG_DB, key)
r.append(key.split(config_db.KEY_SEPARATOR, 2)[2])
r.append("{} -> {}".format(vxlan_map_mapping.get('vni'), vxlan_map_mapping.get('vlan')))
table.append(r)
r = []
r.append(' ')
r.append(' ')
r.append(' ')
else:
table.append(r)

click.echo(tabulate(table, header))

Expand Down
25 changes: 25 additions & 0 deletions tests/vxlan_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@
"""

show_vxlan_name_output="""\
vxlan tunnel name source ip destination ip tunnel map name tunnel map mapping(vni -> vlan)
------------------- ----------- ---------------- ----------------- ---------------------------------
vtep1 1.1.1.1 map_100_Vlan100 100 -> Vlan100
map_101_Vlan101 101 -> Vlan101
map_102_Vlan102 102 -> Vlan102
map_200_Vlan200 200 -> Vlan200
"""

show_vxlan_remotevni_output="""\
+---------+--------------+-------+
| VLAN | RemoteVTEP | VNI |
Expand Down Expand Up @@ -141,6 +150,22 @@ def test_show_vxlan_tunnel(self):
assert result.exit_code == 0
assert result.output == show_vxlan_tunnel_output

def test_show_vxlan_tunnel_output(self):
runner = CliRunner()
result = runner.invoke(show.cli.commands["vxlan"].commands["tunnel"], [])
print(result.exit_code)
print(result.output)
assert result.exit_code == 0
assert result.output == show_vxlan_name_output

def test_show_vxlan_name_vtep(self):
runner = CliRunner()
result = runner.invoke(show.cli.commands["vxlan"].commands["name"],["vtep1"])
print(result.exit_code)
print(result.output)
assert result.exit_code == 0
assert result.output == show_vxlan_name_output

def test_show_vxlan_remotevni(self):
runner = CliRunner()
result = runner.invoke(show.cli.commands["vxlan"].commands["remotevni"], ["all"])
Expand Down

0 comments on commit f41e4d1

Please sign in to comment.