1
1
import click
2
- from show .main import AliasedGroup , ip , run_command
2
+ from show .main import ip , run_command
3
3
from utilities_common .bgp_util import get_bgp_summary_extended
4
4
import utilities_common .constants as constants
5
+ import utilities_common .cli as clicommon
5
6
6
7
7
8
###############################################################################
11
12
###############################################################################
12
13
13
14
14
- @ip .group (cls = AliasedGroup )
15
+ @ip .group (cls = clicommon . AliasedGroup )
15
16
def bgp ():
16
17
"""Show IPv4 BGP (Border Gateway Protocol) information"""
17
18
pass
@@ -22,10 +23,10 @@ def bgp():
22
23
def summary ():
23
24
"""Show summarized information of IPv4 BGP state"""
24
25
try :
25
- device_output = run_command ('sudo {} -c "show ip bgp summary"' . format ( constants . RVTYSH_COMMAND ) , return_cmd = True )
26
+ device_output = run_command ([ 'sudo' , constants . RVTYSH_COMMAND , '-c' , "show ip bgp summary" ] , return_cmd = True )
26
27
get_bgp_summary_extended (device_output )
27
28
except Exception :
28
- run_command ('sudo {} -c "show ip bgp summary"' . format ( constants . RVTYSH_COMMAND ) )
29
+ run_command ([ 'sudo' , constants . RVTYSH_COMMAND , '-c' , "show ip bgp summary" ] )
29
30
30
31
31
32
# 'neighbors' subcommand ("show ip bgp neighbors")
@@ -35,15 +36,13 @@ def summary():
35
36
def neighbors (ipaddress , info_type ):
36
37
"""Show IP (IPv4) BGP neighbors"""
37
38
38
- command = 'sudo {} -c "show ip bgp neighbor' . format ( constants . RVTYSH_COMMAND )
39
+ command = [ 'sudo' , constants . RVTYSH_COMMAND , '-c' , "show ip bgp neighbor" ]
39
40
40
41
if ipaddress is not None :
41
- command += ' {}' .format (ipaddress )
42
+ command [ - 1 ] += ' {}' .format (ipaddress )
42
43
43
44
# info_type is only valid if ipaddress is specified
44
45
if info_type is not None :
45
- command += ' {}' .format (info_type )
46
-
47
- command += '"'
46
+ command [- 1 ] += ' {}' .format (info_type )
48
47
49
48
run_command (command )
0 commit comments