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
eb80c8fb
Commit
eb80c8fb
authored
Mar 03, 2014
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6260 from j2sol/6258
Avoid range selection on empty groups
parents
b5cc6332
0c2c37a4
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 @
eb80c8fb
...
@@ -227,6 +227,12 @@ class Inventory(object):
...
@@ -227,6 +227,12 @@ class Inventory(object):
given a pattern like foo[0:5], where foo matches hosts, return the first 6 hosts
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
)
(
loose_pattern
,
limits
)
=
self
.
_enumeration_info
(
pat
)
if
not
limits
:
if
not
limits
:
return
hosts
return
hosts
...
...
test/units/TestInventory.py
View file @
eb80c8fb
...
@@ -212,6 +212,11 @@ class TestInventory(unittest.TestCase):
...
@@ -212,6 +212,11 @@ class TestInventory(unittest.TestCase):
inventory
.
subset
(
'greek[0-2];norse[0]'
)
inventory
.
subset
(
'greek[0-2];norse[0]'
)
self
.
assertEqual
(
sorted
(
inventory
.
list_hosts
()),
sorted
([
'zeus'
,
'hera'
,
'thor'
]))
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
):
def
test_subset_filename
(
self
):
inventory
=
self
.
simple_inventory
()
inventory
=
self
.
simple_inventory
()
inventory
.
subset
(
'@'
+
os
.
path
.
join
(
self
.
test_dir
,
'restrict_pattern'
))
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