<?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 Re: With the Splunk Python SDK, how do I reload deploy client with 2.7? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/With-the-Splunk-Python-SDK-how-do-I-reload-deploy-client-with-2/m-p/438776#M7956</link>
    <description>&lt;P&gt;Hi @daniel333,&lt;/P&gt;

&lt;P&gt;You can try below script to reload deployment server using Python SDK.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import sys
sys.path.append('splunk-sdk-python-1.6.5')
import splunklib.six as six
import urllib
from xml.etree import ElementTree
import getpass

HOST = raw_input("Enter splunk server hostname/ip: ")
PORT = 8089
splunkUser = raw_input("Enter Splunk Admin Username: ")
splunkPassword = getpass.getpass("Enter Splunk Admin Password: ")
sc = raw_input("Enter Serverclass name to reload OR provide hit Enter to reload all server classes: ")

connection = six.moves.http_client.HTTPSConnection(HOST, PORT)
body = urllib.urlencode({'username': splunkUser, 'password': splunkPassword})
headers = {'Content-Type': "application/x-www-form-urlencoded",
           'Host': HOST
          }

connection.request("POST", "/services/auth/login", body, headers)
response = connection.getresponse()
content = response.read()
connection.close()

session_key = ElementTree.XML(content).findtext("./sessionKey")

connection = six.moves.http_client.HTTPSConnection(HOST, PORT)
headers = {'Content-Type': "application/x-www-form-urlencoded",
           'Host': HOST,
           'Authorization': "Splunk %s" % session_key
          }

if not sc:
    body = ''
else:
    body =  urllib.urlencode({"serverclass": sc})

connection.request("POST", "/services/deployment/server/config/_reload", body, headers)

response = connection.getresponse()
content = response.read()
connection.close()

if response.status == 200:
    if not sc:
        print 'Deployment Server reloaded successfully'
    else:
        print 'Deployment server for class ' + sc + ' reloaded successfully'
else:
    print 'Deployment Server reload failed'
    print content
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;if you want to reload whole deployment server then just Hit Enter while asking for Serverclass name otherwise provide serverclass name&lt;/P&gt;

&lt;P&gt;For example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Enter splunk server hostname/ip: mysplunkserver
Enter Splunk Admin Username: admin
Enter Splunk Admin Password:
Enter Serverclass name to reload OR provide hit Enter to reload all server classes: myServerClass
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Above example reload &lt;CODE&gt;myServerClass&lt;/CODE&gt; server class.&lt;/P&gt;</description>
    <pubDate>Tue, 18 Dec 2018 10:51:30 GMT</pubDate>
    <dc:creator>harsmarvania57</dc:creator>
    <dc:date>2018-12-18T10:51:30Z</dc:date>
    <item>
      <title>With the Splunk Python SDK, how do I reload deploy client with 2.7?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/With-the-Splunk-Python-SDK-how-do-I-reload-deploy-client-with-2/m-p/438775#M7955</link>
      <description>&lt;P&gt;All, &lt;/P&gt;

&lt;P&gt;I am just the worst at Python, so forcing myself to use it more. I can make a connection and list the apps per the SDK example. But that is as far as I have gotten. &lt;/P&gt;

&lt;P&gt;Looking to call my deployment server and reload deploy class&lt;BR /&gt;
1) How do I make that API? &lt;BR /&gt;
2) How would I find the name of the method for reloading the deploy class&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 20:29:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/With-the-Splunk-Python-SDK-how-do-I-reload-deploy-client-with-2/m-p/438775#M7955</guid>
      <dc:creator>daniel333</dc:creator>
      <dc:date>2018-12-17T20:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: With the Splunk Python SDK, how do I reload deploy client with 2.7?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/With-the-Splunk-Python-SDK-how-do-I-reload-deploy-client-with-2/m-p/438776#M7956</link>
      <description>&lt;P&gt;Hi @daniel333,&lt;/P&gt;

&lt;P&gt;You can try below script to reload deployment server using Python SDK.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import sys
sys.path.append('splunk-sdk-python-1.6.5')
import splunklib.six as six
import urllib
from xml.etree import ElementTree
import getpass

HOST = raw_input("Enter splunk server hostname/ip: ")
PORT = 8089
splunkUser = raw_input("Enter Splunk Admin Username: ")
splunkPassword = getpass.getpass("Enter Splunk Admin Password: ")
sc = raw_input("Enter Serverclass name to reload OR provide hit Enter to reload all server classes: ")

