Skip to content

[teamshow]: Fixed teamshow output not displaying the custom portchann… #436

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

SONIC_CFGGEN_PATH = '/usr/local/bin/sonic-cfggen'
SYSLOG_IDENTIFIER = "config"

CFG_PORTCHANNEL_PREFIX = "PortChannel"
CFG_PORTCHANNEL_PREFIX_LEN = 11
CFG_PORTCHANNEL_NO="xxxx"
# ========================== Syslog wrappers ==========================

def log_debug(msg):
Expand Down Expand Up @@ -65,6 +67,10 @@ def run_command(command, display_cmd=False, ignore_error=False):
if proc.returncode != 0 and not ignore_error:
sys.exit(proc.returncode)

def is_portchannel_name_valid(portchannel_name):
if portchannel_name[:CFG_PORTCHANNEL_PREFIX_LEN] != CFG_PORTCHANNEL_PREFIX:
return False
return True

def interface_alias_to_name(interface_alias):
"""Return default interface name if alias name is given as argument
Expand Down Expand Up @@ -435,6 +441,9 @@ def portchannel(ctx):
@click.pass_context
def add_portchannel(ctx, portchannel_name, min_links, fallback):
"""Add port channel"""
if is_portchannel_name_valid(portchannel_name) != True:
ctx.fail("{} is invalid!, name should have prefix '{}' and suffix '{}'"
.format(portchannel_name, CFG_PORTCHANNEL_PREFIX, CFG_PORTCHANNEL_NO))
db = ctx.obj['db']
fvs = {'admin_status': 'up',
'mtu': '9100'}
Expand Down