Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support "show cli" for Multi Npu platforms. #889

Closed
wants to merge 3 commits into from

Conversation

arlakshm
Copy link
Contributor

@arlakshm arlakshm commented Apr 24, 2020

Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan arlakshm@microsoft.com

- What I did
Support the following show commands for Multi NPU platforms.

  • show interface status
  • show interface description
  • show interface portchannel
  • show ip bgp summary
  • show ipv6 bgp summary

To each of the above mentioned commands 2 new options have added

  1. [-n, --namespace] to allow user to display the information for given namespaces
    If this option is not present the information from all the namespaces will be displayed

  2. [-d, --display] to allow user to display information related both internal and external interfaces
    If this option is not present only external interfaces/neighbors will be display

One single NPU platform, this options are not valid, so the behavior remains unchanged

- How I did it
The following changes are done in this PR.

  1. Changes to intfutil script.
    Two new arguments are added intfutil script
    "-n" and "-d" for support the multi npu options described above
  2. Changes to teamshow
    Two new arguments are added intfutil script
    "-n" and "-d" for support the multi npu options described above
  3. A new function introduce to parse the vtysh output for "show ip bgp summary" and filter the internal neighbors based on the display options

- How to verify it
Sample output

Help menu on single Npu platforms


admin@sonic:/home/admin# show interface status -h
Usage: show interface status [OPTIONS] [INTERFACENAME]

  Show Interface status information

Options:
  --verbose            Enable verbose output
  **-d, --display [all]  Show internal interfaces  [default: all]
  -n, --namespace []   Namespace name or all**
  -?, -h, --help       Show this message and exit.

Help menu on multi Npu platforms

admin@sonic:~$ show interface status -h
Usage: show interface status [OPTIONS] [INTERFACENAME]

  Show Interface status information

Options:
  --verbose                       Enable verbose output
  **-d, --display [all|frontend]    Show internal interfaces  [default:
                                  frontend]
  -n, --namespace [asic0|asic1|asic2|asic3|asic4|asic5]**
                                  Namespace name or all
  -?, -h, --help                  Show this message and exit.
admin@sonic:~$ show interface status 

Sample Interface Status

admin@sonic:~$ show interface status 
Warning: failed to retrieve PORT table from ConfigDB!
      Interface        Lanes    Speed    MTU         Alias             Vlan    Oper    Admin    Type    Asym PFC