connection = six.moves.http_client.HTTPSConnection(HOST, PORT)
body = urllib.urlencode({'username': splunkUser, 'password': splunkPassword})
headers = {'Content-Type': "application/x-www-form-urlencoded",
           'Host': HOST
          }

connection.request("POST", "/services/auth/login", body, headers)
response = connection.getresponse()
content = response.read()
connection.close()

session_key = ElementTree.XML(content).findtext("./sessionKey")

connection = six.moves.http_client.HTTPSConnection(HOST, PORT)
headers = {'Content-Type': "application/x-www-form-urlencoded",
           'Host': HOST,
           'Authorization': "Splunk %s" % session_key
          }

if not sc:
    body = ''
else:
    body =  urllib.urlencode({"serverclass": sc})

connection.request("POST", "/services/deployment/server/config/_reload", body, headers)

response = connection.getresponse()
content = response.read()
connection.close()

if response.status == 200:
    if not sc:
        print 'Deployment Server reloaded successfully'
    else:
        print 'Deployment server for class ' + sc + ' reloaded successfully'
else:
    print 'Deployment Server reload failed'
    print content
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;if you want to reload whole deployment server then just Hit Enter while asking for Serverclass name otherwise provide serverclass name&lt;/P&gt;

&lt;P&gt;For example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Enter splunk server hostname/ip: mysplunkserver
Enter Splunk Admin Username: admin
Enter Splunk Admin Password:
Enter Serverclass name to reload OR provide hit Enter to reload all server classes: myServerClass
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Above example reload &lt;CODE&gt;myServerClass&lt;/CODE&gt; server class.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Dec 2018 10:51:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/With-the-Splunk-Python-SDK-how-do-I-reload-deploy-client-with-2/m-p/438776#M7956</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2018-12-18T10:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: With the Splunk Python SDK, how do I reload deploy client with 2.7?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/With-the-Splunk-Python-SDK-how-do-I-reload-deploy-client-with-2/m-p/438777#M7957</link>
      <description>&lt;P&gt;Wow! Exactly what I was trying to build. &lt;/P&gt;

&lt;P&gt;1) I see you're not importing the SDK, does that not offer the functionality ?&lt;BR /&gt;
2) I see you used this endpoint,how would I have found that on my own? /services/deployment/server/config/_reload&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 04:01:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/With-the-Splunk-Python-SDK-how-do-I-reload-deploy-client-with-2/m-p/438777#M7957</guid>
      <dc:creator>daniel333</dc:creator>
      <dc:date>2018-12-19T04:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: With the Splunk Python SDK, how do I reload deploy client with 2.7?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/With-the-Splunk-Python-SDK-how-do-I-reload-deploy-client-with-2/m-p/438778#M7958</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;I am importing Splunk SDK for Python in my script, see &lt;CODE&gt;sys.path.append('splunk-sdk-python-1.6.5')&lt;/CODE&gt;&lt;/LI&gt;
&lt;LI&gt;To use different Splunk REST API start with this &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.2.1/RESTREF/RESTprolog"&gt;documentation&lt;/A&gt; , if you will not able to find required REST API in documentation then run test splunk instance and do your work using CLI or Splunk Web and then check &lt;CODE&gt;$SPLUNK_HOME/var/log/splunk/splunkd_access.log&lt;/CODE&gt; to find which REST API Splunk fired, you will get API but what parameter you need to pass for those API is trail and error method.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Wed, 19 Dec 2018 09:14:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/With-the-Splunk-Python-SDK-how-do-I-reload-deploy-client-with-2/m-p/438778#M7958</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2018-12-19T09:14:53Z</dc:date>
    </item>
    <item>
      <title>Re: With the Splunk Python SDK, how do I reload deploy client with 2.7?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/With-the-Splunk-Python-SDK-how-do-I-reload-deploy-client-with-2/m-p/438779#M7959</link>
      <description>&lt;P&gt;Thanks. It was helpful.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Dec 2018 17:13:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/With-the-Splunk-Python-SDK-how-do-I-reload-deploy-client-with-2/m-p/438779#M7959</guid>
      <dc:creator>prakhersinghal</dc:creator>
      <dc:date>2018-12-27T17:13:33Z</dc:date>
    </item>
  </channel>
</rss>

