Skip to content

Commit

Permalink
[show] Call teamshow using sudo in 'show interfaces portchannel' (#524)
Browse files Browse the repository at this point in the history
* teamshow now also prints message and exits if not run as root
  • Loading branch information
jleveque committed 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.