@@ -78,6 +78,7 @@ class AclLoader(object):
78
78
def __init__ (self ):
79
79
self .yang_acl = None
80
80
self .requested_session = None
81
+ self .current_table = None
81
82
self .tables_db_info = {}
82
83
self .rules_db_info = {}
83
84
self .rules_info = {}
@@ -146,10 +147,19 @@ def get_session_name(self):
146
147
147
148
return None
148
149
150
+ def set_table_name (self , table_name ):
151
+ """
152
+ Set table name to restrict the table to be modified
153
+ :param table_name: Table name
154
+ :return:
155
+ """
156
+ self .current_table = table_name
157
+
149
158
def set_session_name (self , session_name ):
150
159
"""
151
- Set session name to se used in ACL rule action.
160
+ Set session name to be used in ACL rule action
152
161
:param session_name: Mirror session name
162
+ :return:
153
163
"""
154
164
if session_name not in self .get_sessions_db_info ():
155
165
raise AclLoaderException ("Session %s does not exist" % session_name )
@@ -356,6 +366,9 @@ def convert_rules(self):
356
366
warning ("%s table does not exist" % (table_name ))
357
367
continue
358
368
369
+ if self .current_table is not None and self .current_table != table_name
370
+ continue
371
+
359
372
for acl_entry_name in acl_set .acl_entries .acl_entry :
360
373
acl_entry = acl_set .acl_entries .acl_entry [acl_entry_name ]
361
374
try :
@@ -370,11 +383,14 @@ def convert_rules(self):
370
383
def full_update (self ):
371
384
"""
372
385
Perform full update of ACL rules configuration. All existing rules
373
- will be removed. New rules loaded from file will be installed.
386
+ will be removed. New rules loaded from file will be installed. If
387
+ the current_table is not empty, only rules within that table will
388
+ be removed and new rules in that table will be installed.
374
389
:return:
375
390
"""
376
391
for key in self .rules_db_info .keys ():
377
- self .configdb .mod_entry (self .ACL_RULE , key , None )
392
+ if self .current_table is None or self .current_table == key [0 ]:
393
+ self .configdb .mod_entry (self .ACL_RULE , key , None )
378
394
379
395
self .configdb .mod_config ({self .ACL_RULE : self .rules_info })
380
396
@@ -593,15 +609,20 @@ def update(ctx):
593
609
594
610
@update .command ()
595
611
@click .argument ('filename' , type = click .Path (exists = True ))
612
+ @click .option ('--table_name' , type = click .STRING , required = False )
596
613
@click .option ('--session_name' , type = click .STRING , required = False )
597
614
@click .option ('--max_priority' , type = click .INT , required = False )
598
615
@click .pass_context
599
- def full (ctx , filename , session_name , max_priority ):
616
+ def full (ctx , filename , table_name , session_name , max_priority ):
600
617
"""
601
618
Full update of ACL rules configuration.
619
+ If a table_name is provided, the operation will be restricted in the specified table.
602
620
"""
603
621
acl_loader = ctx .obj ["acl_loader" ]
604
622
623
+ if table_name :
624
+ acl_loader .set_table_name (table_name )
625
+
605
626
if session_name :
606
627
acl_loader .set_session_name (session_name )
607
628
0 commit comments