Mercurial > srxproxy
changeset 22:b61b4f736cfe
Make the items in one ruleset unique
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Tue, 12 Feb 2013 16:03:57 +0100 |
| parents | a6848dc21bcd |
| children | 50bbb36cfbec |
| files | srxproxy.py |
| diffstat | 1 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/srxproxy.py Tue Feb 12 15:37:27 2013 +0100 +++ b/srxproxy.py Tue Feb 12 16:03:57 2013 +0100 @@ -50,21 +50,29 @@ def ensure_floating_forwards(ips): + rules = { + floating_ip: (context, fixed_ip, host, instance_id) + for context, floating_ip, fixed_ip, host, instance_id in ips + } rules_xml = [ RULE_XML.format( name=floating_ip.replace('.', '_'), destination=floating_ip, prefix=fixed_ip, ) - for context, floating_ip, fixed_ip, host, instance_id in ips + for floating_ip, (context, fixed_ip, host, instance_id) in rules.iteritems() ] apply_ruleset(rules_xml, default_operation="merge") def remove_floating_forwards(ips): + rules = { + address: (context, instance_id) + for context, address, instance_id in ips + } rules_xml = [ DELETE_XML.format(name=address.replace('.', '_')) - for context, address, instance_id in ips + for address, (context, instance_id) in rules.iteritems() ] apply_ruleset(rules_xml, default_operation="none")
