Following this example to list user and display properties from here: http://dev.splunk.com/view/python-sdk/SP-CAAAEJ6#listusers ends up in the following error:
Users:
Administrator (admin)
Traceback (most recent call last):
File "splunk.py", line 16, in <module>
for role in user.role_entities:
File "/usr/lib/python2.6/site-packages/splunklib/client.py", line 3054, in role_entities
return [self.service.roles[name] for name in self.content.roles]
File "/usr/lib/python2.6/site-packages/splunklib/client.py", line 3195, in __getitem__
return Collection.__getitem__(self, key.lower())
File "/usr/lib/python2.6/site-packages/splunklib/client.py", line 1163, in __getitem__
raise KeyError(key)
KeyError: 'admin'
shell returned 1
Copied and used the code snippet from above link, and logged in as admin using following
service = splunkclient.connect(host='sh1.hostname',
port=8089,
username='admin',
password='adminpassword')
# Get the collection of users, sorted by realname
kwargs = {"sort_key":"realname", "sort_dir":"desc"}
users = service.users.list(count=-1,**kwargs)
# Print the users' real names, usernames, and roles
print "Users:"
for user in users:
print "%s (%s)" % (user.realname, user.name)
for role in user.role_entities:
print " - ", role.name
Using splunk 6, python sdk 1.0.0. Can someone please help to overcome this issue?
Hi @sathiamoorthy
Sorry you are having problems. we've ran this code with our latest SDK on OSX 10 and did not hit any issues. Can you try this out with our latest SDK 1.2.3 and let us know if you still see it?
Thanks!
Glenn
Hi @sathiamoorthy
Sorry you are having problems. we've ran this code with our latest SDK on OSX 10 and did not hit any issues. Can you try this out with our latest SDK 1.2.3 and let us know if you still see it?
Thanks!
Glenn
Yes 1.2.3 doesn't have this issue, thanks.