Sonus SBC 1K/2K: Transformation Table Entry Builder

Original Source: https://johnacook.wordpress.com/2014/03/28/sonus-sbc-1k2k-transformation-table-entry-builder-ariprotheroe/

This post is not my own work, it’s been copied from https://johnacook.wordpress.com and is his own content fully, permission has been sought.

I urge you to check out this excel building tool utilizing cURL and the REST API as it will make your life easier, yes its a old post but for most of us working with individual numbers and no consistency where regex isn’t a option its great.

I have yet to find another way to do this… suggestions welcomed!

Preparing your Sonus SBC 1000/2000 Gateway

With version 3.0 and later of the Sonus SBC 1K/2K software/ a Representational State Transfer (REST) API was added.  So make sure you update the software on the Sonus gateway first.

Then if you go to System\Licencing\Current Licenses in the Sonus WebUI you should see REST, the license was included with version 3.0

clip_image001

Next we need to create a REST Users, go to Security\Users\Local User Management, click on the green plus.  Then specific user name, password and set the Access Level to REST

clip_image002

Next up let create a new empty transformation table, you could use an existing one but I think this is best done with new empty one and then you can just switch to the new transformation table in the Call Route

clip_image003

Once the transformation table is created, make a note of the primary key on the left, you can get then via REST too but well be using this to tell REST where to put our entries.

clip_image004

In order to REST you will need a utility called cURL is required, you can get it here: http://curl.haxx.se/ once you have extracted it you should see the following files:

clip_image005

Now, I found cURL to be a bit instable when using it without SSL, so if you go for CA (I am assuming ADCS here), and click on Download a CA certificate, certificate chain or CRL

clip_image006

Select the CA certificate, set the encoding method to Base 64 and download the CA certificate chain.

clip_image007

Once you have download the certificate you need to convert it to the PEM  certificate format, you can do this using OpenSSL however the the SSL Shopper website has an online converter: https://www.sslshopper.com/ssl-converter.html

clip_image008

Once you have the converted certificate file .crt file copy it into the bin folder with the CURL.exe file.

Creating a REST Logon session and Token

Open a command prompt, when change folder in the bin file (with both CURL.exe and PEM formatted certificate file)

Then to create a logon use the following syntax at the command prompt:

curl.exe –data “Username=<RESTUSERID>&Password=<USERPASSWORD>” –i –v https://<SONUSFQDN>/rest/login –cacert <CACERTFILE>

for example:

curl.exe --data "Username=rest&Password=restpass" -i -v https://sonussbc1.uctestlab.com/rest/login --cacert UcTestLab-RootCA-Chain.crt

Make a note of the logon token (highlighted), you will need this for the builder.  beware the logon token will timeout on the Sonus with inactivity.

clip_image009

Using the Sonus SBC 1000/2000 Transformation Table Entry Builder

There are three based tab in the spreadsheet

  • Version: general details about the tool
  • Input: for input
  • Output: with the REST commands

clip_image010

The input sheet will do some basic validation, the yellow cells are important required information to build the REST commands

clip_image011

At the top is the input sheet is the following required information (yellow cells):

  • FQDN/IP of the Sonus SBC: for connection, the FQDN is important for SSL
  • Logon Cookie: which you previous got
  • Transformation Table: this is the previously note primary key
  • The the CA cert name: the filename for the PEM format CA certificate

clip_image012

Below we have the input rows for the transformation table entries, note the first row has a yellow cell which is set to 1 for input this will be the first transformation table entry.  if you are using an existing transformation table with 5 entries, you might want to set it to 10.  Do be beware if you have deleted existing rules is the past, as you primary key for the entries doesn’t change and this is only visible via REST. Hence why using a new transformation table is best for replacing an existing one.

clip_image013

If a row has incomplete information then it won’t show with the green OK.

NOTE: setting the Admin state of the transformation table entry isn’t as simple via REST as it is via the WebUI, I have left this column in but may remove it in a future release.

clip_image014

Then on the output tab are all the create rest commands

clip_image015

Here are the command from my example entries:

