def __delete_counter(): if _args['table_id'] == None or _args['counter_id'] == None: print( 'Missing attributes-provide table-id and counter-id as arguments') sys.exit(1) nas_acl.delete_counter(int(_args['table_id']), int(_args['counter_id'])) sys.exit(0)
def acl_ut_counter_delete(table_id, counter_id): global total, passed total.append(sys._getframe().f_code.co_name) try: nas_acl.delete_counter(table_id, counter_id) print "Counter ", str(counter_id), " deleted sucessfully" passed.append(sys._getframe().f_code.co_name) except RuntimeError: print "Failed to delete counter" return
eid_ip = nas_acl.create_entry(table_id=tid, prio=511, filter_map={ 'DST_IP': '23.0.0.1', 'DSCP': { 'data': 0x08, 'mask': 0x38 } }, action_map={ 'SET_TC': 4, 'SET_COUNTER': counter_ip }) # Print both entries in ACL table nas_acl.print_entry(tid) raw_input("Press Enter to clean up the ACL entries and table ...") # Print the ACL stats object nas_acl.print_stats(tid, counter_ip) nas_acl.print_stats(tid, counter_mac) # Clean up nas_acl.delete_entry(tid, eid_ip) nas_acl.delete_entry(tid, eid_mac) nas_acl.delete_counter(tid, counter_ip) nas_acl.delete_counter(tid, counter_mac) nas_acl.delete_table(tid) print "Clean up Successful"
table_id=tid, entry_id=eid, filter_map=filters) nas_acl.print_entry(tid, eid) # Completely overwrite the action list with another set of actions print "Replaced action list - new action - Mirror egress" actions = { 'MIRROR_EGRESS': {'index': mirr_id_2, 'data': mirr_opq_2} # Attaching external obj # to ACL # action } nas_acl.replace_entry_action_list( table_id=tid, entry_id=eid, action_map=actions) nas_acl.print_entry(tid, eid) except RuntimeError as r: print r # Clean up nas_acl.delete_entry(tid, eid) nas_acl.delete_counter(tid, counter_id) a_utl.mirror_delete(mirr_id_1) a_utl.mirror_delete(mirr_id_2) nas_acl.delete_table(tid) print "Clean up Successful"
entry_id=eid, filter_map=filters) nas_acl.print_entry(tid, eid) # Completely overwrite the action list with another set of actions print "Replaced action list - new action - Mirror egress" actions = { 'MIRROR_EGRESS': { 'index': mirr_id_2, 'data': mirr_opq_2 } # Attaching external obj # to ACL # action } nas_acl.replace_entry_action_list(table_id=tid, entry_id=eid, action_map=actions) nas_acl.print_entry(tid, eid) except RuntimeError as r: print r # Clean up nas_acl.delete_entry(tid, eid) nas_acl.delete_counter(tid, counter_id) a_utl.mirror_delete(mirr_id_1) a_utl.mirror_delete(mirr_id_2) nas_acl.delete_table(tid) print "Clean up Successful"
# # ACL Entry to set traffic class for packets destined to IP 23.0.0.1 # with a DSCP range 8-15 # # ACL counter to count number of dropped packets counter_ip = nas_acl.create_counter(table_id=tid, types=['PACKET']) # CPS Create the ACL entry eid_ip = nas_acl.create_entry(table_id=tid, prio=511, filter_map={'DST_IP': '23.0.0.1', 'DSCP': {'data':0x08, 'mask':0x38}}, action_map={'SET_TC': 4, 'SET_COUNTER': counter_ip}) # Print both entries in ACL table nas_acl.print_entry(tid) raw_input("Press Enter to clean up the ACL entries and table ...") # Print the ACL stats object nas_acl.print_stats(tid, counter_ip) nas_acl.print_stats(tid, counter_mac) # Clean up nas_acl.delete_entry(tid, eid_ip) nas_acl.delete_entry(tid, eid_mac) nas_acl.delete_counter(tid, counter_ip) nas_acl.delete_counter(tid, counter_mac) nas_acl.delete_table(tid) print "Clean up Successful"