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

Configure and show for platform chassis_modules #1145

Merged
merged 10 commits into from
Nov 11, 2020

Conversation

mprabhu-nokia
Copy link
Contributor

@mprabhu-nokia mprabhu-nokia commented Oct 1, 2020

sonic-utilities: Changes to support show and config command for chassis_modules

HLD: sonic-net/SONiC#646

- What I did
Introduced a show and config commands for modular chassis

$show chassis_modules
$config chassis_modules shutdown <chassis_module_name>

- How I did it
For the show command added a chassismodulesshow script
For the config command added a chassis_modules command to @platform.group

- How to verify it
Vendor will have to implement card.py for both commands to take effect.

- New command output (if the output of a command-line utility has changed)
An example vendor specific output

Out of Configuration command

sudo config chassis-modules shutdown LINE-CARD1
sudo config chassis-modules startup LINE-CARD1

Output of CONFIG_DB

admin@sonic:~$ redis-dump -d 4 -y -k "*CHASSI*"
{
  "CHASSIS_MODULE|LINE-CARD1": {
    "expireat": 1602657677.581144,
    "ttl": -0.001,
    "type": "hash",
    "value": {
      "admin_status": "down"
    }
  }
}

Output of show command

admin@sonic:~$ show chassis-modules status
         Name        Description    Slot    Oper-Status    Admin-Status
-------------  -----------------  ------  -------------  --------------
CONTROL-CARD1           cpm2-ixr      16         Online              up
 FABRIC-CARD1               SFM1      17          Empty              up
 FABRIC-CARD2               SFM2      18          Empty              up
 FABRIC-CARD3               SFM3      19          Empty              up
 FABRIC-CARD4               SFM4      20          Empty              up
 FABRIC-CARD5               SFM5      21         Online              up
 FABRIC-CARD6               SFM6      22          Empty              up
   LINE-CARD1  imm36-400g-qsfpdd       1         Online            down
   LINE-CARD2  imm36-400g-qsfpdd       2         Online              up
   LINE-CARD3          line-card       3          Empty              up
   LINE-CARD4          line-card       4          Empty              up

admin@sonic:~$ show chassis-modules status LINE-CARD1 
         Name        Description    Slot    Oper-Status    Admin-Status
-------------  -----------------  ------  -------------  --------------
  LINE-CARD1  imm36-400g-qsfpdd       1         Online            down

Output of STATE_DB

admin@sonic:~$ redis-dump -d 6 -y -k "*CHASSI*"
{
  "CHASSIS_MODULE_TABLE|CONTROL-CARD1": {
    "expireat": 1602658950.3278022,
    "ttl": -0.001,
    "type": "hash",
    "value": {
      "desc": "cpm2-ixr",
      "oper_status": "Online",
      "slot": "16"
    }
  },
  "CHASSIS_MODULE_TABLE|FABRIC-CARD1": {
    "expireat": 1602658950.32782,
    "ttl": -0.001,
    "type": "hash",
    "value": {
      "desc": "SFM1",
      "oper_status": "Empty",
      "slot": "17"
    }
  },
  "CHASSIS_MODULE_TABLE|LINE-CARD4": {
    "expireat": 1602658950.327953,
    "ttl": -0.001,
    "type": "hash",
    "value": {
      "desc": "line-card",
      "oper_status": "Empty",
      "slot": "4"
    }
  },
  "CHASSIS_TABLE|CHASSIS 1": {
    "expireat": 1602658950.3278341,
    "ttl": -0.001,
    "type": "hash",
    "value": {
      "module_num": "11"
    }
  }
}

@lgtm-com
Copy link

lgtm-com bot commented Oct 1, 2020

This pull request introduces 2 alerts when merging 7c6d23bc95d83e6b5e2a934a43984eed068ecf63 into c15cdf6 - view on LGTM.com

new alerts:

  • 1 for Unnecessary pass
  • 1 for Unused import

@lguohan
Copy link
Contributor

lguohan commented Oct 7, 2020

can you add unit test for the show and config commands?

config/main.py Outdated Show resolved Hide resolved
scripts/chassismodulesshow Outdated Show resolved Hide resolved
Copy link
Contributor

@lguohan lguohan left a comment

Choose a reason for hiding this comment

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

as comments

config/main.py Outdated Show resolved Hide resolved
@lgtm-com
Copy link

lgtm-com bot commented Oct 14, 2020

This pull request introduces 2 alerts when merging c9b1143853a9838ca967c38b26a4646787be7a00 into 3a7457c - view on LGTM.com

new alerts:

  • 1 for Unnecessary pass
  • 1 for Unused import

@lgtm-com
Copy link

lgtm-com bot commented Oct 14, 2020

This pull request introduces 2 alerts when merging 18b692acd70ebc6cc55246acd6aa82ba93d287f7 into 3a7457c - view on LGTM.com

