Here’s a script from the quick & dirty category. Worthy of publishing, but not something I’m going to get around to polishing up to be all-singing and all-dancing.
“Set-UxFxsCountry.ps1” uses Vik Jaswal’s fantastic PowerShell module for the Sonus UX/SBC family of gateways to automate what I reckon has to be the most tedious task of configuring a new gateway – setting the FXS ports to be (in my case) Australia.
Here it is in its entirety:
$list = (get-uxresource -resource "fxscard").fxscard_list if ($list.Count -eq 0) {write-warning "No FXS cards were found"} foreach ($card in $list) { foreach ($cardid in $card.fxscard_pk.id) { for ($i=1; $i -le 4; $i++) { $command = "set-uxresource -resource ""fxscard/$cardid/fxsport/$i"" -args ""Country=1""" try { $response = invoke-expression $command } catch { write-warning "Error caught by handler: $($_)" } } } }
All you need to do is:
- save it to a file
- import the Sonus module
- connect to the gateway
- run the script!
The script will query all of the FXS cards in the gateway and then cycle through ports 1 to 4 on each, setting them (as is coded here) to Australia.
I’ve written and tested this on a 1k, but if you have a 2k, just change the “$i” loop to be “$i -le 24” and you should be good to go.
For other countries, just change the Country from the “1” shown above to the relevant number:
Australia (1), Austria (2), Belgium (3), Brazil (4), China (5), Czech Republic (6), Denmark (7), Finland (8), France (9), Germany (10), Switzerland (11), Greece (12), Hungary (13), India (14), Italy (15), Japan (16), Korea (17), Mexico (18), Netherlands (19), New Zealand (20), Nigeria (21), Norway (22), Portugal (23), Russia (24), Saudi Arabia (25), Slovakia (26), South Africa (27), Spain (28), Sweden (29), Taiwan (30), Turkey (31), United Kingdom (32), United States (33)
There’s more info on the REST interface on the Sonus website: https://support.sonus.net/display/UXDOC60/SBC+Edge+API+User%27s+Guide
Thanks again Vik!
Revision History
9th April 2018. Updated the Sonus REST link.
20th January 2014. This is the initial post.
– G.