curl.exe --cookie PHPSESSID=1guhvo3s0rdu61t9fa3018scp5 -i -v https://sonussbc01.uctestlab.com/rest/transformationtable/2/transformationentry/1 -X PUT --data "Description=Called [0000-0999] to E.164&InputField=0&InputFieldValue=^0(\d{3}$)&MatchType=1&OutputField=0&OutputFieldValue=%2B442079460\1" --cacert uctestlab-RootCA-Chain.crt
curl.exe --cookie PHPSESSID=1guhvo3s0rdu61t9fa3018scp5 -i -v https://sonussbc01.uctestlab.com/rest/transformationtable/2/transformationentry/2 -X PUT --data "Description=Calling [0000-0999] to E.164&InputField=3&InputFieldValue=^0(\d{3}$)&MatchType=1&OutputField=3&OutputFieldValue=%2B442079460\1" --cacert uctestlab-RootCA-Chain.crt
curl.exe --cookie PHPSESSID=1guhvo3s0rdu61t9fa3018scp5 -i -v https://sonussbc01.uctestlab.com/rest/transformationtable/2/transformationentry/3 -X PUT --data "Description=Called [1000-1999] to E.164&InputField=0&InputFieldValue=^1(\d{3}$)&MatchType=1&OutputField=0&OutputFieldValue=%2B442920180\1" --cacert uctestlab-RootCA-Chain.crt
curl.exe --cookie PHPSESSID=1guhvo3s0rdu61t9fa3018scp5 -i -v https://sonussbc01.uctestlab.com/rest/transformationtable/2/transformationentry/4 -X PUT --data "Description=Calling [1000-1999] to E.164&InputField=3&InputFieldValue=^1(\d{3}$)&MatchType=1&OutputField=3&OutputFieldValue=%2B442920180\1" --cacert uctestlab-RootCA-Chain.crt
curl.exe --cookie PHPSESSID=1guhvo3s0rdu61t9fa3018scp5 -i -v https://sonussbc01.uctestlab.com/rest/transformationtable/2/transformationentry/5 -X PUT --data "Description=Called [2000-2999] to E.164&InputField=0&InputFieldValue=^2(\d{3}$)&MatchType=1&OutputField=0&OutputFieldValue=%2B441214960\1" --cacert uctestlab-RootCA-Chain.crt
curl.exe --cookie PHPSESSID=1guhvo3s0rdu61t9fa3018scp5 -i -v https://sonussbc01.uctestlab.com/rest/transformationtable/2/transformationentry/6 -X PUT --data "Description=Calling [2000-2999] to E.164&InputField=3&InputFieldValue=^2(\d{3}$)&MatchType=1&OutputField=3&OutputFieldValue=%2B441214960\1" --cacert uctestlab-RootCA-Chain.crt
curl.exe --cookie PHPSESSID=1guhvo3s0rdu61t9fa3018scp5 -i -v https://sonussbc01.uctestlab.com/rest/transformationtable/2/transformationentry/7 -X PUT --data "Description=Called [3000-3999] to E.164&InputField=0&InputFieldValue=^3(\d{3}$)&MatchType=1&OutputField=0&OutputFieldValue=%2B441134960\1" --cacert uctestlab-RootCA-Chain.crt
curl.exe --cookie PHPSESSID=1guhvo3s0rdu61t9fa3018scp5 -i -v https://sonussbc01.uctestlab.com/rest/transformationtable/2/transformationentry/8 -X PUT --data "Description=Calling [3000-3999] to E.164&InputField=3&InputFieldValue=^3(\d{3}$)&MatchType=1&OutputField=3&OutputFieldValue=%2B441134960\1" --cacert uctestlab-RootCA-Chain.crt
curl.exe --cookie PHPSESSID=1guhvo3s0rdu61t9fa3018scp5 -i -v https://sonussbc01.uctestlab.com/rest/transformationtable/2/transformationentry/9 -X PUT --data "Description=Called [4000-4999] to E.164&InputField=0&InputFieldValue=^4(\d{3}$)&MatchType=1&OutputField=0&OutputFieldValue=%2B441144960\1" --cacert uctestlab-RootCA-Chain.crt
curl.exe --cookie PHPSESSID=1guhvo3s0rdu61t9fa3018scp5 -i -v https://sonussbc01.uctestlab.com/rest/transformationtable/2/transformationentry/10 -X PUT --data "Description=Calling [4000-4999] to E.164&InputField=3&InputFieldValue=^4(\d{3}$)&MatchType=1&OutputField=3&OutputFieldValue=%2B441144960\1" --cacert uctestlab-RootCA-Chain.crt
curl.exe --cookie PHPSESSID=1guhvo3s0rdu61t9fa3018scp5 -i -v https://sonussbc01.uctestlab.com/rest/transformationtable/2/transformationentry/11 -X PUT --data "Description=Called [5000-5999] to E.164&InputField=0&InputFieldValue=^5(\d{3}$)&MatchType=1&OutputField=0&OutputFieldValue=%2B441154960\1" --cacert uctestlab-RootCA-Chain.crt
curl.exe --cookie PHPSESSID=1guhvo3s0rdu61t9fa3018scp5 -i -v https://sonussbc01.uctestlab.com/rest/transformationtable/2/transformationentry/12 -X PUT --data "Description=Calling [5000-5999] to E.164&InputField=3&InputFieldValue=^5(\d{3}$)&MatchType=1&OutputField=3&OutputFieldValue=%2B441154960\1" --cacert uctestlab-RootCA-Chain.crt
curl.exe --cookie PHPSESSID=1guhvo3s0rdu61t9fa3018scp5 -i -v https://sonussbc01.uctestlab.com/rest/transformationtable/2/transformationentry/13 -X PUT --data "Description=Called [6000-6999] to E.164&InputField=0&InputFieldValue=^6(\d{3}$)&MatchType=1&OutputField=0&OutputFieldValue=%2B441164960\1" --cacert uctestlab-RootCA-Chain.crt
curl.exe --cookie PHPSESSID=1guhvo3s0rdu61t9fa3018scp5 -i -v https://sonussbc01.uctestlab.com/rest/transformationtable/2/transformationentry/14 -X PUT --data "Description=Calling [6000-6999] to E.164&InputField=3&InputFieldValue=^6(\d{3}$)&MatchType=1&OutputField=3&OutputFieldValue=%2B441164960\1" --cacert uctestlab-RootCA-Chain.crt
curl.exe --cookie PHPSESSID=1guhvo3s0rdu61t9fa3018scp5 -i -v https://sonussbc01.uctestlab.com/rest/transformationtable/2/transformationentry/15 -X PUT --data "Description=Called [7000-7999] to E.164&InputField=0&InputFieldValue=^7(\d{3}$)&MatchType=1&OutputField=0&OutputFieldValue=%2B441174960\1" --cacert uctestlab-RootCA-Chain.crt
curl.exe --cookie PHPSESSID=1guhvo3s0rdu61t9fa3018scp5 -i -v https://sonussbc01.uctestlab.com/rest/transformationtable/2/transformationentry/16 -X PUT --data "Description=Calling [7000-7999] to E.164&InputField=3&InputFieldValue=^7(\d{3}$)&MatchType=1&OutputField=3&OutputFieldValue=%2B441174960\1" --cacert uctestlab-RootCA-Chain.crt
curl.exe --cookie PHPSESSID=1guhvo3s0rdu61t9fa3018scp5 -i -v https://sonussbc01.uctestlab.com/rest/transformationtable/2/transformationentry/17 -X PUT --data "Description=Called [8000-8999] to E.164&InputField=0&InputFieldValue=^8(\d{3}$)&MatchType=1&OutputField=0&OutputFieldValue=%2B441184960\1" --cacert uctestlab-RootCA-Chain.crt
curl.exe --cookie PHPSESSID=1guhvo3s0rdu61t9fa3018scp5 -i -v https://sonussbc01.uctestlab.com/rest/transformationtable/2/transformationentry/18 -X PUT --data "Description=Calling [8000-8999] to E.164&InputField=3&InputFieldValue=^8(\d{3}$)&MatchType=1&OutputField=3&OutputFieldValue=%2B441184960\1" --cacert uctestlab-RootCA-Chain.crt
curl.exe --cookie PHPSESSID=1guhvo3s0rdu61t9fa3018scp5 -i -v https://sonussbc01.uctestlab.com/rest/transformationtable/2/transformationentry/19 -X PUT --data "Description=Called [9000-9999] to E.164&InputField=0&InputFieldValue=^9(\d{3}$)&MatchType=1&OutputField=0&OutputFieldValue=%2B441194960\1" --cacert uctestlab-RootCA-Chain.crt
curl.exe --cookie PHPSESSID=1guhvo3s0rdu61t9fa3018scp5 -i -v https://sonussbc01.uctestlab.com/rest/transformationtable/2/transformationentry/20 -X PUT --data "Description=Calling [9000-9999] to E.164&InputField=3&InputFieldValue=^9(\d{3}$)&MatchType=1&OutputField=3&OutputFieldValue=%2B441194960\1" --cacert uctestlab-RootCA-Chain.crt
curl.exe --cookie PHPSESSID=1guhvo3s0rdu61t9fa3018scp5 -i -v https://sonussbc01.uctestlab.com/rest/transformationtable/2/transformationentry/21 -X PUT --data "Description=Calling Number (ALL)&InputField=3&InputFieldValue=(.*)&MatchType=1&OutputField=3&OutputFieldValue=\1" --cacert uctestlab-RootCA-Chain.crt
curl.exe --cookie PHPSESSID=1guhvo3s0rdu61t9fa3018scp5 -i -v https://sonussbc01.uctestlab.com/rest/transformationtable/2/transformationentry/22 -X PUT --data "Description=Called Number (ALL)&InputField=0&InputFieldValue=(.*)&MatchType=0&OutputField=0&OutputFieldValue=\1" --cacert uctestlab-RootCA-Chain.crt

Bulk importing the transformation table entries

Then if we copy and past the rest command into the command prompt, it should run through we will see an XML output per entries import.

clip_image016

And if we refresh the transformation table we can see the entries

clip_image017

To give you an idea of speed, it took be 4 days to enter 300 transformation table via the WebUI, using the builder I did it in 15 minutes and that was across a WAN.

Have fun, let me know what you think

Leave a Reply