From 3a5544801a078a4768978e50b94356766869d517 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Fri, 9 May 2014 10:16:44 -0400 Subject: [PATCH] Make sure we disassociate inventory source from the host as part of the dereferencing operation --- awx/main/models/inventory.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/awx/main/models/inventory.py b/awx/main/models/inventory.py index 431d006dcf..b853537a90 100644 --- a/awx/main/models/inventory.py +++ b/awx/main/models/inventory.py @@ -374,7 +374,10 @@ class Group(CommonModelNameNotUnique): continue for host in group.hosts.all(): host.groups.remove(group) - # Remove inventory source + host_inv_sources = host.inventory_sources + for inv_source in group.inventory_sources: + if inv_source in host_inv_sources: + host_inv_sources.remove(inv_source) if host.groups.count() < 1: marked_hosts.append(host) for childgroup in group.children.all():