summaryrefslogtreecommitdiffstats
path: root/nova/db
diff options
context:
space:
mode:
authorRick Harris <rconradharris@gmail.com>2013-02-26 00:47:49 +0000
committerRick Harris <rconradharris@gmail.com>2013-02-26 00:49:59 +0000
commite62d0cb93a4ac788f208982d5d24ced4bc7c4c8f (patch)
tree4aa6e46d159d14a384dbedcbbeccf415ea0601fe /nova/db
parentd9bbcfb76646cb77d9dfc867f057917b3e059a4f (diff)
Migration 147: Prevent duplicate aggregate_hosts
If an aggregate_host record is already present, then the `upgrade` shouldn't attempt to add it again. Change-Id: Ib7ab10fa7c166ccaa3df6a96eb08c7ebcd0af38c
Diffstat (limited to 'nova/db')
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/147_no_service_zones.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/147_no_service_zones.py b/nova/db/sqlalchemy/migrate_repo/versions/147_no_service_zones.py
index d93cd1ead..5c079584d 100644
--- a/nova/db/sqlalchemy/migrate_repo/versions/147_no_service_zones.py
+++ b/nova/db/sqlalchemy/migrate_repo/versions/147_no_service_zones.py
@@ -58,8 +58,12 @@ def upgrade(migrate_engine):
})
# add host to zone
agg_hosts = Table('aggregate_hosts', meta, autoload=True)
- row = agg_hosts.insert()
- row.execute({'host': rec['host'], 'aggregate_id': agg_id})
+ num_hosts = agg_hosts.count().where(
+ agg_hosts.c.host == rec['host']).where(
+ agg_hosts.c.aggregate_id == agg_id).execute().scalar()
+ if num_hosts == 0:
+ agg_hosts.insert().execute({'host': rec['host'],
+ 'aggregate_id': agg_id})
services.drop_column('availability_zone')