Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
b1493246
Commit
b1493246
authored
Mar 03, 2014
by
Jesse Keating
Committed by
James Cammarata
Mar 10, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid range selection on empty groups
This prevents a traceback when the group is empty. Fixes #6258
parent
5341040c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
0 deletions
+11
-0
lib/ansible/inventory/__init__.py
+6
-0
test/units/TestInventory.py
+5
-0
No files found.
lib/ansible/inventory/__init__.py
View file @
b1493246
...
...
@@ -227,6 +227,12 @@ class Inventory(object):
given a pattern like foo[0:5], where foo matches hosts, return the first 6 hosts
"""
# If there are no hosts to select from, just return the
# empty set. This prevents trying to do selections on an empty set.
# issue#6258
if
not
hosts
:
return
hosts
(
loose_pattern
,
limits
)
=
self
.
_enumeration_info
(
pat
)
if
not
limits
:
return
hosts
...
...
test/units/TestInventory.py
View file @
b1493246
...
...
@@ -212,6 +212,11 @@ class TestInventory(unittest.TestCase):
inventory
.
subset
(
'greek[0-2];norse[0]'
)
self
.
assertEqual
(
sorted
(
inventory
.
list_hosts
()),
sorted
([
'zeus'
,
'hera'
,
'thor'
]))
def
test_subet_range_empty_group
(
self
):
inventory
=
self
.
simple_inventory
()
inventory
.
subset
(
'missing[0]'
)
self
.
assertEqual
(
sorted
(
inventory
.
list_hosts
()),
sorted
([]))
def
test_subset_filename
(
self
):
inventory
=
self
.
simple_inventory
()
inventory
.
subset
(
'@'
+
os
.
path
.
join
(
self
.
test_dir
,
'restrict_pattern'
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment