Page 1 of 1

Account-wide global variables and shared code capability

Posted: Thu Nov 20, 2014 9:03 pm
by lpgmt-sysadmin
Hi there,

I'm a new customer of SS. Looks like it's going to suit my needs quite well.

I'm a programmer -- How long because I can't remember ;-) -- just not all that familiar with Ruby and the particular limits (if any) imposed on the Ruby implementation that is customer-facing. My background is Python, C, Pascal, Bash, (and... err... MS Basic, Quickbasic, CP/M Basic on an Osborne 1 at the age of 8.... err am I showinig my age???!!)

I want to head off the development of my Ruby dialplans in the best way possible, so I have the following questions:

1. Is it possible to have account-wide global variables? If so, how? My use case would be to have global variables holding the name(s) of outbound providers for a call to be connected via. By having this in a global, if that provider goes down (or I want to drop them), I can just change the one global variable and all my dialplans will automagically switch to using the new provider.

If globals are not available, what is an alternate way to achieve this? (Perhaps, provisioning a dedicated SS account called "out-primary-1" where all outbound calls are forwarded to, and the outbound DP for that account contains the details of the specific VSP to forward on to. All other outbound dialplans forward to "out-primary-1" instead of any hard-coded URI?)

2. Is there any method to "import" blocks of Ruby code into a DP so that code is not duplicated across multiple DP's? I'm planning to roll SS out for my employer and so I envisage that employee-specific DP's will eventually proliferate and some kind of "import" mechanism (a-la Python) would eliminate the potential administrative nightmare of having to keep duplicates of certain Ruby code blocks up to date over time.

I look forward to any assistance or insight anyone can provide.

Many thanks in advance,

john

Re: Account-wide global variables and shared code capability

Posted: Fri Nov 21, 2014 8:55 am
by Aaron
lpgmt-sysadmin wrote:just not all that familiar with Ruby and the particular limits (if any) imposed on the Ruby implementation that is customer-facing. My background is Python, C, Pascal, Bash, (and... err... MS Basic, Quickbasic, CP/M Basic on an Osborne 1 at the age of 8.... err am I showinig my age???!!)
Basic is where I started, on a BBC Microcomputer System (Model B to be precise). I to have traveled a long progression of different languages and you'll be comforted to know that Ruby is one of the more sensible ones. Here's a good place to get started https://www.ruby-lang.org/en/documentation/quickstart/. As far as limitations of running Ruby within a sipsorcery dialplan you will definitely hit obstacles if you delve into the more esoteric features but a lot of Ruby is supported. Importing external modules (called Gems in Ruby parlance can be done but require sys admin intervention by me). The sipsorcery server uses a flavour or Ruby called IronRuby http://ironruby.net/ if you want to look into the details.
lpgmt-sysadmin wrote:1. Is it possible to have account-wide global variables? If so, how? My use case would be to have global variables holding the name(s) of outbound providers for a call to be connected via. By having this in a global, if that provider goes down (or I want to drop them), I can just change the one global variable and all my dialplans will automagically switch to using the new provider.
Your list of SIP providers are accessible from all your dialplans automatically so you don't need to set up any global variables to hold those. Aside from that you can use the sipsorcery database functions (http://www.sipsorcery.com/mainsite/Help ... s#Database) to store key value pairs that are then available for use across all your dialplans.

If globals are not available, what is an alternate way to achieve this? (Perhaps, provisioning a dedicated SS account called "out-primary-1" where all outbound calls are forwarded to, and the outbound DP for that account contains the details of the specific VSP to forward on to. All other outbound dialplans forward to "out-primary-1" instead of any hard-coded URI?)
lpgmt-sysadmin wrote:2. Is there any method to "import" blocks of Ruby code into a DP so that code is not duplicated across multiple DP's? I'm planning to roll SS out for my employer and so I envisage that employee-specific DP's will eventually proliferate and some kind of "import" mechanism (a-la Python) would eliminate the potential administrative nightmare of having to keep duplicates of certain Ruby code blocks up to date over time.
It turns out it's not that easy to load arbitrary blocks of text into a sipsorcery Ruby dialplan; this request has come up before. It is possible to include a block of Ruby script from a file, ala the Python import, but that would require that file to be stored on the server and therefore it would be problematic to give users access to maintain. Generally the combination of SIP providers being accessible throughout all dialplans and the database key value pairs have meant there is not a huge need for sharing script blocks.

Re: Account-wide global variables and shared code capability

Posted: Mon Nov 24, 2014 10:12 pm
by lpgmt-sysadmin
Dear Aaron,

I'm silenced! That is a very good sign that your response was extremely thorough ;-)

Many thanks for such a detailed response.

All the best,

John