From 0fa5ba606bc5731fb8b8d97223fe5921bc4639af Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Mon, 15 Jul 2013 11:40:53 -0400 Subject: [PATCH] DB lookups should specify inventory to allow for non-unique group names. --- awx/main/management/commands/inventory_import.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/awx/main/management/commands/inventory_import.py b/awx/main/management/commands/inventory_import.py index f8bfcedb4d..5850dad5e5 100644 --- a/awx/main/management/commands/inventory_import.py +++ b/awx/main/management/commands/inventory_import.py @@ -512,8 +512,8 @@ class Command(BaseCommand): # this will be slightly inaccurate, but attribute to first superuser. user = User.objects.filter(is_superuser=True)[0] - db_groups = Group.objects.all() - db_hosts = Host.objects.all() + db_groups = Group.objects.filter(inventory=inventory) + db_hosts = Host.objects.filter(inventory=inventory) db_group_names = [ g.name for g in db_groups ] db_host_names = [ h.name for h in db_hosts ] @@ -539,7 +539,7 @@ class Command(BaseCommand): # FIXME: where it should not exist if overwrite: LOGGER.info("purging host group memberships") - db_groups = Group.objects.all() + db_groups = Group.objects.filter(inventory=inventory) for g in db_groups: g.hosts.clear() g.save() @@ -557,7 +557,7 @@ class Command(BaseCommand): db_group.save() def variable_mangler(model, mem_hash, overwrite, overwrite_vars): - db_collection = model.objects.all() + db_collection = model.objects.filter(inventory=inventory) for obj in db_collection: if obj.name in mem_hash: mem_group = mem_hash[obj.name]