forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Show | Command Reference] Add Port breakout Show Command (sonic-net#859
) **- What I did** Implemented show interface breakout sub-command to show the port capability and the current breakout mode. Available commands are mentioned below. ``` show interfaces breakout --help show interfaces breakout current-mode ``` **- How I did it** using platform.json, hwsku.json and config-db BREAKOUT_CFG table. **- How to verify it** ``` admin@lnos-x1-a-fab01:~$ show interfaces breakout --help Usage: show interfaces breakout [OPTIONS] COMMAND [ARGS]... Show interface breakout Options: -?, -h, --help Show this message and exit. Commands: current-mode Show interface breakout current-mode ``` ``` admin@lnos-x1-a-fab01:~$ show interfaces breakout { "Ethernet0": { "index": "1,1,1,1", "default_brkout_mode": "1x100G[40G]", "child ports": "Ethernet0", "child port speed": "100G", "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]", "Current Breakout Mode": "1x100G[40G]", "lanes": "65,66,67,68", "alias_at_lanes": "Eth1/1, Eth1/2, Eth1/3, Eth1/4" }, "Ethernet4": { "index": "2,2,2,2", "default_brkout_mode": "1x100G[40G]", "child ports": "Ethernet4,Ethernet5,Ethernet6,Ethernet7", "child port speed": "25G,10G,25G,25G", "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]", "Current Breakout Mode": "4x25G", "lanes": "69,70,71,72", "alias_at_lanes": "Eth2/1, Eth2/2, Eth2/3, Eth2/4" }, "Ethernet8": { "index": "3,3,3,3", "default_brkout_mode": "1x100G[40G]", "child ports": "Ethernet8", "child port speed": "100G", "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]", "Current Breakout Mode": "1x100G[40G]", "lanes": "73,74,75,76", "alias_at_lanes": "Eth3/1, Eth3/2, Eth3/3, Eth3/4" },... continue } ``` ``` admin@lnos-x1-a-fab01:~$ show interfaces breakout current-mode Ethernet0 +-------------+-------------------------+ | Interface | Current Breakout Mode | +=============+=========================+ | Ethernet0 | 4x25G[10G] | +-------------+-------------------------+ ``` ``` admin@lnos-x1-a-fab01:~$ show interfaces breakout current-mode +-------------+-------------------------+ | Interface | Current Breakout Mode | +=============+=========================+ | Ethernet0 | 4x25G[10G] | +-------------+-------------------------+ | Ethernet4 | 4x25G[10G] | +-------------+-------------------------+ | Ethernet8 | 4x25G[10G] | +-------------+-------------------------+ ``` Signed-off-by: Sangita Maity <sangitamaity0211@gmail.com>
- Loading branch information
Showing
4 changed files
with
236 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import os | ||
import sys | ||
from click.testing import CliRunner | ||
from unittest import TestCase | ||
from swsssdk import ConfigDBConnector | ||
|
||
test_path = os.path.dirname(os.path.abspath(__file__)) | ||
modules_path = os.path.dirname(test_path) | ||
sys.path.insert(0, test_path) | ||
sys.path.insert(0, modules_path) | ||
|
||
import mock_tables.dbconnector | ||
import show.main as show | ||
|
||
# Expected output for 'show breakout current-mode' | ||
current_mode_all_output = ''+ \ | ||
"""+-------------+-------------------------+ | ||
| Interface | Current Breakout Mode | | ||
+=============+=========================+ | ||
| Ethernet0 | 4x25G[10G] | | ||
+-------------+-------------------------+ | ||
| Ethernet4 | 2x50G | | ||
+-------------+-------------------------+ | ||
| Ethernet8 | 1x100G[40G] | | ||
+-------------+-------------------------+ | ||
""" | ||
|
||
# Expected output for 'show breakout current-mode Ethernet0' | ||
current_mode_intf_output = ''+ \ | ||
"""+-------------+-------------------------+ | ||
| Interface | Current Breakout Mode | | ||
+=============+=========================+ | ||
| Ethernet0 | 4x25G[10G] | | ||
+-------------+-------------------------+ | ||
""" | ||
|
||
class TestBreakout(TestCase): | ||
@classmethod | ||
def setup_class(cls): | ||
print("SETUP") | ||
os.environ["UTILITIES_UNIT_TESTING"] = "1" | ||
|
||
def setUp(self): | ||
self.runner = CliRunner() | ||
self.config_db = ConfigDBConnector() | ||
self.config_db.connect() | ||
self.obj = {'db': self.config_db} | ||
|
||
# Test 'show interfaces breakout current-mode' | ||
def test_all_intf_current_mode(self): | ||
result = self.runner.invoke(show.cli.commands["interfaces"].commands["breakout"].commands["current-mode"], [], obj=self.obj) | ||
print(sys.stderr, result.output) | ||
assert result.output == current_mode_all_output | ||
|
||
# Test 'show interfaces breakout current-mode Ethernet0' | ||
def test_single_intf_current_mode(self): | ||
result = self.runner.invoke(show.cli.commands["interfaces"].commands["breakout"].commands["current-mode"], ["Ethernet0"], obj=self.obj) | ||
print(sys.stderr, result.output) | ||
assert result.output == current_mode_intf_output | ||
|
||
@classmethod | ||
def teardown_class(cls): | ||
print("TEARDOWN") | ||
os.environ["PATH"] = os.pathsep.join(os.environ["PATH"].split(os.pathsep)[:-1]) | ||
os.environ["UTILITIES_UNIT_TESTING"] = "0" |