From 405dd9b4107475d2a17ed8b25e37bce5fed209fa Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 5 Aug 2022 00:02:44 +0000 Subject: [PATCH] Add note for missing constraints in YANG model --- config/vlan.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/vlan.py b/config/vlan.py index 6f55b2cc58..c5adbd2f95 100644 --- a/config/vlan.py +++ b/config/vlan.py @@ -40,7 +40,7 @@ def add_vlan(db, vid): config_db = ValidatedConfigDBCOnnector(db.cfgdb, ADHOC_VALIDATION) try: - config_db.set_entry('VLAN', vlan, {'vlanid': vid}) + config_db.set_entry('VLAN', vlan, {'vlanid': str(vid)}) except ValueError: ctx.fail("Invalid VLAN ID {} (1-4094)".format(vid)) @@ -64,13 +64,13 @@ def del_vlan(db, vid): intf_table = db.cfgdb.get_table('VLAN_INTERFACE') for intf_key in intf_table: - if ((type(intf_key) is str and intf_key == 'Vlan{}'.format(vid)) or + if ((type(intf_key) is str and intf_key == 'Vlan{}'.format(vid)) or # MISSING CONSTRAINT IN YANG MODEL (type(intf_key) is tuple and intf_key[0] == 'Vlan{}'.format(vid))): ctx.fail("{} can not be removed. First remove IP addresses assigned to this VLAN".format(vlan)) keys = [ (k, v) for k, v in db.cfgdb.get_table('VLAN_MEMBER') if k == 'Vlan{}'.format(vid) ] - if keys: + if keys: # MISSING CONSTRAINT IN YANG MODEL ctx.fail("VLAN ID {} can not be removed. First remove all members assigned to this VLAN.".format(vid)) config_db = ValidatedConfigDBConnector(db.cfgdb, ADHOC_VALIDATION) @@ -78,7 +78,7 @@ def del_vlan(db, vid): config_db.set_entry('VLAN', 'Vlan{}'.format(vid), None) except JsonPatchConflict: ctx.fail("{} does not exist".format(vlan)) - except ValueError: + except ValueError: # GCU prohibits empty table, but it is otherwise allowed. So we temporarily catch GCU error and then directly set empty tabe config_db = ConfigDBConnector() config_db.connect() config_db.set_entry('VLAN', 'Vlan{}'.format(vid), None)