---------------  -----------  -------  -----  ------------  ---------------  ------  -------  ------  ----------
      Ethernet0  33,34,35,36      40G   9100   Ethernet1/1  PortChannel0002      up       up     N/A         off
      Ethernet4  29,30,31,32      40G   9100   Ethernet1/2  PortChannel0002      up       up     N/A         off
      Ethernet8  41,42,43,44      40G   9100   Ethernet1/3           routed    down     down     N/A         off
     Ethernet12  37,38,39,40      40G   9100   Ethernet1/4           routed    down     down     N/A         off
     Ethernet16  49,50,51,52      40G   9100   Ethernet1/5  PortChannel0005      up       up     N/A         off
     Ethernet20  45,46,47,48      40G   9100   Ethernet1/6  PortChannel0005      up       up     N/A         off
     Ethernet24  57,58,59,60      40G   9100   Ethernet1/7           routed    down     down     N/A         off
     Ethernet28  53,54,55,56      40G   9100   Ethernet1/8           routed    down     down     N/A         off
     Ethernet32  65,66,67,68      40G   9100   Ethernet1/9           routed    down     down     N/A         off
     Ethernet36  61,62,63,64      40G   9100  Ethernet1/10           routed    down     down     N/A         off
     Ethernet40  73,74,75,76      40G   9100  Ethernet1/11           routed    down     down     N/A         off
     Ethernet44  69,70,71,72      40G   9100  Ethernet1/12           routed    down     down     N/A         off
     Ethernet48  81,82,83,84      40G   9100  Ethernet1/13           routed    down     down     N/A         off
     Ethernet52  77,78,79,80      40G   9100  Ethernet1/14           routed    down     down     N/A         off
     Ethernet56  89,90,91,92      40G   9100  Ethernet1/15           routed    down     down     N/A         off
     Ethernet60  85,86,87,88      40G   9100  Ethernet1/16           routed    down     down     N/A         off
     Ethernet64  33,34,35,36      40G   9100  Ethernet1/17  PortChannel0008      up       up     N/A         off
     Ethernet68  29,30,31,32      40G   9100  Ethernet1/18  PortChannel0008      up       up     N/A         off
     Ethernet72  41,42,43,44      40G   9100  Ethernet1/19           routed    down     down     N/A         off
     Ethernet76  37,38,39,40      40G   9100  Ethernet1/20           routed    down     down     N/A         off
     Ethernet80  49,50,51,52      40G   9100  Ethernet1/21  PortChannel0011      up       up     N/A         off
     Ethernet84  45,46,47,48      40G   9100  Ethernet1/22  PortChannel0011      up       up     N/A         off
     Ethernet88  57,58,59,60      40G   9100  Ethernet1/23           routed    down     down     N/A         off
     Ethernet92  53,54,55,56      40G   9100  Ethernet1/24           routed    down     down     N/A         off
     Ethernet96  65,66,67,68      40G   9100  Ethernet1/25           routed    down     down     N/A         off
    Ethernet100  61,62,63,64      40G   9100  Ethernet1/26           routed    down     down     N/A         off
    Ethernet104  73,74,75,76      40G   9100  Ethernet1/27           routed    down     down     N/A         off
    Ethernet108  69,70,71,72      40G   9100  Ethernet1/28           routed    down     down     N/A         off
    Ethernet112  81,82,83,84      40G   9100  Ethernet1/29           routed    down     down     N/A         off
    Ethernet116  77,78,79,80      40G   9100  Ethernet1/30           routed    down     down     N/A         off
    Ethernet120  89,90,91,92      40G   9100  Ethernet1/31           routed    down     down     N/A         off
    Ethernet124  85,86,87,88      40G   9100  Ethernet1/32           routed    down     down     N/A         off
    Ethernet128  33,34,35,36      40G   9100  Ethernet1/33           routed    down     down     N/A         off
    Ethernet132  29,30,31,32      40G   9100  Ethernet1/34           routed    down     down     N/A         off
    Ethernet136  41,42,43,44      40G   9100  Ethernet1/35  PortChannel0001      up       up     N/A         off
    Ethernet140  37,38,39,40      40G   9100  Ethernet1/36           routed    down     down     N/A         off
    Ethernet144  49,50,51,52      40G   9100  Ethernet1/37  PortChannel0003      up       up     N/A         off
    Ethernet148  45,46,47,48      40G   9100  Ethernet1/38  PortChannel0004      up       up     N/A         off
    Ethernet152  57,58,59,60      40G   9100  Ethernet1/39  PortChannel0006      up       up     N/A         off
    Ethernet156  53,54,55,56      40G   9100  Ethernet1/40  PortChannel0007      up       up     N/A         off
    Ethernet160  65,66,67,68      40G   9100  Ethernet1/41           routed    down     down     N/A         off
    Ethernet164  61,62,63,64      40G   9100  Ethernet1/42           routed    down     down     N/A         off
    Ethernet168  73,74,75,76      40G   9100  Ethernet1/43  PortChannel0009      up       up     N/A         off
    Ethernet172  69,70,71,72      40G   9100  Ethernet1/44           routed    down     down     N/A         off
    Ethernet176  81,82,83,84      40G   9100  Ethernet1/45  PortChannel0010      up       up     N/A         off
    Ethernet180  77,78,79,80      40G   9100  Ethernet1/46  PortChannel0012      up       up     N/A         off
    Ethernet184  89,90,91,92      40G   9100  Ethernet1/47  PortChannel0013      up       up     N/A         off
    Ethernet188  85,86,87,88      40G   9100  Ethernet1/48  PortChannel0014      up       up     N/A         off
    Ethernet192  33,34,35,36      40G   9100  Ethernet1/49           routed    down     down     N/A         off
    Ethernet196  29,30,31,32      40G   9100  Ethernet1/50           routed    down     down     N/A         off
    Ethernet200  41,42,43,44      40G   9100  Ethernet1/51  PortChannel0015      up       up     N/A         off
    Ethernet204  37,38,39,40      40G   9100  Ethernet1/52           routed    down     down     N/A         off
    Ethernet208  49,50,51,52      40G   9100  Ethernet1/53  PortChannel0016      up       up     N/A         off
    Ethernet212  45,46,47,48      40G   9100  Ethernet1/54  PortChannel0017      up       up     N/A         off
    Ethernet216  57,58,59,60      40G   9100  Ethernet1/55  PortChannel0018      up       up     N/A         off
    Ethernet220  53,54,55,56      40G   9100  Ethernet1/56  PortChannel0019      up       up     N/A         off
    Ethernet224  65,66,67,68      40G   9100  Ethernet1/57           routed    down     down     N/A         off
    Ethernet228  61,62,63,64      40G   9100  Ethernet1/58           routed    down     down     N/A         off
    Ethernet232  73,74,75,76      40G   9100  Ethernet1/59  PortChannel0020      up       up     N/A         off
    Ethernet236  69,70,71,72      40G   9100  Ethernet1/60           routed    down     down     N/A         off
    Ethernet240  81,82,83,84      40G   9100  Ethernet1/61  PortChannel0021      up       up     N/A         off
    Ethernet244  77,78,79,80      40G   9100  Ethernet1/62  PortChannel0022      up       up     N/A         off
    Ethernet248  89,90,91,92      40G   9100  Ethernet1/63  PortChannel0023      up       up     N/A         off
    Ethernet252  85,86,87,88      40G   9100  Ethernet1/64  PortChannel0024      up       up     N/A         off
