AC-561 Set host has_inventory_sources flag on import.

This commit is contained in:
Chris Church 2013-10-16 12:57:36 -04:00
parent 2f3409db08
commit a0c6c0e984
2 changed files with 3 additions and 0 deletions

View File

@ -570,6 +570,7 @@ class Command(NoArgsCommand):
if self.inventory_source.group:
self.inventory_source.group.hosts.add(host)
host.inventory_sources.add(self.inventory_source)
host.update_computed_fields(False, False)
# for each host in a mem group, add it to the parents to which it belongs
for (k,v) in self.all_group.group_names.iteritems():

View File

@ -1004,9 +1004,11 @@ class InventoryUpdatesTest(BaseTransactionTest):
for host in inventory.hosts.all():
source_pks = host.inventory_sources.values_list('pk', flat=True)
self.assertTrue(inventory_source.pk in source_pks)
self.assertTrue(host.has_inventory_sources)
for group in inventory.groups.all():
source_pks = group.inventory_sources.values_list('pk', flat=True)
self.assertTrue(inventory_source.pk in source_pks)
self.assertTrue(group.has_inventory_sources)
def test_update_from_ec2(self):
source_username = getattr(settings, 'TEST_AWS_ACCESS_KEY_ID', '')