Skip to content

Commit 52f497d

Browse files
authored
Merge branch 'develop' into bug/DVPL-7204-distributed-search
2 parents 89cd027 + adfa4d5 commit 52f497d

File tree

12 files changed

+1039
-1026
lines changed

12 files changed

+1039
-1026
lines changed

examples/searchcommands_app/package/default/searchbnf.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ comment1 = \
3636
example1 = \
3737
| generatetext text="Hello world! How the heck are you?" count=6 \
3838
| filter predicate="(long(_serial) & 1) == 0" map="_raw = _raw.replace('world', 'Splunk')"
39-
category = eventing
39+
category = events
4040
appears-in = 1.5
4141
maintainer = dnoble
4242
usage = public

splunklib/searchcommands/eventing_command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ class ConfigurationSettings(SearchCommand.ConfigurationSettings):
113113
114114
''')
115115

116-
type = ConfigurationSetting(readonly=True, value='eventing', doc='''
116+
type = ConfigurationSetting(readonly=True, value='events', doc='''
117117
Command type
118118
119-
Fixed: :const:`'eventing'`.
119+
Fixed: :const:`'events'`.
120120
121121
Supported by: SCP 2
122122

splunklib/searchcommands/generating_command.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class GeneratingCommand(SearchCommand):
5656
+==========+=====================================+============================================+
5757
| streams | streaming=True[,local=[True|False]] | type='streaming'[,distributed=[true|false] |
5858
+----------+-------------------------------------+--------------------------------------------+
59-
| events | retainsevents=True, streaming=False | type='eventing' |
59+
| events | retainsevents=True, streaming=False | type='events' |
6060
+----------+-------------------------------------+--------------------------------------------+
6161
| reports | streaming=False | type='reporting' |
6262
+----------+-------------------------------------+--------------------------------------------+
@@ -112,7 +112,7 @@ class StreamingGeneratingCommand(GeneratingCommand)
112112
| | settings to your command class: | setting to your command class: |
113113
| | | |
114114
| | .. code-block:: python | .. code-block:: python |
115-
| | @Configuration( | @Configuration(type='eventing') |
115+
| | @Configuration( | @Configuration(type='events') |
116116
| | retainsevents=True, streaming=False) | class SomeCommand(GeneratingCommand) |
117117
| | class SomeCommand(GeneratingCommand) | ... |
118118
| | ... | |
@@ -127,7 +127,7 @@ class StreamingGeneratingCommand(GeneratingCommand)
127127
Configure your command class like this, if you wish to support both protocols:
128128
129129
.. code-block:: python
130-
@Configuration(type='eventing', retainsevents=True, streaming=False)
130+
@Configuration(type='events', retainsevents=True, streaming=False)
131131
class SomeCommand(GeneratingCommand)
132132
...
133133
@@ -193,6 +193,18 @@ def _execute(self, ifile, process):
193193
:return: `None`.
194194
195195
"""
196+
if self._protocol_version == 2:
197+
result = self._read_chunk(ifile)
198+
199+
if not result:
200+
return
201+
202+
metadata, body = result
203+
action = getattr(metadata, 'action', None)
204+
205+
if action != 'execute':
206+
raise RuntimeError('Expected execute action, not {}'.format(action))
207+
196208
self._record_writer.write_records(self.generate())
197209
self.finish()
198210

@@ -280,7 +292,7 @@ class ConfigurationSettings(SearchCommand.ConfigurationSettings):
280292
==================== ======================================================================================
281293
Value Description
282294
-------------------- --------------------------------------------------------------------------------------
283-
:const:`'eventing'` Runs as the first command in the Splunk events pipeline. Cannot be distributed.
295+
:const:`'events'` Runs as the first command in the Splunk events pipeline. Cannot be distributed.
284296
:const:`'reporting'` Runs as the first command in the Splunk reports pipeline. Cannot be distributed.
285297
:const:`'streaming'` Runs as the first command in the Splunk streams pipeline. May be distributed.
286298
==================== ======================================================================================

splunklib/searchcommands/internals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ def validate_configuration_setting(specification, name, value):
326326
supporting_protocols=[1, 2]),
327327
'type': specification(
328328
type=(bytes, unicode),
329-
constraint=lambda value: value in ('eventing', 'reporting', 'streaming'),
329+
constraint=lambda value: value in ('events', 'reporting', 'streaming'),
330330
supporting_protocols=[2])}
331331

332332

splunklib/searchcommands/search_command.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# Absolute imports
2020

2121
from collections import namedtuple
22+
2223
try:
2324
from collections import OrderedDict # must be python 2.7
2425
except ImportError:
@@ -27,6 +28,7 @@
2728
from cStringIO import StringIO
2829
from itertools import chain, ifilter, imap, islice, izip
2930
from logging import _levelNames, getLevelName, getLogger
31+
3032
try:
3133
from shutil import make_archive
3234
except ImportError:
@@ -47,7 +49,7 @@
4749

4850
# Relative imports
4951

50-
from . internals import (
52+
from .internals import (
5153
CommandLineParser,
5254
CsvDialect,
5355
InputHeader,
@@ -63,6 +65,7 @@
6365
from . import Boolean, Option, environment
6466
from ..client import Service
6567

68+
6669
# ----------------------------------------------------------------------------------------------------------------------
6770

6871
# P1 [ ] TODO: Log these issues against ChunkedExternProcessor
@@ -89,6 +92,7 @@ class SearchCommand(object):
8992
""" Represents a custom search command.
9093
9194
"""
95+
9296
def __init__(self):
9397

9498
# Variables that may be used, but not altered by derived classes
@@ -873,8 +877,10 @@ def _read_chunk(ifile):
873877
# if body_length <= 0:
874878
# return metadata, ''
875879

880+
body = ""
876881
try:
877-
body = ifile.read(body_length)
882+
if body_length > 0:
883+
body = ifile.read(body_length)
878884
except Exception as error:
879885
raise RuntimeError('Failed to read body of length {}: {}'.format(body_length, error))
880886

Binary file not shown.

0 commit comments

Comments
 (0)