Skip to content

Commit

Permalink
fix vlan
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelmsft committed Sep 15, 2022
1 parent 3566cdc commit 5bc3918
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions config/vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@ def add_vlan(db, vid):
"""Add VLAN"""

ctx = click.get_current_context()

vlan = 'Vlan{}'.format(vid)

if ADHOC_VALIDATION:
if not clicommon.is_vlanid_in_range(vid):
ctx.fail("Invalid VLAN ID {} (1-4094)".format(vid))

vlan = 'Vlan{}'.format(vid)
if vid == 1:
ctx.fail("{} is default VLAN".format(vlan)) # TODO: MISSING CONSTRAINT IN YANG MODEL

if vid == 1:
ctx.fail("{} is default VLAN".format(vlan))

if ADHOC_VALIDATION:
if clicommon.check_if_vlanid_exist(db.cfgdb, vlan): # TODO: MISSING CONSTRAINT IN YANG MODEL
ctx.fail("{} already exists".format(vlan))

Expand Down Expand Up @@ -176,12 +174,11 @@ def add_vlan_member(db, vid, port, untagged):
ctx.fail("{} is already untagged member!".format(port))

config_db = ValidatedConfigDBConnector(db.cfgdb, ADHOC_VALIDATION)

try:
config_db.set_entry('VLAN_MEMBER', (vlan, port), {'tagging_mode': "untagged" if untagged else "tagged" })
except ValueError:
ctx.fail("Invalid VLAN ID {} (1-4094)".format(vid))
except JsonPatchConflict:
ctx.fail("{} does not exist".format(vlan))
ctx.fail("{} invalid or does not exist, or {} invalid or does not exist".format(vlan, port))

@vlan_member.command('del')
@click.argument('vid', metavar='<vid>', required=True, type=int)
Expand Down Expand Up @@ -215,8 +212,6 @@ def del_vlan_member(db, vid, port):
config_db = ValidatedConfigDBConnector(db.cfgdb, ADHOC_VALIDATION)
try:
config_db.set_entry('VLAN_MEMBER', (vlan, port), None)
except ValueError:
ctx.fail("Invalid VLAN ID {} (1-4094)".format(vid))
except JsonPatchConflict:
ctx.fail("{} does not exist".format(vlan))
ctx.fail("{} invalid or does not exist, or {} is not a member of {}".format(vlan, port, vlan))

0 comments on commit 5bc3918

Please sign in to comment.