diff --git a/show/vxlan.py b/show/vxlan.py index c31a14910c..3d04552904 100644 --- a/show/vxlan.py +++ b/show/vxlan.py @@ -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: @@ -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']]) diff --git a/tests/mock_tables/appl_db.json b/tests/mock_tables/appl_db.json index fd60d8b136..8554a07eaf 100644 --- a/tests/mock_tables/appl_db.json +++ b/tests/mock_tables/appl_db.json @@ -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" }, diff --git a/tests/vxlan_test.py b/tests/vxlan_test.py index 4404ba9de4..61c78dc429 100644 --- a/tests/vxlan_test.py +++ b/tests/vxlan_test.py @@ -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): @@ -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()