How to manage Multi-tenant in Asterisk


#1

We are trying to implement multi-tenant asterisk solution with bandwidth.com as sip provider.
Every company(tenant) will have a bandwidth.com account which has all the DID numbers corresponding to that company.

As per the discussion in the below links, there will be separate context in extensions.conf for each company :


Outgoing calls can be configured easily.
Problem is in directing incoming calls to its corresponding context based on DID.

As per this project: https://github.com/irontec/ivozprovider , we figured we can have a DB call from extensions.conf through AGI script to fetch context corresponding to DID.
But there is performance issue as we need to have DB call for each incoming call.

An alternative can be getting the value from cache. We already have sorcery cache for pjsip realtime.
But we don’t know how to retrieve data from this cache through AGI script.

Question: How to retrieve data from sorcery cache? Is the above method preferred? If not,what are the alternate solutions?


#2

You could generate static dialplan that’s updated by an external script in a cron job


#3

Hi @johnkiniston
Thanks for the response. But can you please elaborate on static dialplan and what the external script should be doing? As we are not aware how to implement.


#4

So you can define a context and have it include an external file.

[external]
#include "customer.conf"

Then you create ‘customer.conf’ with your dialplan using your external script

exten => 5551234,1,Playback(tt-monkeys)
 same => n,Hangup()

exten => 5551235,1,Playback(you-sound-cute)
 same => n,Hangup()

Your script could be written in any language you like, just read your data from your database and write it out to your file.