generate xml file for FreeSWITCH config

asked 2015-05-26 12:08:07 -0500

pugnacity gravatar image

What is the best way to create a class which in generates a xml file based on the chosen parameter of this define: at the end the XML file should look like this:

<include>
 <gateway name="iprouter">
 <param name="username" value="extvoipgw01"/>
 <param name="realm" value="siprouter.local"/>
 <param name="password" value="secret"/>
 <param name="expire-seconds" value="60"/>
 <param name="caller-id-in-from" value="true"/>
 <param name="ping" value="60"/>
 </gateway>
</include>

The puppet code should be some thing like this:

 freeswitch::sipprofile::gateway{ 'iprouter':
   context  => external,
   params   => { 
    username          => extvoipgw01,
    realm             => siprouter.local,
    password          => secret,
    expire-seconds    => 60
    caller-id-in-from => true,
    ping              => 60,
  }
 }

so far it's sound easy

but how should i handle files like this:

  <include>
   <extension name="0900 numbers">
      <condition regex="any">
        <regex field="destination_number" expression="^([01347]0900\d+)$"/>
          <regex field="destination_number" expression="^(8[0-3]0900\d+)$"/>
      </condition>
        <condition field="caller_id_number" expression="^8910025$|^8904105$">
            <action application="set" data="ignore_display_updates=true"/>
      <action application="bridge" data="{sip_cid_type=none,sip_renegotiate_codec_on_reinvite=true}sofia/gateway/siprouter/$1"/>
      <anti-action application="info"/>
      <anti-action application="hangup" data="CALL_REJECTED"/>
      </condition>
   </extension>
  </include>

where those fields can be, but it's not must

edit retag flag offensive close merge delete