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

[VXLAN]Fixing traceback in show remotemac when mac moves during command execution #2506

Merged
merged 3 commits into from
Nov 22, 2022
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
8 changes: 4 additions & 4 deletions show/vxlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ def interface():
vtepname = key1.pop();
if 'src_ip' in vxlan_table[key]:
vtep_sip = vxlan_table[key]['src_ip']
if vtep_sip is not '0.0.0.0':
if vtep_sip != '0.0.0.0':
output = '\tVTEP Name : ' + vtepname + ', SIP : ' + vxlan_table[key]['src_ip']
else:
output = '\tVTEP Name : ' + vtepname

click.echo(output)

if vtep_sip is not '0.0.0.0':
if vtep_sip != '0.0.0.0':
vxlan_table = config_db.get_table('VXLAN_EVPN_NVO')
vxlan_keys = vxlan_table.keys()
if vxlan_keys is not None:
Expand Down Expand Up @@ -307,8 +307,8 @@ def remotemac(remote_vtep_ip, count):
vxlan_table = db.get_all(db.APPL_DB, key);
if vxlan_table is None:
continue
rmtip = vxlan_table['remote_vtep']
if remote_vtep_ip != 'all' and rmtip != remote_vtep_ip:
rmtip = vxlan_table.get('remote_vtep')
if remote_vtep_ip != 'all' and rmtip != remote_vtep_ip or rmtip is None:
continue
if count is None:
body.append([vlan, mac, rmtip, vxlan_table['vni'], vxlan_table['type']])
Expand Down
10 changes: 10 additions & 0 deletions tests/mock_tables/appl_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,16 @@
"VXLAN_REMOTE_VNI_TABLE:Vlan200:25.25.25.27": {
"vni": "200"
},
"VXLAN_FDB_TABLE:Vlan200:00:02:00:00:47:e2": {
"remote_vtep": "2.2.2.2",
"type": "dynamic",
"vni": "200"
},
"VXLAN_FDB_TABLE:Vlan200:00:02:00:00:47:e3": {
"remote_vtep": "2.2.2.3",
"type": "dynamic",
"vni": "200"
},
"MUX_CABLE_TABLE:Ethernet32": {
"state": "active"
},
Expand Down
64 changes: 64 additions & 0 deletions tests/vxlan_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,38 @@

"""

show_vxlan_remotemac_all_output="""\
+---------+-------------------+--------------+-------+---------+
| VLAN | MAC | RemoteVTEP | VNI | Type |
+=========+===================+==============+=======+=========+
| Vlan200 | 00:02:00:00:47:e2 | 2.2.2.2 | 200 | dynamic |
+---------+-------------------+--------------+-------+---------+
| Vlan200 | 00:02:00:00:47:e3 | 2.2.2.3 | 200 | dynamic |
+---------+-------------------+--------------+-------+---------+
Total count : 2

"""

show_vxlan_remotemac_specific_output="""\
+---------+-------------------+--------------+-------+---------+
| VLAN | MAC | RemoteVTEP | VNI | Type |
+=========+===================+==============+=======+=========+
| Vlan200 | 00:02:00:00:47:e2 | 2.2.2.2 | 200 | dynamic |
+---------+-------------------+--------------+-------+---------+
Total count : 1

"""

show_vxlan_remotemac_cnt_output="""\
Total count : 2

"""

show_vxlan_remotemac_specific_cnt_output="""\
Total count : 1

"""

class TestVxlan(object):
@classmethod
def setup_class(cls):
Expand Down Expand Up @@ -215,6 +247,38 @@ def test_show_vxlan_remotevni_specific_cnt(self):
assert result.exit_code == 0
assert result.output == show_vxlan_remotevni_specific_cnt_output

def test_show_vxlan_remotemac(self):
runner = CliRunner()
result = runner.invoke(show.cli.commands["vxlan"].commands["remotemac"], ["all"])
print(result.exit_code)
print(result.output)
assert result.exit_code == 0
assert result.output == show_vxlan_remotemac_all_output

def test_show_vxlan_remotemac_specific(self):
runner = CliRunner()
result = runner.invoke(show.cli.commands["vxlan"].commands["remotemac"], ["2.2.2.2"])
print(result.exit_code)
print(result.output)
assert result.exit_code == 0
assert result.output == show_vxlan_remotemac_specific_output

def test_show_vxlan_remotemac_cnt(self):
runner = CliRunner()
result = runner.invoke(show.cli.commands["vxlan"].commands["remotemac"], ["all", "count"])
print(result.exit_code)
print(result.output)
assert result.exit_code == 0
assert result.output == show_vxlan_remotemac_cnt_output

def test_show_vxlan_remotemac_specific_cnt(self):
runner = CliRunner()
result = runner.invoke(show.cli.commands["vxlan"].commands["remotemac"], ["2.2.2.2", "count"])
print(result.exit_code)
print(result.output)
assert result.exit_code == 0
assert result.output == show_vxlan_remotemac_specific_cnt_output

def test_config_vxlan_add(self):
runner = CliRunner()
db = Db()
Expand Down