Todd Fulton
2008-Aug-15 00:53 UTC
[asterisk-users] asterisk realtime and creating "new" contexts
<html><body><font color="#000000"><font size="2"><font face="verdana,geneva">Hi,<br><br>I'm trying to create a multi-tennant asterisk installation .... where each of my customers has its own context. Well, I've got asterisk realtime working, and I can add/update extensions to existing contexts in extensions.conf without a problem. However, when I attempt to create database entries with a context that is NOT in extensions.conf, I get an error "invalid extension".<br><br>I've found several posts around the net asking this question, but no answers. Has anyone out there dealt with this problem?<br><br>Any help would be great!<br><br><br>Todd<br></font></font></font></body></html>
Saul Bejarano
2008-Aug-15 02:55 UTC
[asterisk-users] asterisk realtime and creating "new" contexts
By using the standard FreePBX you have all the work done, from that point you just have to enter the information on Mysql: mysql> use asterisk; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> show tables; +---------------------+ | Tables_in_asterisk | +---------------------+ | Backup | | admin | | ampusers | | announcement | | callback | | cidlookup | | cidlookup_incoming | | cronmanager | | custom_destinations | | custom_extensions | | customerdb | | daynight | | devices | | disa | | extensions | | featurecodes | | findmefollow | | freepbx_log | | gabcast | | globals | | iax | | incoming | | inventorydb | | ivr | | ivr_dests | | languages | | manager | | meetme | | miscapps | | miscdests | | module_xml | | modules | | notifications | | paging_autoanswer | | paging_config | | paging_groups | | parkinglot | | phpagiconf | | pinsets | | queues_config | | queues_details | | recordings | | ringgroups | | sip | | timeconditions | | users | | vmblast | | vmblast_groups | | zap | | zapchandids | +---------------------+ 50 rows in set (0.00 sec) The table that will handle your extensions will be SIP not extensions, Extensions will handle the dial plan for outbound dialing: mysql> select * from sip where id=1418 -> ; +------+-------------+---------------+-------+ | id | keyword | data | flags | +------+-------------+---------------+-------+ | 1418 | account | 1418 | 0 | | 1418 | accountcode | | 0 | | 1418 | allow | | 0 | | 1418 | callerid | device <1418> | 0 | | 1418 | callgroup | | 0 | | 1418 | canreinvite | no | 0 | | 1418 | context | from-internal | 0 | | 1418 | dial | SIP/1418 | 0 | | 1418 | disallow | | 0 | | 1418 | dtmfmode | rfc2833 | 0 | | 1418 | host | dynamic | 0 | | 1418 | mailbox | 1418 at device | 0 | | 1418 | nat | yes | 0 | | 1418 | pickupgroup | | 0 | | 1418 | port | 5060 | 0 | | 1418 | qualify | yes | 0 | | 1418 | record_in | Adhoc | 0 | | 1418 | record_out | Adhoc | 0 | | 1418 | secret | 12524674 | 0 | | 1418 | type | friend | 0 | +------+-------------+---------------+-------+ 20 rows in set (0.00 sec) This method is great because you can customize not only the information that you are writing to create the extensions but the information that you allow your customer to modify to manage features like follow me, forwarding, etc. Saul Bejarano Todd Fulton wrote:> Hi, > > I'm trying to create a multi-tennant asterisk installation .... where > each of my customers has its own context. Well, I've got asterisk > realtime working, and I can add/update extensions to existing contexts > in extensions.conf without a problem. However, when I attempt to create > database entries with a context that is NOT in extensions.conf, I get an > error "invalid extension". > > I've found several posts around the net asking this question, but no > answers. Has anyone out there dealt with this problem? > > Any help would be great! > > > Todd > > > ------------------------------------------------------------------------ > > _______________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > AstriCon 2008 - September 22 - 25 Phoenix, Arizona > Register Now: http://www.astricon.net > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users
Saul Bejarano
2008-Aug-15 03:01 UTC
[asterisk-users] asterisk realtime and creating "new" contexts
The VMX-CONTEXT can be managed from database mysql> select * from globals; But you will have to specify the same on each extension under sip once the extension under table sip is the one that calls the CONTEXT to route the call. | PARKNOTIFY | SIP/200 | | RECORDEXTEN | "" | | RINGTIMER | 15 | | DIRECTORY | last | | AFTER_INCOMING | | | IN_OVERRIDE | forcereghours | | REGTIME | 7:55-17:05 | | REGDAYS | mon-fri | | DIRECTORY_OPTS | | | DIALOUTIDS | 1/2/3/4/5/6/ | | OUT_1 | ZAP/g0 | | VM_PREFIX | * | | VM_OPTS | | | VM_GAIN | | | VM_DDTYPE | u | | TIMEFORMAT | kM | | TONEZONE | us | | ALLOW_SIP_ANON | yes | | VMX_CONTEXT | from-internal It will make it sort of complicated thought because it was build to be the generic element routing the calls out of the SIP Registrar, by having individual Context what you are trying to do is partition one Asterisk box to function as multiple offering invidual termination to each one of your users or complete management of a virtual slice of the box :) Todd Fulton wrote:> Hi, > > I'm trying to create a multi-tennant asterisk installation .... where > each of my customers has its own context. Well, I've got asterisk > realtime working, and I can add/update extensions to existing contexts > in extensions.conf without a problem. However, when I attempt to create > database entries with a context that is NOT in extensions.conf, I get an > error "invalid extension". > > I've found several posts around the net asking this question, but no > answers. Has anyone out there dealt with this problem? > > Any help would be great! > > > Todd > > > ------------------------------------------------------------------------ > > _______________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > AstriCon 2008 - September 22 - 25 Phoenix, Arizona > Register Now: http://www.astricon.net > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users
Todd Fulton
2008-Aug-15 08:36 UTC
[asterisk-users] asterisk realtime and creating "new" contexts
<html><body><span style="color: rgb(0, 0, 0);"><font size="2"><span style="font-family: verdana,geneva;">hi saul,<br><br>could you give me more info on the "VMX-CONTEXT" concept? i tried to google it, but could find nothing.<br><br>i am trying to do exactly what you state in terms of creating a virtual slice of the box for each user. thanks!<br><br><br>todd<br></span></font></span><br> <blockquote webmail="1" style="border-left: 2px solid blue; margin-left: 8px; padding-left: 8px;"> -------- Original Message --------<br> Subject: Re: [asterisk-users] asterisk realtime and creating "new"<br> contexts<br> From: Saul Bejarano <saul@procomm100.com><br> Date: Thu, August 14, 2008 8:01 pm<br> To: asterisk-users@lists.digium.com<br> <br> <br> The VMX-CONTEXT can be managed from database<br> <br> mysql> select * from globals;<br> But you will have to specify the same on each extension under sip<br> once the extension under table sip is the one that calls the CONTEXT to <br> route the call.<br> <br> | PARKNOTIFY | SIP/200 |<br> | RECORDEXTEN | "" |<br> | RINGTIMER | 15 |<br> | DIRECTORY | last |<br> | AFTER_INCOMING | |<br> | IN_OVERRIDE | forcereghours |<br> | REGTIME | 7:55-17:05 |<br> | REGDAYS | mon-fri |<br> | DIRECTORY_OPTS | |<br> | DIALOUTIDS | 1/2/3/4/5/6/ |<br> | OUT_1 | ZAP/g0 |<br> | VM_PREFIX | * |<br> | VM_OPTS | |<br> | VM_GAIN | |<br> | VM_DDTYPE | u |<br> | TIMEFORMAT | kM |<br> | TONEZONE | us |<br> | ALLOW_SIP_ANON | yes |<br> | VMX_CONTEXT | from-internal<br> <br> It will make it sort of complicated thought because it was build to be <br> the generic element routing the calls out of the SIP Registrar, by <br> having individual Context what you are trying to do is partition one <br> Asterisk box to function as multiple offering invidual termination to <br> each one of your users or complete management of a virtual slice of the <br> box :)<br> <br> Todd Fulton wrote:<br>> Hi,<br> > <br> > I'm trying to create a multi-tennant asterisk installation .... where <br> > each of my customers has its own context. Well, I've got asterisk <br> > realtime working, and I can add/update extensions to existing contexts <br> > in extensions.conf without a problem. However, when I attempt to create <br> > database entries with a context that is NOT in extensions.conf, I get an <br> > error "invalid extension".<br> > <br> > I've found several posts around the net asking this question, but no <br> > answers. Has anyone out there dealt with this problem?<br> > <br> > Any help would be great!<br> > <br> > <br> > Todd<br> > <br> > <br> > ------------------------------------------------------------------------<br> > <br> > _______________________________________________<br> > -- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" target="_blank" mce_href="http://www.api-digital.com">http://www.api-digital.com</a> --<br> > <br> > AstriCon 2008 - September 22 - 25 Phoenix, Arizona<br> > Register Now: <a href="http://www.astricon.net" target="_blank" mce_href="http://www.astricon.net">http://www.astricon.net</a><br> > <br> > asterisk-users mailing list<br> > To UNSUBSCRIBE or update options visit:<br> > <a href="http://lists.digium.com/mailman/listinfo/asterisk-users" target="_blank" mce_href="http://lists.digium.com/mailman/listinfo/asterisk-users">http://lists.digium.com/mailman/listinfo/asterisk-users</a><br><br> <br> _______________________________________________<br> -- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" target="_blank" mce_href="http://www.api-digital.com">http://www.api-digital.com</a> --<br> <br> AstriCon 2008 - September 22 - 25 Phoenix, Arizona<br> Register Now: <a href="http://www.astricon.net" target="_blank" mce_href="http://www.astricon.net">http://www.astricon.net</a><br> <br> asterisk-users mailing list<br> To UNSUBSCRIBE or update options visit:<br> <a href="http://lists.digium.com/mailman/listinfo/asterisk-users" target="_blank" mce_href="http://lists.digium.com/mailman/listinfo/asterisk-users">http://lists.digium.com/mailman/listinfo/asterisk-users</a><br> </blockquote></body></html>
Mike Clark
2008-Aug-15 11:49 UTC
[asterisk-users] asterisk realtime and creating "new" contexts
Todd Fulton wrote:> Hi, > > I'm trying to create a multi-tennant asterisk installation .... where > each of my customers has its own context. Well, I've got asterisk > realtime working, and I can add/update extensions to existing contexts > in extensions.conf without a problem. However, when I attempt to > create database entries with a context that is NOT in extensions.conf, > I get an error "invalid extension". > > I've found several posts around the net asking this question, but no > answers. Has anyone out there dealt with this problem? > > Any help would be great! > > > Todd >Todd: Unfortunately, new contexts don't seem to show up in "real time". I solved this in RAGUI by putting #exec statements in the extensions.cong file that scan the extensions table and generate the proper contexts. However, you still have to do a reload to get the contexts to be available in Asterisk. Here is an example: in extensions.conf #exec /opt/pointcall/asterisk/scripts/load_extensions.rb I used Ruby, but it could be Perl , PHP or whatever load_extensions.rb #!/usr/local/bin/ruby # require 'mysql' hostname = "host" username = "user" password = "pass" database = "rtdb" my = Mysql.new(hostname, username, password, database) res = my.query("SELECT DISTINCT context FROM extensions ORDER by context") # res.each do |row| context = row[0] print "\n" print '[' + context + "]\n" print "Switch => Realtime/" + context + "\n" end Thanks, Mike
Todd Fulton
2008-Aug-15 13:26 UTC
[asterisk-users] asterisk realtime and creating "new" contexts
<html><body><font style="" color="#000000"><font size="2"><font style="font-family: verdana,geneva;" face="verdana,geneva"><font style="" color="#000000"><font style="font-family: verdana,geneva;" face="verdana,geneva">thanks! this definitely helps. </font></font></font></font></font>now, i'm trying to think of a way to make this happen on multiple asterisk nodes at once. <br><br>i really wish realtime would simply read new contexts from the db. i know that the dialplan is core to the system, but i think this core aspect should be ultimately configurable from a database using realtime. sigh.....<br><br><br>todd <br><br> <blockquote webmail="1" style="border-left: 2px solid blue; margin-left: 8px; padding-left: 8px;"> -------- Original Message --------<br> Subject: Re: [asterisk-users] asterisk realtime and creating "new"<br> contexts<br> From: Mike Clark <mike@infoanywhere.com><br> Date: Fri, August 15, 2008 4:49 am<br> To: Asterisk Users Mailing List - Non-Commercial Discussion<br> <asterisk-users@lists.digium.com><br> <br> <br> Todd Fulton wrote:<br>> Hi,<br> ><br> > I'm trying to create a multi-tennant asterisk installation .... where <br> > each of my customers has its own context. Well, I've got asterisk <br> > realtime working, and I can add/update extensions to existing contexts <br> > in extensions.conf without a problem. However, when I attempt to <br> > create database entries with a context that is NOT in extensions.conf, <br> > I get an error "invalid extension".<br> ><br> > I've found several posts around the net asking this question, but no <br> > answers. Has anyone out there dealt with this problem?<br> ><br> > Any help would be great!<br> ><br> ><br> > Todd<br> ><br>Todd:<br> <br> Unfortunately, new contexts don't seem to show up in "real time". I <br> solved this in RAGUI by putting #exec statements in the extensions.cong <br> file that scan the extensions table and generate the proper contexts. <br> However, you still have to do a reload to get the contexts to be <br> available in Asterisk.<br> <br> Here is an example:<br> <br> in extensions.conf<br> <br> #exec /opt/pointcall/asterisk/scripts/load_extensions.rb<br> <br> I used Ruby, but it could be Perl , PHP or whatever<br> <br> load_extensions.rb<br> <br> #!/usr/local/bin/ruby<br> #<br> <br> require 'mysql'<br> <br> hostname = "host"<br> username = "user"<br> password = "pass"<br> database = "rtdb"<br> <br> my = Mysql.new(hostname, username, password, database)<br> <br> res = my.query("SELECT DISTINCT context FROM extensions ORDER by context")<br> #<br> res.each do |row|<br> context = row[0]<br> print "\n"<br> print '[' + context + "]\n"<br> print "Switch => Realtime/" + context + "\n"<br> end<br> <br> <br> Thanks,<br> <br> Mike<br> <br> _______________________________________________<br> -- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" target="_blank" mce_href="http://www.api-digital.com">http://www.api-digital.com</a> --<br> <br> AstriCon 2008 - September 22 - 25 Phoenix, Arizona<br> Register Now: <a href="http://www.astricon.net" target="_blank" mce_href="http://www.astricon.net">http://www.astricon.net</a><br> <br> asterisk-users mailing list<br> To UNSUBSCRIBE or update options visit:<br> <a href="http://lists.digium.com/mailman/listinfo/asterisk-users" target="_blank" mce_href="http://lists.digium.com/mailman/listinfo/asterisk-users">http://lists.digium.com/mailman/listinfo/asterisk-users</a><br> </blockquote></body></html>