PortChannel0001          N/A      40G   9100           N/A           routed      up       up     N/A         N/A
PortChannel0002          N/A      80G   9100           N/A           routed      up       up     N/A         N/A
PortChannel0003          N/A      40G   9100           N/A           routed      up       up     N/A         N/A
PortChannel0004          N/A      40G   9100           N/A           routed      up       up     N/A         N/A
PortChannel0005          N/A      80G   9100           N/A           routed      up       up     N/A         N/A
PortChannel0006          N/A      40G   9100           N/A           routed      up       up     N/A         N/A
PortChannel0007          N/A      40G   9100           N/A           routed      up       up     N/A         N/A
PortChannel0008          N/A      80G   9100           N/A           routed      up       up     N/A         N/A
PortChannel0009          N/A      40G   9100           N/A           routed      up       up     N/A         N/A
PortChannel0010          N/A      40G   9100           N/A           routed      up       up     N/A         N/A
PortChannel0011          N/A      80G   9100           N/A           routed      up       up     N/A         N/A
PortChannel0012          N/A      40G   9100           N/A           routed      up       up     N/A         N/A
PortChannel0013          N/A      40G   9100           N/A           routed      up       up     N/A         N/A
PortChannel0014          N/A      40G   9100           N/A           routed      up       up     N/A         N/A
PortChannel0015          N/A      40G   9100           N/A           routed      up       up     N/A         N/A
PortChannel0016          N/A      40G   9100           N/A           routed      up       up     N/A         N/A
PortChannel0017          N/A      40G   9100           N/A           routed      up       up     N/A         N/A
PortChannel0018          N/A      40G   9100           N/A           routed      up       up     N/A         N/A
PortChannel0019          N/A      40G   9100           N/A           routed      up       up     N/A         N/A
PortChannel0020          N/A      40G   9100           N/A           routed      up       up     N/A         N/A
PortChannel0021          N/A      40G   9100           N/A           routed      up       up     N/A         N/A
PortChannel0022          N/A      40G   9100           N/A           routed      up       up     N/A         N/A
PortChannel0023          N/A      40G   9100           N/A           routed      up       up     N/A         N/A
PortChannel0024          N/A      40G   9100           N/A           routed      up       up     N/A         N/A

Sample output for specific ASIC

admin@sonic:~$ show interface status -n asic1 
Warning: failed to retrieve PORT table from ConfigDB!
      Interface        Lanes    Speed    MTU         Alias             Vlan    Oper    Admin    Type    Asym PFC
