Multi tenants issue (again?)

Hi, I’m trying to rewrite FreePBX to support Multi-tenant. I read the milestone of Freepbx, and notice that the program won’t support Multi- tenants soon (3.0 won’t, too).
My idea is extract 2 first number of extension number, and use that to seperate the context. For e.g, company A want an extension that can be called locally with number 100, so I’ll create a regular extension (like Freepbx usually create) number 10100 (10 is the company code). For company, number 100 will be extension 11100 (11 is the tenant code). I also change the context in table sip (or zap) to “from-internal-10” (with device = 10100) and “from-internal-11” (with device = 11100). After that, just rewrite the all the get_config() function from modules I want to be seperate. For e.g
Normally:
$ext->add($context, $extension, $priority, $application);
Will be re-write to
$ext->add(‘context-’.substring($context.’-’.substring($extension, 0, 2), substring($extension, 2) , $priority, $application);

I also need to re-write the context and extension in $application, if they exist.

That’s my idea. Any suggestion?
Sorry for my poor writing.

Unfortunately there is way more than that involved in making it multi-tenant. Once you start digging into the code and some of the more complex features, you will find that the task gets pretty complicated pretty quickly.

with custom context you could easily adopt a multi tenant scenario (I did one with 4 tenants).

setup:
Trunk-1: 1000 ctxt-A
Trunk-2: 2000 ctxt-B
Trunk-3: 3000 ctxt-C
Trunk-4: 4000 ctxt-D

I have ring groups for each trunk line.

Everything workfine user dial-out on their number and incoming calls to to the right ring group.

The only issue is:

When for example ring group1 rings and the call is forwarded it always uses trunk-1 to go out…even that custom context is not allowed to use it (but I guess the system does the forward and not the user).

Jay,
your forwarding issue is just one example of the complexities that need to be considered, and try the transfer scenario also, you will run into similar issues.

Yes, I’ve been digging into the code for 2 weeks. Quite complicated, as I don’t usually programming in PHP. :frowning:
The main problem with Customcontext is, if I want to provide a company an extension like 100, I couldn’t allow another extension 100 in another company. So, I have to use 10100 and 11100 instead, and then re-construct the dialplan and separate them by context.

the hard part is not really the php so much (although that will all have to be dealt with), it’s the actual dialplan construction that would be needed (and then all the code to manage it).

The parking lot is also an issue. A patch exists for Asterisk that allows multiple parking lots. They have to be specified on a per extension basis.

Scott

At least, I have complete the minimum function: allow internal call and voicemail in tenant extensions. But the mailbox is not very “pretty”, e.g 10100@default or 11100@default instead of 100@10 and 100@11. The voicemail need to be unique to be usable by throughout the dialplan.
Is there anyone doing similar project? I’d like to co-operate with them.

QiS,

We have multiple (small business) tenants using Customcontexts and a specific dialing plan that we assign to clients. We hand out extensions in the 50 block numbers and give out more if we need to. This works well, especially since we have a web-enabled database front-end to the phone provisioning so that we can update the phone’s dialing plan to only be able to dial the appropriate extensions. We also set voicemail contexts to be company names and have modified the ARI code so that forwarding cannot occur between different contexts.

Combined with customcontext and the fact that we’re dealing with companies that are happy to have us tell them their extensions (instead of them telling us) and it works well.

True multi-tenant capabilities must be addressed (parking lots, call forward trunking issues and other things) before FreePBX is truly capable in this arena, but I love FreePBX and all the work that’s been done on it, and support it fully.

Feel free to contact me to discuss what we’ve done to see if it can help you.

Asterisk is certainly not the good choice for such a high complexity project.

Freeswitch would certainly be more friendly. Multiple parking lots are supported and advanced things like BLF and custom devices states are easier to program.

For such big projects, i think that Asterisk is definitely not the Answer because of the amount of work needed to adapt it.

Asterisk scaling, reliability and code uniformity is a problem as well for high call volumes and big systems. Asterisk does not give a clear migration path.

Each time a new version is out, there are lots of compatibility problems. This give a lot of work to programmers to re-enable previous custom applications.

I would be happy to see a community starting a FreePBX project for Freeswitch. Should be a very interesting story.

Olivier.

I have done a patch for that. It’s not easy at all, but at least now I could separate the following functions:

  • Extension: Except an additional prefix each client should use to register to the server, like CompanyA100, or CompanyB200, the end user in each company can use number like 100 or 200 to reach CompanyA100 or CompanyB200 account.
  • Outbound Routes: We don’t use custom context for this case. Instead, we fix up the core modules, to provide a complete separate set of outbound routes and trunks for each company use the PBX box.
  • IVR : Every company can have their own set of IVR.
  • Inter-company contact : yes, if you implement the IP box in a building or some small network, as my estimation, it can support 300+ users to interact with each other freely. If you work for company A, and want to call to company B operators, there’s no need to use DID number: just press the feature code, and you’ll be in the system IVR, which permit a call transfer to other company using the same PBX box.
  • Follow me, Ringgroups, Voicemail, Blacklist, Recordings : minor features for every one. We’re trying to implement call parking using valetparking, or wait for 1.6 release, with multiple parkinglot and fully g729 support.
  • FOP for each company.
  • Separate call records. We’re trying to implement the call billing interface as well.
    You can view our demo site at http://hahuubinh.no-ip.org
    Company 1 : DEMO — username: demo — password: demo
    Company 1 : DEM — username: demo2 — password: demo2

We have asterisk setup in two seperate Jails on freBSD
So 2 seperate asterisk/ freepbx on the same box with their own IP address.
Then some custom context, extensions, IAX trunks between them
originally setup 3 jails then moved 1 to New York, the other was planed to move to Australia
All lines are VoIP so no zap issues (1 zap line comes in via ATA adapter.
using app_conference because it does not require a timing device, so no zapdummy either.

Works well

Robin

Dingtrung,
I tried your demo url, http://hahuubinh.no-ip.org and it is working. Cannot be found. Do you have a live demo? Is it working for you? do you have a patch on freepbx’s website?

Sorry, this site is just a demo site my partner gave me. I’ll set up a new one in our system. I’m trying to convince my boss to give the project Open source asap… It will take some time.
The new site will use Asterisk 1.6. Many bugs has been fixed recently.
Will update this thread asap.

Okay, I have migrate the server to this IP :
http://72.37.213.120

This is just a test server, with very little hardware resources, but still suitable for testing purpose.

I have created 2 administrators for 2 separate tenants, with similar tenant code and extension range.

User demo (with password = demo) can create and configure extensions, ring groups, queues … in range 100 to 110. His tenant have the code DEMO.

User demoo (with password = demoo) can create and configure extensions in range 105 to 115. His tenant code is DEMOO.

The tenant code is the prefix added to extension number when register phone with the system. For example, demo/demo create extension 101, so the softphone must register with asterisk by “DEMO100”. The same for demoo/demoo : use DEMOO106 to register with extension 106. DEMOO106 can call DEMOO108 by press only 108 in his softphone.

Right now, this system is support G729 and G723.

dinhtrung,
excellent job. I took a quite look at your new demo web site and it looks like you have solved the problem with multi-tenants uses same extensions.

The thing your coding will be excellent for the open source community.

Hi, I was not able to check your demo but my interest is if this multi tenant version does support call transfers and call forward and follow me. I mean will it take the extension context to establish a call ending up using the correct trunk for a blind call transfer.