Skip to content

Commit 0026ebe

Browse files
author
Frederick Ross
committed
A number of small changes.
Rename Indexes.default to Indexes.get_default. Removed the enable and disable methods on Index, since they weren't doing anything that the Entity method wasn't already doing. Moved reenabling the index at the end of Index.clean to before throwing an exception if the clean didn't leave the index empty.
1 parent 0545eac commit 0026ebe

File tree

2 files changed

+5
-24
lines changed

2 files changed

+5
-24
lines changed

splunklib/client.py

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,7 @@ class Indexes(Collection):
17131713
"""This class contains the collection of indexes in this Splunk instance.
17141714
Retrieve this collection using :meth:`Service.indexes`.
17151715
"""
1716-
def default(self):
1716+
def get_default(self):
17171717
""" Returns the default index.
17181718
17191719
:return: An :class:`Index` object.
@@ -1843,33 +1843,14 @@ def clean(self, timeout=60):
18431843
finally:
18441844
# Restore original values
18451845
self.update(maxTotalDataSizeMB=tds, frozenTimePeriodInSecs=ftp)
1846-
if self.content.totalEventCount != '0':
1847-
raise OperationError, "Cleaning index %s took longer than %s seconds; timing out." % \
1848-
(self.name, timeout)
18491846
if (not was_disabled_initially and \
18501847
self.service.splunk_version < (5,)):
18511848
# Re-enable the index if it was originally enabled and we messed with it.
18521849
self.enable()
1853-
return self
1854-
1855-
def disable(self):
1856-
"""Disables this index.
1857-
1858-
:return: The :class:`Index`.
1859-
"""
1860-
# Starting in Ace, we have to do this with specific sharing,
1861-
# unlike most other entities.
1862-
self.post("disable")
1863-
return self
1864-
1865-
def enable(self):
1866-
"""Enables this index.
1850+
if self.content.totalEventCount != '0':
1851+
raise OperationError, "Cleaning index %s took longer than %s seconds; timing out." %\
1852+
(self.name, timeout)
18671853

1868-
:return: The :class:`Index`.
1869-
"""
1870-
# Starting in Ace, we have to reenable this with a specific
1871-
# sharing unlike most other entities.
1872-
self.post("enable")
18731854
return self
18741855

18751856
def roll_hot_buckets(self):

tests/test_index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_integrity(self):
5757
self.check_entity(self.index)
5858

5959
def test_default(self):
60-
default = self.service.indexes.default()
60+
default = self.service.indexes.get_default()
6161
self.assertTrue(isinstance(default, str))
6262

6363
def test_disable_enable(self):

0 commit comments

Comments
 (0)