@@ -401,7 +401,7 @@ def messages(self):
401401 @property
402402 def modular_input_kinds (self ):
403403 """Returns a collection of the modular input kinds on this Splunk instance."""
404- if self .splunk_version [ 0 ] >= 5 :
404+ if self .splunk_version >= ( 5 ,) :
405405 return ReadOnlyCollection (self , PATH_MODULAR_INPUTS , item = ModularInputKind )
406406 else :
407407 raise IllegalOperationException ("Modular inputs are not supported before Splunk version 5." )
@@ -1481,7 +1481,7 @@ def default(self):
14811481 return index ['defaultDatabase' ]
14821482
14831483 def delete (self , name ):
1484- if self .service .splunk_version [ 0 ] >= 5 :
1484+ if self .service .splunk_version >= ( 5 ,) :
14851485 Collection .delete (self , name )
14861486 else :
14871487 raise IllegalOperationException ("Deleting indexes via the REST API is "
@@ -1558,12 +1558,19 @@ def clean(self, timeout=60):
15581558 self .refresh ()
15591559 tds = self ['maxTotalDataSizeMB' ]
15601560 ftp = self ['frozenTimePeriodInSecs' ]
1561+ was_disabled_initially = self .disabled
15611562 try :
1563+ if (not was_disabled_initially and \
1564+ self .service .splunk_version < (5 ,)):
1565+ # Need to disable the index first on Splunk 4.x,
1566+ # but it doesn't work to disable it on 5.0.
1567+ self .disable ()
15621568 self .update (maxTotalDataSizeMB = 1 , frozenTimePeriodInSecs = 1 )
15631569 self .roll_hot_buckets ()
15641570
15651571 start = datetime .now ()
15661572 diff = timedelta (seconds = timeout )
1573+ # Wait until event count goes to 0.
15671574 while self .content .totalEventCount != '0' and datetime .now () < start + diff :
15681575 sleep (1 )
15691576 self .refresh ()
@@ -1573,6 +1580,10 @@ def clean(self, timeout=60):
15731580 if self .content .totalEventCount != '0' :
15741581 raise OperationError , "Cleaning index %s took longer than %s seconds; timing out." % \
15751582 (self .name , timeout )
1583+ if (not was_disabled_initially and \
1584+ self .service .splunk_version < (5 ,)):
1585+ # Re-enable the index if it was originally enabled and we messed with it.
1586+ self .enable ()
15761587 return self
15771588
15781589 def disable (self ):
0 commit comments