Skip to content

Commit edabaa4

Browse files
author
David Noble
committed
Resolves test_index.IndexTest.test_disable_enable failure
1 parent 594929e commit edabaa4

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

splunklib/client.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -516,16 +516,21 @@ def restart_required(self):
516516
"""Indicates whether splunkd is in a state that requires a restart.
517517
518518
:return: A ``boolean`` that indicates whether a restart is required.
519+
519520
"""
520521
response = self.get("messages").body.read()
521522
messages = data.load(response)['feed']
522523
if 'entry' not in messages:
523-
titles = []
524-
elif isinstance(messages['entry'], dict):
525-
titles = [messages['entry']['title']]
524+
result = False
526525
else:
527-
titles = [x['title'] for x in messages['entry']]
528-
return 'restart_required' in titles
526+
if isinstance(messages['entry'], dict):
527+
titles = [messages['entry']['title']]
528+
else:
529+
titles = [x['title'] for x in messages['entry']]
530+
for title in titles:
531+
print title
532+
result = 'restart_required' in titles
533+
return result
529534

530535
@property
531536
def roles(self):
@@ -976,6 +981,8 @@ def content(self):
976981
def disable(self):
977982
"""Disables the entity at this endpoint."""
978983
self.post("disable")
984+
if self.service._splunk_version[0] < 6:
985+
self.restartSplunk()
979986
return self
980987

981988
def enable(self):
@@ -1687,6 +1694,7 @@ def delete(self, name):
16871694
raise IllegalOperationException("Deleting indexes via the REST API is "
16881695
"not supported before Splunk version 5.")
16891696

1697+
16901698
class Index(Entity):
16911699
"""This class represents an index and provides different operations, such as
16921700
cleaning the index, writing to the index, and so forth."""
@@ -1860,6 +1868,7 @@ def upload(self, filename, **kwargs):
18601868
self.service.post(path, name=filename, **kwargs)
18611869
return self
18621870

1871+
18631872
class Input(Entity):
18641873
"""This class represents a Splunk input. This class is the base for all
18651874
typed input classes and is also used when the client does not recognize an
@@ -2372,7 +2381,6 @@ def __init__(self, service, sid, **kwargs):
23722381
path = PATH_JOBS + sid
23732382
Entity.__init__(self, service, path, skip_refresh=True, **kwargs)
23742383
self.sid = sid
2375-
self._is_ready = False
23762384

23772385
# The Job entry record is returned at the root of the response
23782386
def _load_atom_entry(self, response):

tests/test_index.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ def test_default(self):
6666

6767
def test_disable_enable(self):
6868
self.index.disable()
69-
self.restartSplunk()
7069
self.index.refresh()
7170
self.assertEqual(self.index['disabled'], '1')
7271
self.index.enable()

0 commit comments

Comments
 (0)