From b004658a885df73191e754750a78c6513d875aee Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Tue, 30 Apr 2019 21:06:24 +0000 Subject: [PATCH 1/2] [show] Call teamshow using sudo in 'show interfaces portchannel' --- show/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/show/main.py b/show/main.py index b853507b62..1a078ad134 100755 --- a/show/main.py +++ b/show/main.py @@ -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) # From 547c317e51ad4e446101ea080fd314018d8f3dda Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Tue, 30 Apr 2019 21:23:45 +0000 Subject: [PATCH 2/2] teamshow prints message and exits if not run as root --- scripts/teamshow | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/teamshow b/scripts/teamshow index 3c157f75fe..3ea2691eda 100755 --- a/scripts/teamshow +++ b/scripts/teamshow @@ -19,6 +19,7 @@ """ import json +import os import re import swsssdk import subprocess @@ -127,6 +128,9 @@ 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() @@ -134,8 +138,7 @@ def main(): 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()