---------------  -----------  -------  -----  ------------  ---------------  ------  -------  ------  ----------
     Ethernet64  33,34,35,36      40G   9100  Ethernet1/17  PortChannel0008      up       up     N/A         off
     Ethernet68  29,30,31,32      40G   9100  Ethernet1/18  PortChannel0008      up       up     N/A         off
     Ethernet72  41,42,43,44      40G   9100  Ethernet1/19           routed    down     down     N/A         off
     Ethernet76  37,38,39,40      40G   9100  Ethernet1/20           routed    down     down     N/A         off
     Ethernet80  49,50,51,52      40G   9100  Ethernet1/21  PortChannel0011      up       up     N/A         off
     Ethernet84  45,46,47,48      40G   9100  Ethernet1/22  PortChannel0011      up       up     N/A         off
     Ethernet88  57,58,59,60      40G   9100  Ethernet1/23           routed    down     down     N/A         off
     Ethernet92  53,54,55,56      40G   9100  Ethernet1/24           routed    down     down     N/A         off
     Ethernet96  65,66,67,68      40G   9100  Ethernet1/25           routed    down     down     N/A         off
    Ethernet100  61,62,63,64      40G   9100  Ethernet1/26           routed    down     down     N/A         off
    Ethernet104  73,74,75,76      40G   9100  Ethernet1/27           routed    down     down     N/A         off
    Ethernet108  69,70,71,72      40G   9100  Ethernet1/28           routed    down     down     N/A         off
    Ethernet112  81,82,83,84      40G   9100  Ethernet1/29           routed    down     down     N/A         off
    Ethernet116  77,78,79,80      40G   9100  Ethernet1/30           routed    down     down     N/A         off
    Ethernet120  89,90,91,92      40G   9100  Ethernet1/31           routed    down     down     N/A         off
    Ethernet124  85,86,87,88      40G   9100  Ethernet1/32           routed    down     down     N/A         off
PortChannel0008          N/A      80G   9100           N/A           routed      up       up     N/A         N/A
PortChannel0011          N/A      80G   9100           N/A           routed      up       up     N/A         N/A

Sample output of specific asic display internal and external interfaces

admin@sonic:~$ show interface status -n asic1 -d all
Warning: failed to retrieve PORT table from ConfigDB!
      Interface            Lanes    Speed    MTU           Alias             Vlan    Oper    Admin    Type    Asym PFC
---------------  ---------------  -------  -----  --------------  ---------------  ------  -------  ------  ----------
     Ethernet64      33,34,35,36      40G   9100    Ethernet1/17  PortChannel0008      up       up     N/A         off
     Ethernet68      29,30,31,32      40G   9100    Ethernet1/18  PortChannel0008      up       up     N/A         off
     Ethernet72      41,42,43,44      40G   9100    Ethernet1/19           routed    down     down     N/A         off
     Ethernet76      37,38,39,40      40G   9100    Ethernet1/20           routed    down     down     N/A         off
     Ethernet80      49,50,51,52      40G   9100    Ethernet1/21  PortChannel0011      up       up     N/A         off
     Ethernet84      45,46,47,48      40G   9100    Ethernet1/22  PortChannel0011      up       up     N/A         off
     Ethernet88      57,58,59,60      40G   9100    Ethernet1/23           routed    down     down     N/A         off
     Ethernet92      53,54,55,56      40G   9100    Ethernet1/24           routed    down     down     N/A         off
     Ethernet96      65,66,67,68      40G   9100    Ethernet1/25           routed    down     down     N/A         off
    Ethernet100      61,62,63,64      40G   9100    Ethernet1/26           routed    down     down     N/A         off
    Ethernet104      73,74,75,76      40G   9100    Ethernet1/27           routed    down     down     N/A         off
    Ethernet108      69,70,71,72      40G   9100    Ethernet1/28           routed    down     down     N/A         off
    Ethernet112      81,82,83,84      40G   9100    Ethernet1/29           routed    down     down     N/A         off
    Ethernet116      77,78,79,80      40G   9100    Ethernet1/30           routed    down     down     N/A         off
    Ethernet120      89,90,91,92      40G   9100    Ethernet1/31           routed    down     down     N/A         off
    Ethernet124      85,86,87,88      40G   9100    Ethernet1/32           routed    down     down     N/A         off
  Ethernet-BP64  125,126,127,128      40G   9100   Ethernet-BP64  PortChannel4003      up       up     N/A         off
  Ethernet-BP68          1,2,3,4      40G   9100   Ethernet-BP68  PortChannel4003      up       up     N/A         off
  Ethernet-BP72          5,6,7,8      40G   9100   Ethernet-BP72  PortChannel4003      up       up     N/A         off
  Ethernet-BP76       9,10,11,12      40G   9100   Ethernet-BP76  PortChannel4003      up       up     N/A         off
  Ethernet-BP80      13,14,15,16      40G   9100   Ethernet-BP80  PortChannel4003      up       up     N/A         off
  Ethernet-BP84      17,18,19,20      40G   9100   Ethernet-BP84  PortChannel4003      up       up     N/A         off
  Ethernet-BP88      21,22,23,24      40G   9100   Ethernet-BP88  PortChannel4003      up       up     N/A         off
  Ethernet-BP92      25,26,27,28      40G   9100   Ethernet-BP92  PortChannel4003      up       up     N/A         off
  Ethernet-BP96      93,94,95,96      40G   9100   Ethernet-BP96  PortChannel4004      up       up     N/A         off
 Ethernet-BP100     97,98,99,100      40G   9100  Ethernet-BP100  PortChannel4004      up       up     N/A         off
 Ethernet-BP104  101,102,103,104      40G   9100  Ethernet-BP104  PortChannel4004      up       up     N/A         off
 Ethernet-BP108  105,106,107,108      40G   9100  Ethernet-BP108  PortChannel4004      up       up     N/A         off
 Ethernet-BP112  109,110,111,112      40G   9100  Ethernet-BP112  PortChannel4004      up       up     N/A         off
 Ethernet-BP116  113,114,115,116      40G   9100  Ethernet-BP116  PortChannel4004      up       up     N/A         off
 Ethernet-BP120  117,118,119,120      40G   9100  Ethernet-BP120  PortChannel4004      up       up     N/A         off
 Ethernet-BP124  121,122,123,124      40G   9100  Ethernet-BP124  PortChannel4004      up       up     N/A         off
