Skip to content

Commit

Permalink
[show]: If interface has no alias, 'show interfaces alias' outputs in…
Browse files Browse the repository at this point in the history
…terface name as alias (sonic-net#115)
  • Loading branch information
jleveque authored Oct 6, 2017
1 parent c06b37a commit abd5e8a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,22 @@ def alias(interfacename):
body = []

if interfacename is not None:
# If we're given an interface name, output name and alias for that interface only
if interfacename in port_dict:
body.append([interfacename, port_dict[interfacename]['alias']])
if 'alias' in port_dict[interfacename]:
body.append([interfacename, port_dict[interfacename]['alias']])
else:
body.append([interfacename, interfacename])
else:
click.echo("Invalid interface name, '{0}'".format(interfacename))
return
else:
# Output name and alias for all interfaces
for port_name in natsorted(port_dict.keys()):
body.append([port_name, port_dict[port_name]['alias']])
if 'alias' in port_dict[port_name]:
body.append([port_name, port_dict[port_name]['alias']])
else:
body.append([port_name, port_name])

click.echo(tabulate(body, header))

Expand Down

0 comments on commit abd5e8a

Please sign in to comment.