aXAPI: slb.template.client_ssl.create
Keepcase
Member ✭
Hey all,
I was wondering if someone could lend a hand in regards to how to properly put together a request using python over aXAPI using the slb.template.client_ssl.create method.
I was trying to setup the parameters but I'm getting confused using the Url-encode options and how to properly set the array, I was doing the following but I keep getting invalid parameters.
I keep getting the following error:
Any help would be greatly appreciated! (I have a feeling I'm not passing this in properly but I will keep trying while checking back here)
I was wondering if someone could lend a hand in regards to how to properly put together a request using python over aXAPI using the slb.template.client_ssl.create method.
I was trying to setup the parameters but I'm getting confused using the Url-encode options and how to properly set the array, I was doing the following but I keep getting invalid parameters.
config = {}
config['name'] = 'template1'
config['key_name'] = 'key1.key'
config['cert_name'] = 'cert1.crt'
config['cipher_list'] = 'cipher1%02cipher2'
config['cipher1'] = 'name%03TLS1_RSA_EXPORT1024_RC4_56_SHA'
config['cipher2'] = 'name%03TLS1_RSA_EXPORT1024_RC4_56_MD5'
myClass(host,sid,json.dumps(config))
I keep getting the following error:
response status="fail" error code="1003" msg="Invalid parameters
Any help would be greatly appreciated! (I have a feeling I'm not passing this in properly but I will keep trying while checking back here)
0
Comments
So depending on the code version you are running json may not be supported for the method. In that case you have to encode the parameters. A stream dump looks like this:
POST /services/rest/V2/?session_id=0e8e80eeea436a771d7741530a3a35&method=slb.template.client_ssl.create HTTP/1.0 Content-Type: application/x-www-form-urlencoded Content-Length: 70 Host: 172.21.21.254 User-Agent: Python-urllib/1.17 key_name=MyCertificateTest&name=myTemplate&cert_name=MyCertificateTestHTTP/1.1 200 OK Content-Type: application/xml Date: Thu, 18 Oct 2012 20:51:31 GMT Expires: Thu, 26 Oct 1995 00:00:00 GMT Last-Modified: Thu, 18 Oct 2012 20:51:31 GMT Pragma: no-cache Content-Length: 72 Server: A10WS/1.00
Working sample code looks like:
class template(object): @classmethod def clientSSL(cls, host, sid, configuration): method = "method=slb.template.client_ssl.create" data = req.postXML(host, method, sid, configuration) return data host = "172.21.21.254" username = 'admin' password = 'a10' tempName = "myTemplate" cert = "MyCertificateTest" key = "MyCertificateTest" mytemplate = urllib.urlencode({ 'name': tempName, 'cert_name': cert, 'key_name': key }) sid = auth.sessionID(host, username, password) t = template.clientSSL(host, sid, mytemplate) auth.sessionClose(host, sid)
Thanks for taking advantage of the API.
Let's see what else I can do with this API
Any particular methods you find useful that might not necessarily be used that often?
I'm thinking to work on stats next; I was going to start parsing the fetchAllStatistics methods for servers and virtual_servers next
I've just been playing around with servers, service_groups, virtual_servers and SSL.
Thanks again! I'll keep you posted
Cheers