Hi Damien,
I made some progress and I managed to write down the custom authentication handler which I confirm it is working (I tested it standalone using python.exe).
Basically the authentication handler does a Post to vcloud director and once authenticated saves the authentication token (http x-vcloud-authorization header ) which has to be used for the following GET API requests which I make using the REST API Modular Input UI.
My problem is that I am not too sure how and if I have to pass the x-vcloud-authorization token back to the REST API Modular Input
below the code:
class vCloudAuth(vCloud):
def __init__(self,**args):
# Custom Authentication Handler Arguments I am passing from REST API Modular Input.
self.username = args['username']
self.password = args['password']
pass
def __call__(self,r):
# do a Post to https://x.x.x.x/api/sessions passing 'Accept:application/*+xml;version=1.5' , Username, Password
# return x-vcloud-authorization token
# Set the required Headers
headers = {'Accept': 'application/*+xml;version=1.5'}
# Set the URL
url = 'https://x.x.x.x/api/sessions'
# Make the API POST
r = requests.post(url, headers=headers, auth=(self.username, self.password), verify=False)
THIS IS THE STEP I AM NOT TOO SURE ABOUT
#should I return just the header I need?
#return r.headers['x-vcloud-authorization']
#or should I return the whole Request object?
#return r
Splunkd.log shows the following error:
12-31-2014 11:09:00.371 +0000 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/rest_ta/bin/rest.py" Traceback (most recent call last):
12-31-2014 11:09:00.371 +0000 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/rest_ta/bin/rest.py" File "/opt/splunk/etc/apps/rest_ta/bin/rest.py", line 696, in <module>
12-31-2014 11:09:00.371 +0000 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/rest_ta/bin/rest.py" do_run()
12-31-2014 11:09:00.371 +0000 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/rest_ta/bin/rest.py" File "/opt/splunk/etc/apps/rest_ta/bin/rest.py", line 332, in do_run
12-31-2014 11:09:00.371 +0000 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/rest_ta/bin/rest.py" (item.split('=') for item in http_header_propertys_str.split(delimiter)))
12-31-2014 11:09:00.371 +0000 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/rest_ta/bin/rest.py" File "/opt/splunk/etc/apps/rest_ta/bin/rest.py", line 331, in <genexpr>
12-31-2014 11:09:00.371 +0000 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/rest_ta/bin/rest.py" http_header_propertys = dict((k.strip(), v.strip()) for k,v in
12-31-2014 11:09:00.372 +0000 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/rest_ta/bin/rest.py" ValueError: too many values to unpack
Do I need to modify opt/splunk/etc/apps/rest_ta/bin/rest.py as well?
Happy new Year!
Thanks again,
Davide.
... View more