PortChannel0008              N/A      80G   9100             N/A           routed      up       up     N/A         N/A
PortChannel0011              N/A      80G   9100             N/A           routed      up       up     N/A         N/A
PortChannel4003              N/A     320G   9100             N/A           routed      up       up     N/A         N/A
PortChannel4004              N/A     320G   9100             N/A           routed      up       up     N/A         N/A

- Previous command output (if the output of a command-line utility has changed)

- New command output (if the output of a command-line utility has changed)

Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
@arlakshm arlakshm marked this pull request as ready for review April 25, 2020 00:41
@lgtm-com
Copy link

lgtm-com bot commented Apr 25, 2020

This pull request introduces 4 alerts when merging 32568af into fc719ad - view on LGTM.com

new alerts:

  • 3 for Unused import
  • 1 for Comparison using is when operands support __eq__

Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
@jleveque
Copy link
Contributor

@arlakshm: FYI, whenever adding/removing/modifying subcommands in the user-facing CLI (show, config, clear), please also modify doc/Command-Reference.md to reflect your changes as part of the same PR.

def db_connect_configdb():

def db_config_unload():
swsssdk.SonicDBConfig._sonic_db_global_config_init = False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_variable_names are intended to be used as private variables. Suggest writing setter decorator.

@smaheshm smaheshm self-requested a review July 28, 2020 16:27
sorted_table = natsorted(table)
print tabulate(sorted_table, header_stat if not sub_intf_only else header_stat_sub_intf, tablefmt="simple", stralign='right')


def __init__(self, intf_name):
def __init__(self, intf_name,display_opt, namespace=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

intf_name, display_opt

import sonic_device_util
from show.multi_npu import multi_npu_process_options
from show.multi_npu import skip_intf_display
from show.multi_npu import DISPLAY_ALL as DISPLAY_ALL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you intend to use a different name for DISPLAY_ALL

@smaheshm
Copy link
Contributor

@arlakshm Wondering are there any changes required for this PR, since there's also a PR for Multi-ASIC object. There's some common functions between Multi-ASIC and show/multi_npu.py. Are we fine with using 'npu', I remember we wanted to use 'asic'.

Comment on lines +9 to +11
BACKPLANE_INTERFACE_PREFIX = "Ethernet-BP"
DISPLAY_ALL = 'all'
DISPLAY_EXTERNAL = 'frontend'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be moved to 'constants.py' that you created.

@arlakshm
Copy link
Contributor Author

Closing this PR. The changes have been spilit into multiple PRs

@arlakshm
Copy link
Contributor Author

Closing this PR

@arlakshm arlakshm closed this Aug 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants