Closed
Description
Attempts to use client for kvstore access fails with user context of 'nobody'
error.
import splunklib.client as client
HOST = "localhost"
PORT = "8089"
'''
### BROKEN ###
service = client.connect(
host=HOST,
port=PORT,
username='admin',
password='changeme')
kv_client = service.kvstore
for kv in kv_client:
print(kv)
# HTTPError: HTTP 400 Bad Request -- Must use user context of 'nobody' when interacting with collection configurations (used user='admin')
Manually this can be solved:
### Solution By Modifying Owner ###
service = client.connect(
host=HOST,
port=PORT,
username='admin',
password='changeme')
print(service.namespace)
#{'owner': None, 'app': None, 'sharing': None}
service.namespace['owner'] = 'Nobody' #<- change namespace owner to Nobody
kv_client = service.kvstore
for kv in kv_client:
print(kv)
# <splunklib.client.KVStoreCollection object at 0x...>
# <splunklib.client.KVStoreCollection object at 0x...>
Since all interactions with kvstores must be done with an owner of Nobody
, this should be set by default in client.py
. I haven't spent much time with this library, but possibly:
class KVStoreCollectionData(object):
"""This class represents the data endpoint for a KVStoreCollection.
Retrieve using :meth:`KVStoreCollection.data`
"""
JSON_HEADER = [('Content-Type', 'application/json')]
def __init__(self, collection):
self.service = collection.service
self.collection = collection
#self.owner, self.app, self.sharing = collection._proper_namespace() # replace this line
self.owner = 'Nobody' # <- add default
self.app, self.sharing = collection._proper_namespace()
Metadata
Metadata
Assignees
Labels
No labels