From 0fe96d39d6f0c859215724012b097f9547992a98 Mon Sep 17 00:00:00 2001 From: iris Date: Wed, 15 Dec 2021 17:46:38 +0800 Subject: [PATCH] add neigh-suppress CLI command --- config/main.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/config/main.py b/config/main.py index f914e64653..723153ec9b 100644 --- a/config/main.py +++ b/config/main.py @@ -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='', required=True, type=int) +@click.argument('state', metavar='', 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 ...') #