Hi
I want to connect to Splunk using a Python SDK.
This is the code in python:
import splunklib.client as client
HOST = "localhost"
PORT = 8089
USERNAME = "admin"
PASSWORD = "passwdSPLUNK"
# Create a Service instance and log in
service = client.connect(
host=HOST,
port=PORT,
username=USERNAME,
password=PASSWORD)
# Print installed apps to the console to verify login
for app in service.apps:
print (app.name)
And this is my attempt to do the same using Julia. It obviously does not work.
using PyCall
py"""
import splunklib.client as client
def Julk_Connect(x):
service = client.connect([{'host': "localhost", 'port': 8089, 'username': "admin", 'password': x}])
return service
"""
py"Julk_Connect"(passwdSPLUNK)
This is other attempt using a Module:
module MyJulk
function __init__()
print("Module MyJulk loaded")
end
function Julk_Connect(port)::PyCall.PyObject
py"""
import splunklib.client as client
def Julk_ConnectP(aport):
service = client.connect([{'host': 'localhost', 'port': aport, 'username': 'admin', 'password': 'passwdSPLUNK'}])
return service
"""
py"Julk_ConnectP"(port)
end
end
Please, any clues on what am I doing wrong?