Accessing Sonus UX with REST API’s
Follow me With the release of version 3.0 firmware for Sonus UX1000/2000 several new features have been added. As part of 3.0 upgrade REST license has become part of the Base license hence it is available free of charge. This is one of the feature I have been most excited about. REST API support has been there in the UX’s for some time license fee was required until R3.0.
REST certainly has opened lot of possibilities to manage Sonus UX’s esp. if you have few of them to manage. I would go as far as saying REST API license probably is compelling enough reason to move to R3.0.
UX REST API and PowerShell
With Poweshell v3 we now have cmdlets which supports REST API. That means we can easily access the UX using REST API by leveraging PowerShell…Right….well…almost.
In order to access the UX login credentials are required. This is something which should be specified when a REST call is made. PowerShell fully supports parameters to add the authentication information. Once the client is authenticated the UX provides the REST client (in this case PowerShell) a session token in a cookie. All subsequent requests to access any resources on the UX are authenticated using the cookie. Now this is where it all breaks down if you are using PowerShell. I couldn’t figure out a way in PowerShell v3 to use cookie authentication with UX.
Alternatives to PowerShell
I am sure Sonus will soon release the required documentation to connect to UX using REST but with PowerShell out of question (for now) what other options we have? Well cURL is another extremely powerful client which can be used to connect to REST services. cURL is a command line tool for getting or sending files using URL syntax.
UX REST API and cURL
To get started ensure your UX is on R3.0 at minimum and you have got REST license applied (Its part of the Base license)
Irrespective of what REST client you use a REST Account will need to be created on the UX. This can be done by logging on to the UX web console and navigating to Settings>Security>users > Local User Management
Now download CURL (for Windows) from http://curl.haxx.se/dlwiz/?type=bin&os=Win32&flav=-&ver=2000%2FXP
Unzip the download file. No installation is required. The program is launched directly from an exe.
Once extracted you will have the following files
Launch command prompt and navigate to the folder where cURL files are extracted
To make connection to the UX use following command is required change Username, password, IP address as per requirements
If the command is successful the following output appears. This output also contains the “Session token” in a cookie which will be used for subsequent authentication
Accessing UX via REST using cURL
Once you are logged in you are ready to make REST calls.
The command below will access System configuration (eg: DNS Server name, NTP server, ASM module details, hardware information etc.)
Below is the partial output from the above command:
To access other resources like Routing tables, Transformation table, Signalling groups, etc. you just need to request the correct URL (https://188.8.131.52/rest/routingtable). The list of valid resources is available on https://support.net.com/display/UXAPIDOC/REST+Resources
UX REST API and PowerShell….Again
We are yet unable to natively connect using PowerShell to UX REST API, but all is not lost. You can use cURL in PowerShell as well.
$Command = “.\curl.exe –cookie PHPSESSID=4sr9e2dtfc9trmg739lv56ith3 –i -v https://10.37.3.172/rest/routingtable/4 –insecure”
$Output= invoke-expression $Command
Once you have got all in the $ouput variable, you can just parse the XML and get the required information
REST API provides access to several of UX resources. It certainly is not the most user friendly way to access the UX but once you get the hang of it you can do absolutely anything …..Backup, Restores, bulk create transformation tables, Delete stuff, etc.
In the next post I will show you how you can use REST API’s to perform the Backup of the UX. Hint: It’s just another ResourceJ
If you don’t know what Sonus UX is , check this out http://www.sonus.net/node/1959
UX REST Resources – https://support.net.com/display/UXAPIDOC/REST+Resources