mirror of
https://github.com/ansible/awx.git
synced 2026-03-26 13:25:02 -02:30
DB lookups should specify inventory to allow for non-unique group names.
This commit is contained in:
@@ -512,8 +512,8 @@ class Command(BaseCommand):
|
|||||||
# this will be slightly inaccurate, but attribute to first superuser.
|
# this will be slightly inaccurate, but attribute to first superuser.
|
||||||
user = User.objects.filter(is_superuser=True)[0]
|
user = User.objects.filter(is_superuser=True)[0]
|
||||||
|
|
||||||
db_groups = Group.objects.all()
|
db_groups = Group.objects.filter(inventory=inventory)
|
||||||
db_hosts = Host.objects.all()
|
db_hosts = Host.objects.filter(inventory=inventory)
|
||||||
db_group_names = [ g.name for g in db_groups ]
|
db_group_names = [ g.name for g in db_groups ]
|
||||||
db_host_names = [ h.name for h in db_hosts ]
|
db_host_names = [ h.name for h in db_hosts ]
|
||||||
|
|
||||||
@@ -539,7 +539,7 @@ class Command(BaseCommand):
|
|||||||
# FIXME: where it should not exist
|
# FIXME: where it should not exist
|
||||||
if overwrite:
|
if overwrite:
|
||||||
LOGGER.info("purging host group memberships")
|
LOGGER.info("purging host group memberships")
|
||||||
db_groups = Group.objects.all()
|
db_groups = Group.objects.filter(inventory=inventory)
|
||||||
for g in db_groups:
|
for g in db_groups:
|
||||||
g.hosts.clear()
|
g.hosts.clear()
|
||||||
g.save()
|
g.save()
|
||||||
@@ -557,7 +557,7 @@ class Command(BaseCommand):
|
|||||||
db_group.save()
|
db_group.save()
|
||||||
|
|
||||||
def variable_mangler(model, mem_hash, overwrite, overwrite_vars):
|
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:
|
for obj in db_collection:
|
||||||
if obj.name in mem_hash:
|
if obj.name in mem_hash:
|
||||||
mem_group = mem_hash[obj.name]
|
mem_group = mem_hash[obj.name]
|
||||||
|
|||||||
Reference in New Issue
Block a user