def ensure_floating_forward(floating_ip, fixed_ip, device, network):
 regex = ('.*\\s+%s(/32|\\s+|$)' % floating_ip)
 num_rules = iptables_manager.ipv4['nat'].remove_rules_regex(regex)
 if num_rules:
  msg = _('Removed %(num)d duplicate rules for floating ip %(float)s')
  LOG.warn((msg % {'num': num_rules, 'float': floating_ip}))
 for (chain, rule) in floating_forward_rules(floating_ip, fixed_ip, device):
  iptables_manager.ipv4['nat'].add_rule(chain, rule)
 iptables_manager.apply()
 if (device != network['bridge']):
  ensure_ebtables_rules(*floating_ebtables_rules(fixed_ip, network))

def ensure_floating_forward ( floating_ip , fixed_ip , device , network ) : regex = ( '.*\\s+%s(/32|\\s+|$)' % floating_ip ) num_rules = iptables_manager . ipv4 [ 'nat' ] . remove_rules_regex ( regex ) if num_rules : msg = _ ( 'Removed %(num)d duplicate rules for floating ip %(float)s' ) LOG . warn ( ( msg % { 'num' : num_rules , 'float' : floating_ip } ) ) for ( chain , rule ) in floating_forward_rules ( floating_ip , fixed_ip , device ) : iptables_manager . ipv4 [ 'nat' ] . add_rule ( chain , rule ) iptables_manager . apply ( ) if ( device != network [ 'bridge' ] ) : ensure_ebtables_rules ( * floating_ebtables_rules ( fixed_ip , network ) )
ensure floating ip forwarding rule .