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] remove unnecessary trailing space for show commands #1792

Merged
merged 1 commit into from
Dec 9, 2021
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
34 changes: 17 additions & 17 deletions show/vxlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def interface():
if vtep_sip is not '0.0.0.0':
output = '\tVTEP Name : ' + vtepname + ', SIP : ' + vxlan_table[key]['src_ip']
else:
output = '\tVTEP Name : ' + vtepname
output = '\tVTEP Name : ' + vtepname

click.echo(output)

Expand All @@ -109,7 +109,7 @@ def interface():
if len(key1) == 3 and key1[2] == vtep_sip+'/32':
loopback = key1[1]
break
output = '\tSource interface : ' + loopback
output = '\tSource interface : ' + loopback
if vtep_sip != '0.0.0.0':
click.echo(output)

Expand All @@ -133,7 +133,7 @@ def vlanvnimap(count):
vxlan_count = len(vxlan_keys)

output = 'Total count : '
output += ('%s \n' % (str(vxlan_count)))
output += ('%s\n' % (str(vxlan_count)))
click.echo(output)
else:
vxlan_table = config_db.get_table('VXLAN_TUNNEL_MAP')
Expand All @@ -145,7 +145,7 @@ def vlanvnimap(count):
num += 1
click.echo(tabulate(body, header, tablefmt="grid"))
output = 'Total count : '
output += ('%s \n' % (str(num)))
output += ('%s\n' % (str(num)))
click.echo(output)

@vxlan.command()
Expand All @@ -168,7 +168,7 @@ def vrfvnimap():
num += 1
click.echo(tabulate(body, header, tablefmt="grid"))
output = 'Total count : '
output += ('%s \n' % (str(num)))
output += ('%s\n' % (str(num)))
click.echo(output)

@vxlan.command()
Expand All @@ -183,7 +183,7 @@ def remotevtep(count):
header = ['SIP', 'DIP', 'Creation Source', 'OperStatus']
body = []
db = SonicV2Connector(host='127.0.0.1')
db.connect(db.STATE_DB)
db.connect(db.STATE_DB)

vxlan_keys = db.keys(db.STATE_DB, 'VXLAN_TUNNEL_TABLE|*')

Expand All @@ -194,9 +194,9 @@ def remotevtep(count):

if (count is not None):
output = 'Total count : '
output += ('%s \n' % (str(vxlan_count)))
output += ('%s\n' % (str(vxlan_count)))
click.echo(output)
else:
else:
num = 0
if vxlan_keys is not None:
for key in natsorted(vxlan_keys):
Expand All @@ -207,7 +207,7 @@ def remotevtep(count):
num += 1
click.echo(tabulate(body, header, tablefmt="grid"))
output = 'Total count : '
output += ('%s \n' % (str(num)))
output += ('%s\n' % (str(num)))
click.echo(output)

@vxlan.command()
Expand All @@ -219,11 +219,11 @@ def remotevni(remote_vtep_ip, count):
if (remote_vtep_ip != 'all') and (clicommon.is_ipaddress(remote_vtep_ip ) is False):
click.echo("Remote VTEP IP {} invalid format".format(remote_vtep_ip))
return

header = ['VLAN', 'RemoteVTEP', 'VNI']
body = []
db = SonicV2Connector(host='127.0.0.1')
db.connect(db.APPL_DB)
db.connect(db.APPL_DB)

if(remote_vtep_ip == 'all'):
vxlan_keys = db.keys(db.APPL_DB, 'VXLAN_REMOTE_VNI_TABLE:*')
Expand All @@ -237,7 +237,7 @@ def remotevni(remote_vtep_ip, count):
vxlan_count = len(vxlan_keys)

output = 'Total count : '
output += ('%s \n' % (str(vxlan_count)))
output += ('%s\n' % (str(vxlan_count)))
click.echo(output)
else:
num = 0
Expand All @@ -254,7 +254,7 @@ def remotevni(remote_vtep_ip, count):
num += 1
click.echo(tabulate(body, header, tablefmt="grid"))
output = 'Total count : '
output += ('%s \n' % (str(num)))
output += ('%s\n' % (str(num)))
click.echo(output)

@vxlan.command()
Expand All @@ -263,14 +263,14 @@ def remotevni(remote_vtep_ip, count):
def remotemac(remote_vtep_ip, count):
"""Show MACs pointing to the remote VTEP"""

if (remote_vtep_ip != 'all') and (clicommon.is_ipaddress(remote_vtep_ip ) is False):
if (remote_vtep_ip != 'all') and (clicommon.is_ipaddress(remote_vtep_ip ) is False):
click.echo("Remote VTEP IP {} invalid format".format(remote_vtep_ip))
return

header = ['VLAN', 'MAC', 'RemoteVTEP', 'VNI', 'Type']
body = []
db = SonicV2Connector(host='127.0.0.1')
db.connect(db.APPL_DB)
db.connect(db.APPL_DB)

vxlan_keys = db.keys(db.APPL_DB, 'VXLAN_FDB_TABLE:*')

Expand All @@ -281,7 +281,7 @@ def remotemac(remote_vtep_ip, count):
vxlan_count = len(vxlan_keys)

output = 'Total count : '
output += ('%s \n' % (str(vxlan_count)))
output += ('%s\n' % (str(vxlan_count)))
click.echo(output)
else:
num = 0
Expand All @@ -302,6 +302,6 @@ def remotemac(remote_vtep_ip, count):
if count is None:
click.echo(tabulate(body, header, tablefmt="grid"))
output = 'Total count : '
output += ('%s \n' % (str(num)))
output += ('%s\n' % (str(num)))
click.echo(output)

18 changes: 9 additions & 9 deletions tests/vxlan_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
+---------+-------+
| Vlan200 | 200 |
+---------+-------+
Total count : 4
Total count : 4

"""

Expand All @@ -37,7 +37,7 @@
+=======+=======+
| Vrf1 | 1000 |
+-------+-------+
Total count : 1
Total count : 1

"""

Expand All @@ -52,7 +52,7 @@
+---------+-------------+-------------------+--------------+
| 1.1.1.1 | 25.25.25.27 | EVPN | oper_down |
+---------+-------------+-------------------+--------------+
Total count : 3
Total count : 3

"""

Expand All @@ -66,7 +66,7 @@
+---------+--------------+-------+
| Vlan200 | 25.25.25.27 | 200 |
+---------+--------------+-------+
Total count : 3
Total count : 3

"""

Expand All @@ -76,26 +76,26 @@
+=========+==============+=======+
| Vlan200 | 25.25.25.27 | 200 |
+---------+--------------+-------+
Total count : 1
Total count : 1

"""
show_vxlan_vlanvnimap_cnt_output="""\
Total count : 4
Total count : 4

"""

show_vxlan_tunnel_cnt_output="""\
Total count : 3
Total count : 3

"""

show_vxlan_remotevni_cnt_output="""\
Total count : 3
Total count : 3

"""

show_vxlan_remotevni_specific_cnt_output="""\
Total count : 1
Total count : 1

"""

Expand Down