From c61c8b2b45a211a748397ee609e9de1e0cde0a3f Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Thu, 31 Mar 2016 09:48:14 -0400 Subject: [PATCH] Revert accidental active_flag removal changes in south_migrations Fixes #1349 --- awx/main/south_migrations/0018_v14_changes.py | 10 +++++----- awx/main/south_migrations/0044_v1411_changes.py | 2 +- awx/main/south_migrations/0070_v221_changes.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/awx/main/south_migrations/0018_v14_changes.py b/awx/main/south_migrations/0018_v14_changes.py index 980c4293d6..ea4fde18ab 100644 --- a/awx/main/south_migrations/0018_v14_changes.py +++ b/awx/main/south_migrations/0018_v14_changes.py @@ -13,7 +13,7 @@ class Migration(DataMigration): # and orm['appname.ModelName'] for models in other applications. # Refresh has_active_failures for all hosts. - for host in orm.Host.objects: + for host in orm.Host.objects.filter(active=True): has_active_failures = bool(host.last_job_host_summary and host.last_job_host_summary.job.active and host.last_job_host_summary.failed) @@ -30,9 +30,9 @@ class Migration(DataMigration): for subgroup in group.children.exclude(pk__in=except_group_pks): qs = qs | get_all_hosts_for_group(subgroup, except_group_pks) return qs - for group in orm.Group.objects: + for group in orm.Group.objects.filter(active=True): all_hosts = get_all_hosts_for_group(group) - failed_hosts = all_hosts.filter( + failed_hosts = all_hosts.filter(active=True, last_job_host_summary__job__active=True, last_job_host_summary__failed=True) hosts_with_active_failures = failed_hosts.count() @@ -49,8 +49,8 @@ class Migration(DataMigration): # Now update has_active_failures and hosts_with_active_failures for all # inventories. - for inventory in orm.Inventory.objects: - failed_hosts = inventory.hosts.filter( has_active_failures=True) + for inventory in orm.Inventory.objects.filter(active=True): + failed_hosts = inventory.hosts.filter(active=True, has_active_failures=True) hosts_with_active_failures = failed_hosts.count() has_active_failures = bool(hosts_with_active_failures) changed = False diff --git a/awx/main/south_migrations/0044_v1411_changes.py b/awx/main/south_migrations/0044_v1411_changes.py index c58dc8d155..137f4cb220 100644 --- a/awx/main/south_migrations/0044_v1411_changes.py +++ b/awx/main/south_migrations/0044_v1411_changes.py @@ -8,7 +8,7 @@ from django.db import models class Migration(DataMigration): def forwards(self, orm): - for iu in orm.InventoryUpdate.objects: + for iu in orm.InventoryUpdate.objects.filter(active=True): if iu.inventory_source is None or iu.inventory_source.group is None or iu.inventory_source.inventory is None: continue iu.name = "%s (%s)" % (iu.inventory_source.group.name, iu.inventory_source.inventory.name) diff --git a/awx/main/south_migrations/0070_v221_changes.py b/awx/main/south_migrations/0070_v221_changes.py index c27edf8e9c..0bc36f27ac 100644 --- a/awx/main/south_migrations/0070_v221_changes.py +++ b/awx/main/south_migrations/0070_v221_changes.py @@ -12,7 +12,7 @@ from django.conf import settings class Migration(DataMigration): def forwards(self, orm): - for j in orm.UnifiedJob.objects: + for j in orm.UnifiedJob.objects.filter(active=True): cur = connection.cursor() stdout_filename = os.path.join(settings.JOBOUTPUT_ROOT, "%d-%s.out" % (j.pk, str(uuid.uuid1()))) fd = open(stdout_filename, 'w')