[Asterisk-Dev] Creating Virtual PBX Partitions

Steven Sokol ssokol at sokol-associates.com
Sun Jul 11 10:24:17 MST 2004

Ok, here goes...

I'm working on a simple way to create logical partitions from one or more
Asterisk systems.  Essentially I am building Virtual PBXs (vPBX) by
segmenting the dial plan.  I have run into one annoying issue.  I have to
create a separate [vPBXname_features] context for each vPBX because there is
no way of uniquely identifying the users when activating/deactivating
features.  I really would prefer to be able to simply include a
[standard-features] context in the base context for each vPBX.

The issue comes down to not having a unique identifier for the user making
the call.  Each user is assigned to one of a several contexts that "belong"
to the virtual PBX.  When the user dials a feature code the call drops
through the dial-plan until it hits the [pbxname-internal] context which
includes the [standard-features] context.  In this context is an option to
turn on/off DND, FWD, etc.  However, this presents a problem.  The only
"key" I can use to identify the user/caller in the database (the DB1
Asterisk database) is their Caller ID value.

This doesn't work for two reasons: First, the Caller ID value for vPBX users
is often set to "Company Name" <Main Phone> and is therefore the same for
all employees/users of the vPBX.  The other option is to set the CALLERIDNUM
value to <Exten> so that it has the extension number.  But again you get
overlap as users for vPBX A and vPBX B may both be extension 100.

As I know I have a tendency to drift away from the ONE TRUE PATH of
simplicity, I thought I would everyone you a chance to tell me the error of
my ways.  What strikes you as the best way to introduce a variable for all
User calls that identifies the vPBX to which they belong?

My thought would be to solve this by having Asterisk create a variable for
every call made by a user.  The variable would simply be the username.  For
IAX and SIP this would be fairly straight forward.  For Zap you could simply
use the channel name, since they are static.  (Or you could add a directive
to the zapata.conf file that sets the username.)  I think the same logic
holds for the other VoIP and TDM channels.

With this enhancement, we can use the variable (${USERNAME}) to act as the
unique key when altering feature settings:

exten => *76,1,DBPut(${USERNAME}/DND=1)
exten => *77,1,DBPut(${USERNAME}/DND=0)

Since its easy to set the username to a unique value, we could just use the
username as the identifier for such functions. (I currently have all IAX and
SIP users built as "username#vPBXname".)

A slightly more advanced version of this solution would be to include a
separate vPBX value that can be added to users of all types.  The vPBX value
would become a separate vPBX variable whenever the user makes a call.

exten => *76,1,DBPut(${PBX}/${USERNAME}/DND=1)
exten => *77,1,DBPut(${PBX}/${USERNAME}/DND=0)

Have I drifted away from the path again?  Am I missing some obvious bit of
Asterisk-fu that would send Critchfield into a smoking rage were he to read
this?  Anybody care to guess as to the complexity of making this happen in
the various Channels?



More information about the asterisk-dev mailing list