<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic python sdk raises keyerror while listing roles of user in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/python-sdk-raises-keyerror-while-listing-roles-of-user/m-p/133618#M1905</link>
    <description>&lt;P&gt;Following this example to list user and display properties from here: &lt;A href="http://dev.splunk.com/view/python-sdk/SP-CAAAEJ6#listusers"&gt;http://dev.splunk.com/view/python-sdk/SP-CAAAEJ6#listusers&lt;/A&gt; ends up in the following error:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Users:
Administrator (admin)
Traceback (most recent call last):
  File "splunk.py", line 16, in &amp;lt;module&amp;gt;
    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
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Copied and used the code snippet from above link, and logged in as admin using following &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;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
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Using splunk 6, python sdk 1.0.0. Can someone please help to overcome this issue? &lt;/P&gt;</description>
    <pubDate>Tue, 08 Jul 2014 14:09:55 GMT</pubDate>
    <dc:creator>sathiyamoorthy</dc:creator>
    <dc:date>2014-07-08T14:09:55Z</dc:date>
    <item>
      <title>python sdk raises keyerror while listing roles of user</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/python-sdk-raises-keyerror-while-listing-roles-of-user/m-p/133618#M1905</link>
      <description>&lt;P&gt;Following this example to list user and display properties from here: &lt;A href="http://dev.splunk.com/view/python-sdk/SP-CAAAEJ6#listusers"&gt;http://dev.splunk.com/view/python-sdk/SP-CAAAEJ6#listusers&lt;/A&gt; ends up in the following error:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Users:
Administrator (admin)
Traceback (most recent call last):
  File "splunk.py", line 16, in &amp;lt;module&amp;gt;
    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
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Copied and used the code snippet from above link, and logged in as admin using following &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;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
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Using splunk 6, python sdk 1.0.0. Can someone please help to overcome this issue? &lt;/P&gt;</description>
      <pubDate>Tue, 08 Jul 2014 14:09:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/python-sdk-raises-keyerror-while-listing-roles-of-user/m-p/133618#M1905</guid>
      <dc:creator>sathiyamoorthy</dc:creator>
      <dc:date>2014-07-08T14:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: python sdk raises keyerror while listing roles of user</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/python-sdk-raises-keyerror-while-listing-roles-of-user/m-p/133619#M1906</link>
      <description>&lt;P&gt;Hi @sathiamoorthy&lt;/P&gt;

&lt;P&gt;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?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;BR /&gt;
Glenn&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jul 2014 20:06:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/python-sdk-raises-keyerror-while-listing-roles-of-user/m-p/133619#M1906</guid>
      <dc:creator>gblock_splunk</dc:creator>
      <dc:date>2014-07-17T20:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: python sdk raises keyerror while listing roles of user</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/python-sdk-raises-keyerror-while-listing-roles-of-user/m-p/133620#M1907</link>
      <description>&lt;P&gt;Yes 1.2.3 doesn't have this issue, thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jul 2014 14:19:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/python-sdk-raises-keyerror-while-listing-roles-of-user/m-p/133620#M1907</guid>
      <dc:creator>sathiyamoorthy</dc:creator>
      <dc:date>2014-07-18T14:19:23Z</dc:date>
    </item>
  </channel>
</rss>

