I’ve recently been playing around with the A10 aXAPI, writing a PHP based web application to help automate the management of our A10 Application Delivery Controllers (Load Balancers). I like to start these projects small and then add features and functionality as I become more accustom to the API and refine the application requirements. Starting small also helps me visualize my progress and keeps me engaged as the code development progresses. There’s nothing worse than writing code where you can’t easily and quickly see the fruits of your labors. I had a little prototype up and working within a few hours and felt pretty good about myself. That was three days ago now.
:(
I’ve spent the past three days troubleshooting a bug in the PHP SDK itself.
Once I had my prototype working I started to add some error checking and logging. I quickly discovered that calls to closeSession() were failing, but they were failing from within the SDK itself, never making it to the actual appliance. I switched to termSession() which was also failing but at least the SDK was actually passing the API request to the appliance and I could see it failing in a packet trace. The SDK would return “Paramater [SID] must be provided” with closeSession() or “Invalid session ID” with termSession().
The PHP SDK formulates the REST calls to the A10 ADC, however, in this case the PHP SDK wasn’t formulating the calls properly when using termSession() and wasn’t sending anything when using closeSession() because it was likely failing an internal parameter check.
Here’s the example below when I called $axapi->sessionTerm();
http://10.1.1.1/services/rest/V2/?method=session.close&sid=d058ce0c98a30674dfdc4e39bbfcef
Here’s what I eventually discovered the REST API actually expects;
http://10.1.1.1/services/rest/V2/?method=session.close&session_id=d058ce0c98a30674dfdc4e39bbfcef
I’m not sure how many people are using the PHP SDK but I’d guess not too many. I had to hack the files /include/fucntions_1.php and /include/functions_2.php so that they passed the parameter name of session_id and not sid.
[mfm@centos includes]# diff functions_1.php functions_1.php-orig 6c6 < 'close' =>array('xpath' => 'response', 'function' => 'session.close', 'request_method' => 'POST', 'params' => array('session_id' => array('required'))), --- > 'close' =>array('xpath' => 'response', 'function' => 'session.close', 'request_method' => 'POST', 'params' => array('sid' => array('required'))), 411c411 < return $result; --- > return $result; \ No newline at end of file [mfm@centos includes]# diff functions_2.php functions_2.php-orig 7c7 < 'close' =>array('xpath' => '//response', 'function' => 'session.close', 'request_method' => 'POST','version' => 1, 'params' => array('session_id' => array('required'))), --- > 'close' =>array('xpath' => '//response', 'function' => 'session.close', 'request_method' => 'POST','version' => 1, 'params' => array('sid' => array('required'))), 513c513 < return $result; --- > return $result; \ No newline at end of file
With that change I’m no longer getting errors when trying to close the session and I can go back to actually writing useful code.
On another note it took me more than a few minutes to find the actual SDKs. There’s a few really tantalizing write-ups available on A10’s website but neither go into much detail and they both refer users to the other document which left me a loop – pardon the pun. I finally found the SDKs on the download side of the support website.
I hope to start posting some useful information around A10 now that they have a lot of visibility in my network.
Cheers!