From 1882ab76ff64ff6014ae8e72195170d6891f5602 Mon Sep 17 00:00:00 2001 From: Prem Prakash Date: Wed, 19 Jun 2019 00:16:55 -0700 Subject: [PATCH 1/3] [Sonic-utilities]: Added commands to view acl and port running configs --- doc/Command-Reference.md | 34 +++++++++++++++++++++++++++++++++- show/main.py | 23 +++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/doc/Command-Reference.md b/doc/Command-Reference.md index 6e39650289..1e11dab5e2 100644 --- a/doc/Command-Reference.md +++ b/doc/Command-Reference.md @@ -2785,6 +2785,8 @@ This sub-section explains the show commands for displaying the running configura 3) ntp 4) snmp 5) all +6) accesslist +7) interface **show runningconfiguration all** @@ -2851,6 +2853,36 @@ This command displays the running configuration of the snmp module. admin@sonic:~$ show runningconfiguration snmp ``` +**show runningconfiguration accesslist** + +This command displays the running configuration of the acls + + - Usage: + show runningconfiguration accesslist + + +- Example: + ``` + admin@sonic:~$ show runningconfiguration accesslist + ``` + +**show runningconfiguration interface ** + +This command displays the running configuration of the ports + + - Usage: + show runningconfiguration interface + + +- Example: + ``` + admin@sonic:~$ show runningconfiguration interface + ``` + + ``` + admin@sonic:~$ show runningconfiguration interface + ``` + Go Back To [Beginning of the document](#SONiC-COMMAND-LINE-INTERFACE-GUIDE) or [Beginning of this section](#Startup--Running-Configuration) @@ -3677,4 +3709,4 @@ Once if users go to "vtysh", they can use the routing stack specific commands as Refer the routing stack [Quagga Command Reference](https://www.quagga.net/docs/quagga.pdf) or [FRR Command Reference](https://buildmedia.readthedocs.org/media/pdf/frrouting/latest/frrouting.pdf) to know more about about the routing stack configuration. -Go Back To [Beginning of the document](#SONiC-COMMAND-LINE-INTERFACE-GUIDE) \ No newline at end of file +Go Back To [Beginning of the document](#SONiC-COMMAND-LINE-INTERFACE-GUIDE) diff --git a/show/main.py b/show/main.py index b55184fe9e..5a4412f8cc 100755 --- a/show/main.py +++ b/show/main.py @@ -1329,6 +1329,29 @@ def all(verbose): run_command(cmd, display_cmd=verbose) +# 'accesslist' subcommand ("show runningconfiguration accesslist") +@runningconfiguration.command() +@click.option('--verbose', is_flag=True, help="Enable verbose output") +def accesslist(verbose): + """Show acl running configuration""" + cmd = "sonic-cfggen -d --print-acl" + run_command(cmd, display_cmd=verbose) + + +# 'interface' subcommand ("show runningconfiguration interface ") +@runningconfiguration.command() +@click.argument('interfacename', required=False) +@click.option('--verbose', is_flag=True, help="Enable verbose output") +def interface(interfacename, verbose): + """Show port running configuration""" + cmd = "sonic-cfggen -d --print-port" + + if interfacename is not None: + cmd += " {0} {1}".format("--interface", interfacename) + + run_command(cmd, display_cmd=verbose) + + # 'bgp' subcommand ("show runningconfiguration bgp") @runningconfiguration.command() @click.option('--verbose', is_flag=True, help="Enable verbose output") From 3083f798369d743a05e620b6774034bb0d5b0219 Mon Sep 17 00:00:00 2001 From: Prem Prakash Date: Sun, 23 Jun 2019 21:53:25 -0700 Subject: [PATCH 2/3] Use --var-json to show running configs of port/specific port and acls --- show/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/show/main.py b/show/main.py index 5a4412f8cc..e36ab1a876 100755 --- a/show/main.py +++ b/show/main.py @@ -1334,7 +1334,7 @@ def all(verbose): @click.option('--verbose', is_flag=True, help="Enable verbose output") def accesslist(verbose): """Show acl running configuration""" - cmd = "sonic-cfggen -d --print-acl" + cmd = "sonic-cfggen -d --var-json ACL_RULE" run_command(cmd, display_cmd=verbose) @@ -1344,7 +1344,7 @@ def accesslist(verbose): @click.option('--verbose', is_flag=True, help="Enable verbose output") def interface(interfacename, verbose): """Show port running configuration""" - cmd = "sonic-cfggen -d --print-port" + cmd = "sonic-cfggen -d --var-json PORT" if interfacename is not None: cmd += " {0} {1}".format("--interface", interfacename) From 912178289ff9330d76695f580e3e62519ab7e00c Mon Sep 17 00:00:00 2001 From: Prem Prakash Date: Mon, 24 Jun 2019 21:43:47 -0700 Subject: [PATCH 3/3] Renaming accesslist to acl to maintain the consistency --- doc/Command-Reference.md | 8 ++++---- show/main.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/Command-Reference.md b/doc/Command-Reference.md index 1e11dab5e2..6e88305731 100644 --- a/doc/Command-Reference.md +++ b/doc/Command-Reference.md @@ -2785,7 +2785,7 @@ This sub-section explains the show commands for displaying the running configura 3) ntp 4) snmp 5) all -6) accesslist +6) acl 7) interface **show runningconfiguration all** @@ -2853,17 +2853,17 @@ This command displays the running configuration of the snmp module. admin@sonic:~$ show runningconfiguration snmp ``` -**show runningconfiguration accesslist** +**show runningconfiguration acl** This command displays the running configuration of the acls - Usage: - show runningconfiguration accesslist + show runningconfiguration acl - Example: ``` - admin@sonic:~$ show runningconfiguration accesslist + admin@sonic:~$ show runningconfiguration acl ``` **show runningconfiguration interface ** diff --git a/show/main.py b/show/main.py index e36ab1a876..402a6b7641 100755 --- a/show/main.py +++ b/show/main.py @@ -1329,10 +1329,10 @@ def all(verbose): run_command(cmd, display_cmd=verbose) -# 'accesslist' subcommand ("show runningconfiguration accesslist") +# 'acl' subcommand ("show runningconfiguration acl") @runningconfiguration.command() @click.option('--verbose', is_flag=True, help="Enable verbose output") -def accesslist(verbose): +def acl(verbose): """Show acl running configuration""" cmd = "sonic-cfggen -d --var-json ACL_RULE" run_command(cmd, display_cmd=verbose)