From 6d0da4672da337872ac41201e361db533299734c Mon Sep 17 00:00:00 2001 From: Chris Church Date: Thu, 15 May 2014 13:08:48 -0400 Subject: [PATCH] AC-1278 Reduced the level of pickiness expressed by inventory_import regarding filenames. --- awx/main/management/commands/inventory_import.py | 2 ++ awx/main/tests/commands.py | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/awx/main/management/commands/inventory_import.py b/awx/main/management/commands/inventory_import.py index 68698dc22a..45cfcac087 100644 --- a/awx/main/management/commands/inventory_import.py +++ b/awx/main/management/commands/inventory_import.py @@ -430,6 +430,8 @@ def load_inventory_source(source, all_group=None, group_filter_re=None, original_all_group = all_group if not os.path.exists(source): raise IOError('Source does not exist: %s' % source) + source = os.path.join(os.path.dirname(source) or os.getcwd(), source) + source = os.path.normpath(os.path.abspath(source)) if os.path.isdir(source): all_group = all_group or MemGroup('all', source) for filename in glob.glob(os.path.join(source, '*')): diff --git a/awx/main/tests/commands.py b/awx/main/tests/commands.py index 3a118287e2..e05ec81388 100644 --- a/awx/main/tests/commands.py +++ b/awx/main/tests/commands.py @@ -860,12 +860,14 @@ class InventoryImportTest(BaseCommandMixin, BaseLiveServerTest): new_inv = self.organizations[0].inventories.create(name='newec2') self.assertEqual(new_inv.hosts.count(), 0) self.assertEqual(new_inv.groups.count(), 0) - inv_file = os.path.join(os.path.dirname(__file__), 'data', - 'large_ec2_inventory.py') + #inv_file = os.path.join(os.path.dirname(__file__), 'data', + # 'large_ec2_inventory.py') + os.chdir(os.path.join(os.path.dirname(__file__), 'data')) + inv_file = 'large_ec2_inventory.py' result, stdout, stderr = self.run_command('inventory_import', inventory_id=new_inv.pk, source=inv_file) - self.assertEqual(result, None) + self.assertEqual(result, None, stdout+stderr) # Check that inventory is populated as expected within a reasonable # amount of time. Computed fields should also be updated. new_inv = Inventory.objects.get(pk=new_inv.pk)