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

[show] fix "show interfaces breakout" command #1198

Merged
merged 2 commits into from
Jan 27, 2021

Conversation

dmytroxshevchuk
Copy link
Contributor

@dmytroxshevchuk dmytroxshevchuk commented Oct 28, 2020

- What I did
Fixed show interface breakout command

- How I did it

- How to verify it
From command line type show interface breakout

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

Traceback (most recent call last):
  File "/usr/local/bin/show", line 10, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1114, in invoke
    return Command.invoke(self, ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/show/interfaces/__init__.py", line 135, in breakout
    config_db = ConfigDBConnector()
NameError: global name 'ConfigDBConnector' is not defined

- New command output (if the output of a command-line utility has changed)
Related from DPB config.
e.g.

{
    "Ethernet0": {
        "index": "0,0,0,0",
        "default_brkout_mode": "1x100G[40G]",
        "child ports": "Ethernet0",
        "breakout_modes": "1x100G[40G],2x50G,4x25G[10G],2x25G(2)+1x50G(2),1x50G(2)+2x25G(2)",
        "child port speeds": "100G",
        "Current Breakout Mode": "1x100G[40G]",
        "lanes": "25,26,27,28",
        "alias_at_lanes": "Ethernet0/0,Ethernet0/1,Ethernet0/2,Ethernet0/3"
    }
}

@dmytroxshevchuk dmytroxshevchuk changed the title fix show breakout port [show] fix show breakout port Oct 30, 2020
@dmytroxshevchuk dmytroxshevchuk changed the title [show] fix show breakout port [show] fix "show interfaces breakout" command Oct 30, 2020
@dmytroxshevchuk
Copy link
Contributor Author

dmytroxshevchuk commented Oct 30, 2020

Fixed fails:

File "/usr/local/lib/python2.7/dist-packages/show/interfaces/__init__.py", line 135, in breakout
  config_db = ConfigDBConnector()
NameError: global name 'ConfigDBConnector' is not defined

File "/usr/local/lib/python2.7/dist-packages/show/interfaces/__init__.py", line 148, in breakout
  platform_path, hwsku_path = device_info.get_paths_to_platform_and_hwsku_dirs()
NameError: global name 'device_info' is not defined

File "/usr/local/lib/python2.7/dist-packages/show/interfaces/__init__.py", line 150, in breakout
  platform_file = os.path.join(platform_path, PLATFORM_JSON)
1 import json
NameError: global name 'os' is not defined

File "/usr/local/lib/python2.7/dist-packages/show/interfaces/__init__.py", line 151, in breakout
  platform_file = os.path.join(platform_path, PLATFORM_JSON)
NameError: global name 'PLATFORM_JSON' is not defined

File "/usr/local/lib/python2.7/dist-packages/show/interfaces/__init__.py", line 154, in breakout
  platform_dict = readJsonFile(platform_file)['interfaces']
NameError: global name 'readJsonFile' is not defined

File "/usr/local/lib/python2.7/dist-packages/show/interfaces/__init__.py", line 180, in breakout
  child_port_dict = get_child_ports(port_name, cur_brkout_mode, platformFile)
NameError: global name 'get_child_ports' is not defined

File "/usr/local/lib/python2.7/dist-packages/show/interfaces/__init__.py", line 181, in breakout
  child_port_dict = get_child_ports(port_name, cur_brkout_mode, platformFile)
NameError: global name 'platformFile' is not defined

File "/usr/local/lib/python2.7/dist-packages/show/interfaces/__init__.py", line 200, in breakout
  parsed = OrderedDict((k, platform_dict[k]) for k in natsorted(platform_dict.keys()))
NameError: global name 'OrderedDict' is not defined

@dmytroxshevchuk
Copy link
Contributor Author

@daall @lguohan please review

@lguohan
Copy link
Contributor

lguohan commented Nov 5, 2020

@praveen-li to review

@rbone-mitre
Copy link

Hope this fix can be pushed soon

import utilities_common.cli as clicommon
import utilities_common.multi_asic as multi_asic_util
import portchannel

PLATFORM_JSON = 'platform.json'

Choose a reason for hiding this comment

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

@samaity : Hi Sangita, as I know, we do not provide platform.json like this. We need a call to device_info.get_path_to_port_config_file(). Kindly confirm, if yes, I will mark it as a change needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@praveen-li, I saw device_info.get_path_to_port_config_file() logic, I think its better way to find PLATFORM.json, so PR was updated.
Please take a look.

Copy link
Contributor

Choose a reason for hiding this comment

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

We didn't have get_path_to_port_config_file available when the show breakout functionality was added. This is absolutely the better way to get the path. Thanks for the update!

@dmytroxshevchuk dmytroxshevchuk force-pushed the fix_breakout_show branch 2 times, most recently from c65dfe2 to 002d858 Compare November 20, 2020 10:32
@lgtm-com
Copy link

lgtm-com bot commented Nov 20, 2020

This pull request introduces 2 alerts when merging 002d8587cb30db2275cf8f595fc8190146af0276 into 05c8e33 - view on LGTM.com

new alerts:

  • 2 for Module is imported more than once

@lgtm-com
Copy link

lgtm-com bot commented Nov 20, 2020

This pull request introduces 2 alerts when merging d93dae67e644c25a3010469c52b8dcfed088455c into 05c8e33 - view on LGTM.com

new alerts:

  • 2 for Module is imported more than once

@dmytroxshevchuk dmytroxshevchuk force-pushed the fix_breakout_show branch 2 times, most recently from 1bf7554 to b324e90 Compare November 20, 2020 12:07
@dmytroxshevchuk
Copy link
Contributor Author

@praveen-li @daall @lguohan can we merge this PR? its very comfortably to see information related to DPB using show command

praveen-li
praveen-li previously approved these changes Dec 17, 2020
Copy link

@praveen-li praveen-li left a comment

Choose a reason for hiding this comment

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

Look Good to Me.
@samaity for quick double-check.

@samaity
Copy link
Contributor

samaity commented Dec 17, 2020

Look Good to Me.
@samaity for quick double-check.

Looks good to me.

Look Good to Me.
@samaity for quick double-check.

LGTM 👍

samaity
samaity previously approved these changes Dec 17, 2020
@dmytroxshevchuk
Copy link
Contributor Author

@praveen-li @samaity thanks for the review

@lguohan @daall can we merge it now?

@dmytroxshevchuk
Copy link
Contributor Author

dmytroxshevchuk commented Jan 20, 2021

@vdahiya12 @qiluo-msft @renukamanavalan please take a look and review/merge this PR. Thanks.

try:
with open(fileName) as f:
result = json.load(f)
except Exception as e:
Copy link
Contributor

@qiluo-msft qiluo-msft Jan 21, 2021

Choose a reason for hiding this comment

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

Exception [](start = 11, length = 9)

Could you catch the specific type/types? such as file exception, json format exceptions, etc? #Closed

with open(fileName) as f:
result = json.load(f)
except Exception as e:
click.echo(str(e))
Copy link
Contributor

@qiluo-msft qiluo-msft Jan 21, 2021

Choose a reason for hiding this comment

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

echo [](start = 14, length = 4)

echo to stderr #Closed

@dmytroxshevchuk
Copy link
Contributor Author

@qiluo-msft done, please check

@dmytroxshevchuk
Copy link
Contributor Author

dmytroxshevchuk commented Jan 27, 2021

@qiluo-msft please merge

@qiluo-msft qiluo-msft merged commit c7c01e4 into sonic-net:master Jan 27, 2021
yxieca pushed a commit that referenced this pull request Feb 23, 2021
**- What I did**
Fixed `show interface breakout` command

**- How I did it**

**- How to verify it**
From command line type `show interface breakout`

**- Previous command output (if the output of a command-line utility has changed)**
```
Traceback (most recent call last):
  File "/usr/local/bin/show", line 10, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1114, in invoke
    return Command.invoke(self, ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/show/interfaces/__init__.py", line 135, in breakout
    config_db = ConfigDBConnector()
NameError: global name 'ConfigDBConnector' is not defined
```
**- New command output (if the output of a command-line utility has changed)**
Related from DPB config.
e.g.
```
{
    "Ethernet0": {
        "index": "0,0,0,0",
        "default_brkout_mode": "1x100G[40G]",
        "child ports": "Ethernet0",
        "breakout_modes": "1x100G[40G],2x50G,4x25G[10G],2x25G(2)+1x50G(2),1x50G(2)+2x25G(2)",
        "child port speeds": "100G",
        "Current Breakout Mode": "1x100G[40G]",
        "lanes": "25,26,27,28",
        "alias_at_lanes": "Ethernet0/0,Ethernet0/1,Ethernet0/2,Ethernet0/3"
    }
}
```
anand-kumar-subramanian pushed a commit to anand-kumar-subramanian/sonic-utilities that referenced this pull request Mar 2, 2021
**- What I did**
Fixed `show interface breakout` command

**- How I did it**

**- How to verify it**
From command line type `show interface breakout`

**- Previous command output (if the output of a command-line utility has changed)**
```
Traceback (most recent call last):
  File "/usr/local/bin/show", line 10, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1114, in invoke
    return Command.invoke(self, ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/show/interfaces/__init__.py", line 135, in breakout
    config_db = ConfigDBConnector()
NameError: global name 'ConfigDBConnector' is not defined
```
**- New command output (if the output of a command-line utility has changed)**
Related from DPB config.
e.g.
```
{
    "Ethernet0": {
        "index": "0,0,0,0",
        "default_brkout_mode": "1x100G[40G]",
        "child ports": "Ethernet0",
        "breakout_modes": "1x100G[40G],2x50G,4x25G[10G],2x25G(2)+1x50G(2),1x50G(2)+2x25G(2)",
        "child port speeds": "100G",
        "Current Breakout Mode": "1x100G[40G]",
        "lanes": "25,26,27,28",
        "alias_at_lanes": "Ethernet0/0,Ethernet0/1,Ethernet0/2,Ethernet0/3"
    }
}
```
@qiluo-msft
Copy link
Contributor

swsssdk is deprecated largely in sonic-utilities. Could you adapt the new ConfigDBConnector as in latest code?

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.

8 participants