Skip to content

Commit

Permalink
add neigh-suppress CLI command
Browse files Browse the repository at this point in the history
  • Loading branch information
iris00522 committed Dec 15, 2021
1 parent 96143ee commit 0fe96d3
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4506,6 +4506,38 @@ def del_vrf_vni_map(ctx, vrfname):

config_db.mod_entry('VRF', vrfname, {"vni": 0})


#
# 'neigh-suppress' group ('config neigh-suppress vlan...')
#

@config.group(cls=clicommon.AbbreviationGroup, name='neigh-suppress')
@click.pass_context
def neigh_suppress(ctx):
""" Neighbour Suppress VLAN-related configuration """
config_db = ConfigDBConnector()
config_db.connect()
ctx.obj = {'db': config_db}

@neigh_suppress.command('vlan')
@click.argument('vid', metavar='<vid>', required=True, type=int)
@click.argument('state', metavar='<on|off>', required=True, type=click.Choice(["on", "off"]))
@click.pass_context
def set_neigh_suppress(ctx, vid, state):
db = ctx.obj['db']
if vid<1 or vid>4094:
ctx.fail(" Invalid Vlan Id , Valid Range : 1 to 4094 ")
vlan = 'Vlan{}'.format(vid)
if len(db.get_entry('VLAN', vlan)) == 0:
click.echo("{} doesn't exist".format(vlan))
return
if state == "on":
fvs = {'suppress': "on"}
db.set_entry('SUPPRESS_VLAN_NEIGH', vlan, fvs)
else:
db.set_entry('SUPPRESS_VLAN_NEIGH', vlan, None)


#
# 'route' group ('config route ...')
#
Expand Down

0 comments on commit 0fe96d3

Please sign in to comment.