Skip to content

Commit

Permalink
[show] Call teamshow using sudo in 'show interfaces portchannel' (son…
Browse files Browse the repository at this point in the history
…ic-net#524)

* teamshow now also prints message and exits if not run as root
  • Loading branch information
jleveque authored Apr 30, 2019
1 parent b531934 commit 8d97400
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions scripts/teamshow
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"""

import json
import os
import re
import swsssdk
import subprocess
Expand Down Expand Up @@ -127,15 +128,17 @@ class Teamshow(object):
print tabulate(output, header)

def main():
if os.geteuid() != 0:
exit("This utility must be run as root")

try:
team = Teamshow()
team.get_portchannel_names()
team.get_teamdctl()
team.get_teamshow_result()
team.display_summary()
except Exception as e:
print e.message
sys.exit(1)
sys.exit(e.message)

if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ def rif(interface, period, verbose):
@click.option('--verbose', is_flag=True, help="Enable verbose output")
def portchannel(verbose):
"""Show PortChannel information"""
cmd = "teamshow"
cmd = "sudo teamshow"
run_command(cmd, display_cmd=verbose)

#
Expand Down

0 comments on commit 8d97400

Please sign in to comment.