new alerts:

  • 1 for Unnecessary pass
  • 1 for Unused import

@mprabhu-nokia
Copy link
Contributor Author

How about Fan Tray (FT) and Power Supply Units (PSU)?
They too are planned to be treated as modules - right? and planned to be part of show platform chassismodules

No plans to add FT and PSU as part of 'show chassis-modules'. Existing 'show platform fan' and 'show platform psustatus' can be used.

@mprabhu-nokia
Copy link
Contributor Author

can you add unit test for the show and config commands?

Done. UT is part of tests/chassis_modules_test.py

@lgtm-com
Copy link

lgtm-com bot commented Oct 21, 2020

This pull request introduces 1 alert when merging efe7873b3e9fac40a50cbf7caa10a30e2acb1db4 into 13bd06b - view on LGTM.com

new alerts:

  • 1 for Syntax error

@mprabhu-nokia
Copy link
Contributor Author

mprabhu-nokia commented Oct 22, 2020

UT coverage as requested

Name                                       Stmts   Miss  Cover
--------------------------------------------------------------
config/chassis_modules.py                     18      1    94%
show/chassis_modules.py                       45      4    91%

@mprabhu-nokia
Copy link
Contributor Author

This pull request introduces 2 alerts when merging c9b1143 into 3a7457c - view on LGTM.com

new alerts:

* 1 for Unnecessary pass

* 1 for Unused import

This pull request introduces 1 alert when merging efe7873 into 13bd06b - view on LGTM.com

new alerts:

* 1 for Syntax error

Fixed

show/chassis_modules.py Outdated Show resolved Hide resolved
@mprabhu-nokia
Copy link
Contributor Author

retest please

@mprabhu-nokia
Copy link
Contributor Author

retest default please

@mprabhu-nokia
Copy link
Contributor Author

retest this please

@mprabhu-nokia
Copy link
Contributor Author

retest this please

@lguohan
Copy link
Contributor

lguohan commented Nov 4, 2020

@shyam77git, can you approve?

lguohan
lguohan previously approved these changes Nov 4, 2020
shyam77git
shyam77git previously approved these changes Nov 4, 2020
lguohan
lguohan previously approved these changes Nov 5, 2020
shyam77git
shyam77git previously approved these changes Nov 5, 2020
@jleveque
Copy link
Contributor

Please fix conflicts

@mprabhu-nokia
Copy link
Contributor Author

Please fix conflicts

Fixed.

@mprabhu-nokia
Copy link
Contributor Author

@lguohan could you please approve and merge? Thanks. You already had approved this, I just resolved conflicts and updated.

@lguohan lguohan merged commit 40377d3 into sonic-net:master Nov 11, 2020
rawal01 added a commit to rawal01/sonic-mgmt that referenced this pull request Feb 3, 2021
 -adding new json file to support fixture in platform tests to skip checks for modules not present in DUT
new file:   tests/platform_tests/cli/test_show_chassis_module.py
  -adding new two new test cases for verifying show chassis-module status and show chassis-module midplane status introduced as part of
   PRs sonic-net/sonic-utilities#1145 and sonic-net/sonic-utilities#1267
tests/platform_tests/conftest.py
   -adding a fixture that skips checking for modules for DUT
yxieca pushed a commit to sonic-net/sonic-mgmt that referenced this pull request Feb 11, 2021
…sonic modular chassis (#2794)

Description of PR
Summary:

What is the motivation for this PR?
Add test cases to verify show chassis-module status and show chassis-module midplane-status for VOQ chassis. The cli commands were introduced in following PRs:

sonic-net/sonic-utilities#1145
sonic-net/sonic-utilities#1267
How did you do it?
Added new script tests/platform_tests/cli/test_show_chassis_module.py for verifying show chassis-module status and show chassis-module midplane status. Introduced test cases:
test_show_chassis_module_status: verify the output of command show chassis-module status
test_show_chassis_module_midplane_status: verify the output of command show chassis-module midplane-status
Added new script test_power_budget_info.py for verifying the redis output for power budget policy in supervisor card of chassis
Added a fixture that skips checking for modules for DUT. This new fixture is introduced to skips modules for DUT not present based on entries in inventory file, by default the test it is assumed the chassis is fully equipped and all modules are up. Example to skip certain modules add to skip modules in inventory for DUT:
DUT1
    skip_modules:
        'line-cards':
          - LINE-CARD0
          - LINE-CARD2
        'fabric-cards':
          - FABRIC-CARD3
        'psus':
          - PSU4
          - PSU5
Based on inventory file the tests will skip above modules for DUT1. For example, show chassis module will allow empty as status for LINE-CARD0 and LINE-CARD2 while all other will be expected to be ONLINE.

How did you verify/test it?
Ran sample tests against Nokia chassis with t2 topology using the skip fixture

Any platform specific information?
Supported testbed topology if it's a new test case?
t2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants