changeset 34:29b0aa997665

check old instance before db update
author Radomir Dopieralski <sheep-devel@sheep.art.pl>
date Wed, 13 Feb 2013 14:59:15 +0100
parents 080c74b95136
children 2bbc58bc81e7
files srxproxy.py
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/srxproxy.py	Wed Feb 13 13:56:34 2013 +0100
+++ b/srxproxy.py	Wed Feb 13 14:59:15 2013 +0100
@@ -160,12 +160,6 @@
         # Write the changes to the database
         LOG.info("Updating database for %s", fixed_ip)
         try:
-            nm.db.floating_ip_fixed_ip_associate(
-                context,
-                floating_ip,
-                fixed_ip,
-                host,
-            )
             instance_ids = {instance_id}
             floating_ip_ref = nm.db.floating_ip_get_by_address(
                 context,
@@ -176,6 +170,12 @@
                 old_fixed_ip_ref = nm.db.fixed_ip_get(context, fixed_ip_id)
                 if old_fixed_ip_ref and old_fixed_ip_ref['instance_id']:
                     instance_ids.add(old_fixed_ip_ref['instance_id'])
+            nm.db.floating_ip_fixed_ip_associate(
+                context,
+                floating_ip,
+                fixed_ip,
+                host,
+            )
             for id_ in instance_ids:
                 instance = nm.db.instance_get(context, id_)
                 nm.get_instance_nw_info(