-
Notifications
You must be signed in to change notification settings - Fork 817
show interface portchannel support for Multi ASIC #1005
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
Changes from all commits
e71321f
194b619
b77f2ac
a942c4b
9b8f365
0eaaa72
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,13 @@ | ||
| import click | ||
|
|
||
| from tabulate import tabulate | ||
| from natsort import natsorted | ||
| import os | ||
| import sys | ||
|
|
||
| import click | ||
| import utilities_common.cli as clicommon | ||
| from natsort import natsorted | ||
| from tabulate import tabulate | ||
| import utilities_common.multi_asic as multi_asic_util | ||
| from utilities_common.constants import PORT_CHANNEL_OBJ | ||
|
|
||
| """ | ||
| Script to show LAG and LAG member status in a summary view | ||
|
|
@@ -24,7 +28,6 @@ | |
|
|
||
| """ | ||
|
|
||
|
|
||
| PORT_CHANNEL_APPL_TABLE_PREFIX = "LAG_TABLE:" | ||
| PORT_CHANNEL_CFG_TABLE_PREFIX = "PORTCHANNEL|" | ||
| PORT_CHANNEL_STATE_TABLE_PREFIX = "LAG_TABLE|" | ||
|
|
@@ -35,21 +38,33 @@ | |
| PORT_CHANNEL_MEMBER_STATUS_FIELD = "status" | ||
|
|
||
| class Teamshow(object): | ||
| def __init__(self, db): | ||
| def __init__(self, namespace_option, display_option): | ||
| self.teams = [] | ||
| self.teamsraw = {} | ||
| self.summary = {} | ||
| self.db = db.db | ||
| self.db2 = db | ||
| self.err = None | ||
| self.db = None | ||
| self.multi_asic = multi_asic_util.MultiAsic(display_option, namespace_option) | ||
|
|
||
| @multi_asic_util.run_on_multi_asic | ||
| def get_teams_info(self): | ||
| self.get_portchannel_names() | ||
| self.get_teamdctl() | ||
| self.get_teamshow_result() | ||
|
|
||
| def get_portchannel_names(self): | ||
| """ | ||
| Get the portchannel names from database. | ||
| """ | ||
| self.teams = [] | ||
| team_keys = self.db.keys(self.db.CONFIG_DB, PORT_CHANNEL_CFG_TABLE_PREFIX+"*") | ||
| if team_keys is None: | ||
| return | ||
| self.teams = [key[len(PORT_CHANNEL_CFG_TABLE_PREFIX):] for key in team_keys] | ||
| for key in team_keys: | ||
| team_name = key[len(PORT_CHANNEL_CFG_TABLE_PREFIX):] | ||
| if self.multi_asic.skip_display(PORT_CHANNEL_OBJ, team_name) is True: | ||
| continue | ||
| self.teams.append(team_name) | ||
|
|
||
| def get_portchannel_status(self, port_channel_name): | ||
| """ | ||
|
|
@@ -120,7 +135,7 @@ def get_teamshow_result(self): | |
| pstate = self.db.get_all(self.db.STATE_DB, PORT_CHANNEL_MEMBER_STATE_TABLE_PREFIX+team+'|'+port) | ||
| selected = True if pstate['runner.aggregator.selected'] == "true" else False | ||
| if clicommon.get_interface_naming_mode() == "alias": | ||
| alias = clicommon.InterfaceAliasConverter(self.db2).name_to_alias(port) | ||
| alias = clicommon.InterfaceAliasConverter().name_to_alias(port) | ||
| info["ports"] += alias + "(" | ||
| else: | ||
| info["ports"] += port + "(" | ||
|
|
@@ -146,12 +161,10 @@ def display_summary(self): | |
|
|
||
| # 'portchannel' subcommand ("show interfaces portchannel") | ||
| @click.command() | ||
| @multi_asic_util.multi_asic_click_options | ||
| @click.option('--verbose', is_flag=True, help="Enable verbose output") | ||
| @clicommon.pass_db | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this removed? this can break the unit test.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With multi asic support, Teamshow will connect to DBs in each namespace or default namespace. No need to pass the db. Unit test will work with the changes done to support multi asic CLIs |
||
| def portchannel(db, verbose): | ||
| def portchannel(namespace, display, verbose): | ||
| """Show PortChannel information""" | ||
| team = Teamshow(db) | ||
| team.get_portchannel_names() | ||
| team.get_teamdctl() | ||
| team.get_teamshow_result() | ||
| team.display_summary() | ||
| team = Teamshow(namespace, display) | ||
| team.get_teams_info() | ||
| team.display_summary() | ||
Uh oh!
There was an error while loading. Please reload this page.