Skip to content

Commit e3bb8b9

Browse files
jlevequeyxieca
authored andcommitted
[show] Call teamshow using sudo in 'show interfaces portchannel' (#524)
* teamshow now also prints message and exits if not run as root
1 parent 584e706 commit e3bb8b9

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

scripts/teamshow

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"""
2020

2121
import json
22+
import os
2223
import re
2324
import swsssdk
2425
import subprocess
@@ -127,15 +128,17 @@ class Teamshow(object):
127128
print tabulate(output, header)
128129

129130
def main():
131+
if os.geteuid() != 0:
132+
exit("This utility must be run as root")
133+
130134
try:
131135
team = Teamshow()
132136
team.get_portchannel_names()
133137
team.get_teamdctl()
134138
team.get_teamshow_result()
135139
team.display_summary()
136140
except Exception as e:
137-
print e.message
138-
sys.exit(1)
141+
sys.exit(e.message)
139142

140143
if __name__ == "__main__":
141144
main()

show/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ def counters(period, printall, clear, verbose):
579579
@click.option('--verbose', is_flag=True, help="Enable verbose output")
580580
def portchannel(verbose):
581581
"""Show PortChannel information"""
582-
cmd = "teamshow"
582+
cmd = "sudo teamshow"
583583
run_command(cmd, display_cmd=verbose)
584584

585585
#

0 commit comments

Comments
 (0)