<?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 Delete index and recreate using python sdk in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Delete-index-and-recreate-using-python-sdk/m-p/439907#M76722</link>
    <description>&lt;P&gt;Hi, &lt;BR /&gt;
  I am trying to delete all data from an index for automated testing using the python sdk. The splunk.client.index.clean works intermittently but times out often. I seen this question: where in the last comment gblock [Splunk] suggest not using the clean function but delete the index and recreate instead. I have tried this in the below code function but when I try to recreate, I get an error saying &lt;/P&gt;

&lt;P&gt;HTTPError: HTTP 404 Not Found -- Index "testindex" is being deleted; name still unavailable&lt;/P&gt;

&lt;P&gt;Sode Snippet&lt;/P&gt;

&lt;P&gt;def clear_index(index):&lt;BR /&gt;
    service = splunk_connection.get()&lt;BR /&gt;
    if index.state.content.disabled == 1:&lt;BR /&gt;
        index.enable()&lt;BR /&gt;
    name = index.name&lt;BR /&gt;
    service.indexes.delete(name)&lt;BR /&gt;
    service.indexes.create(name)&lt;/P&gt;

&lt;P&gt;the user is created as follows.&lt;/P&gt;

&lt;P&gt;/opt/splunk/bin/splunk add user usernasme  -password password  -role admin -auth admin:changeme'&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 19:51:19 GMT</pubDate>
    <dc:creator>bertm81</dc:creator>
    <dc:date>2020-09-29T19:51:19Z</dc:date>
    <item>
      <title>Delete index and recreate using python sdk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Delete-index-and-recreate-using-python-sdk/m-p/439907#M76722</link>
      <description>&lt;P&gt;Hi, &lt;BR /&gt;
  I am trying to delete all data from an index for automated testing using the python sdk. The splunk.client.index.clean works intermittently but times out often. I seen this question: where in the last comment gblock [Splunk] suggest not using the clean function but delete the index and recreate instead. I have tried this in the below code function but when I try to recreate, I get an error saying &lt;/P&gt;

&lt;P&gt;HTTPError: HTTP 404 Not Found -- Index "testindex" is being deleted; name still unavailable&lt;/P&gt;

&lt;P&gt;Sode Snippet&lt;/P&gt;

&lt;P&gt;def clear_index(index):&lt;BR /&gt;
    service = splunk_connection.get()&lt;BR /&gt;
    if index.state.content.disabled == 1:&lt;BR /&gt;
        index.enable()&lt;BR /&gt;
    name = index.name&lt;BR /&gt;
    service.indexes.delete(name)&lt;BR /&gt;
    service.indexes.create(name)&lt;/P&gt;

&lt;P&gt;the user is created as follows.&lt;/P&gt;

&lt;P&gt;/opt/splunk/bin/splunk add user usernasme  -password password  -role admin -auth admin:changeme'&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:51:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Delete-index-and-recreate-using-python-sdk/m-p/439907#M76722</guid>
      <dc:creator>bertm81</dc:creator>
      <dc:date>2020-09-29T19:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: Delete index and recreate using python sdk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Delete-index-and-recreate-using-python-sdk/m-p/439908#M76723</link>
      <description>&lt;P&gt;Bumping this as I am still having this issue. &lt;/P&gt;</description>
      <pubDate>Wed, 11 Jul 2018 16:01:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Delete-index-and-recreate-using-python-sdk/m-p/439908#M76723</guid>
      <dc:creator>bertm81</dc:creator>
      <dc:date>2018-07-11T16:01:04Z</dc:date>
    </item>
  </channel>
</rss>

