[asterisk-dev] [Code Review] 4190: res_pjsip_config_wizard: Allow streamlined configuration of common pjsip scenarios

George Joseph reviewboard at asterisk.org
Mon Dec 8 11:00:16 CST 2014



> On Dec. 8, 2014, 5:52 a.m., Joshua Colp wrote:
> > branches/12/res/res_pjsip_config_wizard.c, lines 781-811
> > <https://reviewboard.asterisk.org/r/4190/diff/3/?file=69442#file69442line781>
> >
> >     This is a roundabout way to do this.
> >     
> >     Why not have an API function like apply_wizard_mapping that returns the wizard and wizard_data?
> >     
> >     How does this impact ordering? Where does this get placed in the wizard order? Is it at the start, at the end, etc.

I was trying to minimize the changes to sorcery.  The existing apply_wizard_mapping creates the object type if it doesn't exist, adds the wizard to it, then returns FAIL, DUPLICATE or SUCCESS.  I could have split it up or cloned it but the wizard observer did the trick.

object_types->wizards is a list and since the mapping is done as a result of the object type register, the new wizard would get appended after all others.


- George


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/4190/#review13911
-----------------------------------------------------------


On Dec. 3, 2014, 4:42 p.m., George Joseph wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/4190/
> -----------------------------------------------------------
> 
> (Updated Dec. 3, 2014, 4:42 p.m.)
> 
> 
> Review request for Asterisk Developers, Joshua Colp and Mark Michelson.
> 
> 
> Repository: Asterisk
> 
> 
> Description
> -------
> 
> The PJSIP Configuration Wizard allows for creation of simple pjsip scenarios like phone or trunk without having to directly specify individual endpoints, aors, auths, identifies or registrations.  The easiest way to demonstrate this is with an example or two from pjsip_wizard.conf.sample...
> 
> ;============EXAMPLE WIZARD CONFIGURATION FOR A PHONE=======================
> 
> ; This config would create an endpoint, aor with dynamic contact, inbound
> ; auth and a phoneprov object.
> 
> [myphone]
> type = wizard
> accepts_auth = yes
> accepts_registrations = yes
> transport = ipv4
> has_phoneprov = yes
> aor/max_contacts = 1
> inbound_auth/username = testname
> inbound_auth/password = test password
> endpoint/allow = ulaw
> endpoint/context = default
> phoneprov/MAC = 001122aa4455
> phoneprov/PROFILE = profile1
> 
> ;============EXAMPLE WIZARD CONFIGURATION FOR AN ITSP TRUNK=================
> 
> ; This ITSP has 2 servers available and requires registration.
> 
> ; This config would create an endpoint, an aor with 2 static contacts, an outbound
> ; auth, an identify with 2 matches, and 2 registrations.
> 
> [mytrunk]
> type = wizard
> sends_auth = yes
> sends_registrations = yes
> transport = ipv4
> ; The number of remote_hosts drives the number of contacts, matches and registrations.
> remote_hosts = sip1.myitsp.com:5060,sip2.myitsp.com:5060
> outbound_auth/username = testname
> outbound_auth/password = test password
> endpoint/allow = ulaw
> endpoint/context = default
> 
> pjsip_wizard.conf.sample has more details.
> 
> The history of the wizard approach can be found in the following 2 threads...
> 
> http://lists.digium.com/pipermail/asterisk-dev/2014-September/070426.html
> http://lists.digium.com/pipermail/asterisk-dev/2014-October/070616.html
> 
> THEORY OF OPERATION:
> 
> Load sequence...
> * Register as an ast_sorcery_global_observer.
> * When notified that res_pjsip has opened a sorcery instance, register as an ast_sorcery_instance_observer for res_pjsip.
> * When notified that an object_type has been registered, call ast_sorcery_apply_wizard_mapping to add a memory wizard to the object type.
> * When notified that the memory wizard has been mapped, save its callbacks for later use.
> * When notified that an object type has been loaded or reloaded, parse pjsip_wizard.conf (detecting adds, changed and deletes), create, replace or delete the object types from the wizard definitions and add them to the memory wizard using the callbacks saved in the previous step.
> 
> RELOADABILITY:
> 
> The new module itself cannot be reloaded or unloaded but there's no point to that anyway.  'core reload' and 'module reload res_pjsip' work quite well though which is much more important.  'core reload' is the preferred reload mechanism over reloading specific pjsip modules because it reloads all modules so modules such as res_pjsip_outbound_registration know to start registration for newly discovered objects.  
> 
> BACKWARDS COMPATIBILITY:
> 
> This module does not change any existing functionality.  Once created by the wizard, pjsip objects are indistinguishable from ones created discretely other than the addition of the '@pjsip_wizard' attribute.
> 
> OTHER:
> 
> This module does not use sorcery to read its pjsip_wizard.conf file.  Since this module implements a sorcery wizard, doing so would have created 'chicken and egg' scenarios which would have been complex to solve.  It does use the standard config mechanism though so you can use extconfig.conf to get the config from an external source.
> 
> res_pjsip_phoneprov_provider needed a little rearranging to work with the wizard.  No other modules were modified.
> 
> 
> Diffs
> -----
> 
>   branches/12/res/res_pjsip_phoneprov_provider.c 428944 
>   branches/12/res/res_pjsip_config_wizard.c PRE-CREATION 
>   branches/12/configs/pjsip_wizard.conf.sample PRE-CREATION 
> 
> Diff: https://reviewboard.asterisk.org/r/4190/diff/
> 
> 
> Testing
> -------
> 
> Test suite tests are available that use the wizard to create objects and AMI to read the results.  The results are indistinguishable except the for '@pjsip_wizard' attribute.
> 
> I've converted my own PBX to use the wizard approach and phones and trunks operate normally.
> 
> 
> Thanks,
> 
> George Joseph
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20141208/2eaef0af/attachment-0001.html>


More information about the asterisk-dev mailing list