diff --git a/awx/main/management/commands/inventory_import.py b/awx/main/management/commands/inventory_import.py index cd1d269ef2..816f3651ef 100644 --- a/awx/main/management/commands/inventory_import.py +++ b/awx/main/management/commands/inventory_import.py @@ -169,10 +169,9 @@ class BaseLoader(object): def get_host(self, name): ''' - Return a MemHost instance from host name, creating if needed. + Return a MemHost instance from host name, creating if needed. If name + contains brackets, they will not be interpreted as a host pattern. ''' - if '[' in name or ']' in name: - raise ValueError('host ranges like %s are not supported by this importer' % name) host_name = name.split(':')[0] if self.host_filter_re and not self.host_filter_re.match(host_name): logger.debug('Filtering host %s', host_name) diff --git a/awx/main/tests/commands.py b/awx/main/tests/commands.py index e9e2dc04d5..c79637371e 100644 --- a/awx/main/tests/commands.py +++ b/awx/main/tests/commands.py @@ -775,8 +775,13 @@ class InventoryImportTest(BaseCommandMixin, BaseLiveServerTest): self.assertTrue(isinstance(result, ValueError), result) def test_executable_file(self): - # New empty inventory. + # Use existing inventory as source. old_inv = self.inventories[1] + # Modify host name to contain brackets (AC-1295). + old_host = old_inv.hosts.all()[0] + old_host.name = '[hey look some brackets]' + old_host.save() + # New empty inventory. new_inv = self.organizations[0].inventories.create(name='newb') self.assertEqual(new_inv.hosts.count(), 0) self.assertEqual(new_inv.groups.count(), 0)