#NEWLINE# def _process_metering_rule_action( self , router , action ) : #NEWLINE# #INDENT# rm = self . routers . get ( router [ 'id' ] ) #NEWLINE# if ( not rm ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# ext_dev = self . get_external_device_name ( rm . router [ 'gw_port_id' ] ) #NEWLINE# if ( not ext_dev ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# with IptablesManagerTransaction ( self . iptables_manager ) : #NEWLINE# #INDENT# labels = router . get ( constants . METERING_LABEL_KEY , [ ] ) #NEWLINE# for label in labels : #NEWLINE# #INDENT# label_id = label [ 'id' ] #NEWLINE# label_chain = iptables_manager . get_chain_name ( ( ( WRAP_NAME + LABEL ) + label_id ) , wrap = False ) #NEWLINE# rules_chain = iptables_manager . get_chain_name ( ( ( WRAP_NAME + RULE ) + label_id ) , wrap = False ) #NEWLINE# rule = label . get ( 'rule' ) #NEWLINE# if rule : #NEWLINE# #INDENT# if ( action == 'create' ) : #NEWLINE# #INDENT# self . _process_metering_label_rule_add ( rm , rule , ext_dev , label_chain , rules_chain ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( action == 'delete' ) : #NEWLINE# #INDENT# self . _process_metering_label_rule_delete ( rm , rule , ext_dev , label_chain , rules_chain )