mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 09:27:36 -02:30
AC-1278 Reduced the level of pickiness expressed by inventory_import regarding filenames.
This commit is contained in:
@@ -430,6 +430,8 @@ def load_inventory_source(source, all_group=None, group_filter_re=None,
|
|||||||
original_all_group = all_group
|
original_all_group = all_group
|
||||||
if not os.path.exists(source):
|
if not os.path.exists(source):
|
||||||
raise IOError('Source does not exist: %s' % 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):
|
if os.path.isdir(source):
|
||||||
all_group = all_group or MemGroup('all', source)
|
all_group = all_group or MemGroup('all', source)
|
||||||
for filename in glob.glob(os.path.join(source, '*')):
|
for filename in glob.glob(os.path.join(source, '*')):
|
||||||
|
|||||||
@@ -860,12 +860,14 @@ class InventoryImportTest(BaseCommandMixin, BaseLiveServerTest):
|
|||||||
new_inv = self.organizations[0].inventories.create(name='newec2')
|
new_inv = self.organizations[0].inventories.create(name='newec2')
|
||||||
self.assertEqual(new_inv.hosts.count(), 0)
|
self.assertEqual(new_inv.hosts.count(), 0)
|
||||||
self.assertEqual(new_inv.groups.count(), 0)
|
self.assertEqual(new_inv.groups.count(), 0)
|
||||||
inv_file = os.path.join(os.path.dirname(__file__), 'data',
|
#inv_file = os.path.join(os.path.dirname(__file__), 'data',
|
||||||
'large_ec2_inventory.py')
|
# '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',
|
result, stdout, stderr = self.run_command('inventory_import',
|
||||||
inventory_id=new_inv.pk,
|
inventory_id=new_inv.pk,
|
||||||
source=inv_file)
|
source=inv_file)
|
||||||
self.assertEqual(result, None)
|
self.assertEqual(result, None, stdout+stderr)
|
||||||
# Check that inventory is populated as expected within a reasonable
|
# Check that inventory is populated as expected within a reasonable
|
||||||
# amount of time. Computed fields should also be updated.
|
# amount of time. Computed fields should also be updated.
|
||||||
new_inv = Inventory.objects.get(pk=new_inv.pk)
|
new_inv = Inventory.objects.get(pk=new_inv.pk)
|
||||||
|
|||||||
Reference in New Issue
Block a user