Koozali.org: home of the SME Server

Polycom Sip Definition

Offline compsos

  • *
  • 472
  • +0/-0
Polycom Sip Definition
« on: October 27, 2011, 01:58:46 PM »
Hi Jeff
Now that we have had the battle with the 1st line either being blank or including the file name. I am a little curious as to how the generator handles the Polycom Sip definition used in ver 2 and the template in V3. The v2 generator would create individual files for "each" "[ ]" section but V3 just writes a file with the 1st "filename" with everything in it.

The template code from V3
Code: [Select]
["$mac.cfg"
<?xml version="1.0" standalone="yes"?>
<!-- $Revision: 1.14 $  $Date: 2005/07/27 18:43:30 $ -->
<APPLICATION APP_FILE_PATH="sip.ld" CONFIG_FILES="$mac-phone.cfg, polycom-locals.cfg, phone1.cfg, sip.cfg" MISC_FILES="" LOG_FILE_DIRECTORY="" OVERRIDES_DIRECTORY="" CONTACTS_DIRECTORY=""/>
]

["$mac-phone.cfg"
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- $Revision: 1.73.6.2 $  $Date: 2006/07/17 21:46:42 $ -->

<phone$ext>
  <reg
      reg.1.displayName="$desc"
      reg.1.address="$ext"
      reg.1.label="$ext"
      reg.1.auth.userId="$ext"
      reg.1.auth.password="$password"/>
  <reg
</phone$ext>
]

["$mac-directory.xml"
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- $Revision: 1.2 $  $Date: 2004/12/21 18:28:05 $ -->
<directory>
        <item_list>
                <item>
                        <ln>Doe</ln>
                        <fn>John</fn>
                        <ct>1001</ct>
                        <sd>1</sd>
                        <rt>3</rt>
                        <dc/>
                        <ad>0</ad>
                        <ar>0</ar>
                        <bw>0</bw>
                        <bb>0</bb>
                </item>

        </item_list>
</directory>
]
I would think the generator has to check the provisioning code for the number of closing "]" and then do each section in a loop with the filename generation within the loop. What seems to work is to just generate a single $mac.cfg file with no other references to $mac-phone.cfg or phone$ext.cfg. But not sure if it is the right thing to do for Polycom's. Can v3 generator handle larger code than V2? I think that was one of the reasons to make the provisioning  in sections.

Your thoughts?
Regards

Gordon............

Offline SARK devs

  • ****
  • 2,806
  • +1/-0
    • http://sarkpbx.com
Re: Polycom Sip Definition
« Reply #1 on: October 28, 2011, 10:21:20 PM »
HI Gordon

Polycoms work just fine (as does the V2 multiple file construct) .  V3 uses php's "split" to break up the provisioning stream into separate "files" and then it iteratively generates each of them. Look at line 66 in the code.


Kind Regards

Jeff

Offline compsos

  • *
  • 472
  • +0/-0
Re: Polycom Sip Definition
« Reply #2 on: October 29, 2011, 01:05:56 AM »
Hi Jeff
Then the "warning" from php about split being depreciated (we are using 5.3.3 required by zarafa) is not a warning as it is not working.

This is the output of the generated file on 2 different systems
Code: [Select]
<?xml version="1.0" standalone="yes"?>
<!-- $Revision: 1.14 $  $Date: 2005/07/27 18:43:30 $ -->
<APPLICATION APP_FILE_PATH="sip.ld" CONFIG_FILES="mac.cfg, polycom-locals.cfg, phoneext.cfg, sip.cfg, phone1.cfg, 000000000000.cfg" MISC_FILES="" LOG_FILE_DIRECTORY="/log" OVERRIDES_DIRECTORY="/$



<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!-- Example Per-phone Configuration File -->
<!-- $RCSfile: phone1.cfg,v $  $Revision: 1.121.4.11 $ -->
<phoneext>
  <reg reg.1.displayName="Desc"
       reg.1.auth.userId="ext"
       reg.1.address="ext"
       reg.1.label="desc"
       reg.1.auth.password="secret"
       reg.2.displayName="desc"
       reg.2.auth.userId="ext"
       reg.2.address="ext"
       reg.2.label="ext"
       reg.2.auth.password="secret" />
</phoneext>

Note the parts in "" are correct just modified for security.
The PHP 5.3.3 came from update-testing so I guess it is on the way to the updates repo soon.
Should we experiment with the new php code for the split command?
Regards

Gordon............

Offline SARK devs

  • ****
  • 2,806
  • +1/-0
    • http://sarkpbx.com
Re: Polycom Sip Definition
« Reply #3 on: October 29, 2011, 12:27:25 PM »
For each bracketed file in the provisioning stream, the generator creates a file in /tftpboot

here is what it generates on the reference box for a Polycom with MAC 0004f215899a

 [root@fxos ~]# ls -l /tftpboot/0004f215899*
-rwxrwxrwx 1 root root 1183 Oct 28 21:34 /tftpboot/0004f215899a.cfg
-rwxrwxrwx 1 root root 1183 Oct 28 21:34 /tftpboot/0004f215899a-directory.xml
-rwxrwxrwx 1 root root 1183 Oct 28 21:34 /tftpboot/0004f215899a-phone.cfg

Deprecated means that the feature will go in a  future release, split is fine in the current releases of php.

Best

S

Offline compsos

  • *
  • 472
  • +0/-0
Re: Polycom Sip Definition
« Reply #4 on: October 30, 2011, 12:33:08 AM »
Thanks Jeff
Think I am not explaining this well.
Just setup a test extension on an clean system using the standard php 5.2.10. You are right we do get 3 files as expected but the contents look of all 3 are
Code: [Select]
<?xml version="1.0" standalone="yes"?>
<!-- $Revision: 1.14 $  $Date: 2005/07/27 18:43:30 $ -->
<APPLICATION APP_FILE_PATH="sip.ld" CONFIG_FILES="0004f2179387-phone.cfg, polycom-locals.cfg, phone1.cfg, sip.cfg" MISC_FILES="" LOG_FILE_DIRECTORY="" OVERRIDES_DIRECTORY="" CONTACTS_DIRECTORY=""/>

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- $Revision: 1.73.6.2 $  $Date: 2006/07/17 21:46:42 $ -->
<phone5041>
<reg
reg.1.displayName="test"
reg.1.address="5041"
reg.1.label="5041"
reg.1.auth.userId="5041"
reg.1.auth.password="cfr0cSWR"/>
<reg
</phone5041>

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- $Revision: 1.2 $  $Date: 2004/12/21 18:28:05 $ -->
<directory>
<item_list>
<item> <ln>Doe</ln>
<fn>John</fn>
<ct>1001</ct>
<sd>1</sd>
<rt>3</rt>
<dc/>
<ad>0</ad>
<ar>0</ar>
<bw>0</bw>
<bb>0</bb>
</item>
</item_list>
</directory>
And all 3 files contain the same data, where it should be split and into the correct file. The generator does not seem to understand the "sections". When I do a var_dump(), at different parts of the loop (including just before the file close command), I get all the data in the variable as a single lot just like the file.
On your test is the content of each file correct?
« Last Edit: October 30, 2011, 12:37:02 AM by compsos »
Regards

Gordon............

Offline SARK devs

  • ****
  • 2,806
  • +1/-0
    • http://sarkpbx.com
Re: Polycom Sip Definition
« Reply #5 on: October 30, 2011, 10:22:45 PM »
ah ok understand

replace your two patch lines with this

Code: [Select]
$test = preg_replace ( ' /\["(.*)"/ ',"", $thisfile);
$thisfile = trim($test,"\r\n ");

replace the file write (2 lines on) with this

Code: [Select]
fwrite($fh,$thisfile) or die('Could not write to file');
Let me know if it works.

Best

S
« Last Edit: October 30, 2011, 10:24:47 PM by SARK devs »

Offline compsos

  • *
  • 472
  • +0/-0
Re: Polycom Sip Definition
« Reply #6 on: October 30, 2011, 10:37:42 PM »
Hi Jeff

Will that just write out the file twice?
Code: [Select]
                                        fwrite($fh,$thisfile) or die('Could not write to file');  <--This line
                                        //$test = preg_replace ( ' /\["(.*)"/ ',"", $row['provision'] );
                                        //$row['provision'] = trim($test,"\r\n ");
                                        //$row['provision'] = preg_replace ( ' /\["(.*)"\n/ ',"", $row['provision'] );
                                        $fh = fopen($cfgfilename, 'w') or die('Could not open file!');
                                        fwrite($fh,$row['provision']) or die('Could not write to file'); <--- This line
                                        fclose($fh);
Regards

Gordon............

Offline SARK devs

  • ****
  • 2,806
  • +1/-0
    • http://sarkpbx.com
Re: Polycom Sip Definition
« Reply #7 on: October 30, 2011, 10:38:21 PM »
Here is how the stanza should look

Code: [Select]
else {
$test = preg_replace ( ' /\["(.*)"/ ',"", $thisfile);
$thisfile = trim($test,"\r\n ");
$fh = fopen($cfgfilename, 'w') or die('Could not open file!');
fwrite($fh,$thisfile) or die('Could not write to file');
fclose($fh);
}

There is another change required but just test this for me first to see if we agree.
« Last Edit: October 30, 2011, 10:43:39 PM by SARK devs »

Offline compsos

  • *
  • 472
  • +0/-0
Re: Polycom Sip Definition
« Reply #8 on: October 30, 2011, 10:50:44 PM »
Ok that just writes a single file $mac.cfg, but I should reset the system to defaults to remove any of our other tweeks.
Just been called to a factory breakdown so will test and report back later.
As you are about to go off-air any other adjustments you would like us to try?

Regards

Gordon............

Offline SARK devs

  • ****
  • 2,806
  • +1/-0
    • http://sarkpbx.com
Re: Polycom Sip Definition
« Reply #9 on: October 30, 2011, 11:01:55 PM »
I'm off now

I will send you a module tomorrow.  It works correctly here on our Polycom defs.

Kind Regards

S

Offline SARK devs

  • ****
  • 2,806
  • +1/-0
    • http://sarkpbx.com
Re: Polycom Sip Definition
« Reply #10 on: October 30, 2011, 11:05:12 PM »
send me an email  to admin@aelintra.com  and we'll send you the module.

Offline compsos

  • *
  • 472
  • +0/-0
Re: Polycom Sip Definition
« Reply #11 on: October 31, 2011, 03:00:01 PM »
That looks a lot better!!
Jeff are your sure about the Polycom template?

Code: [Select]
["phone$ext.cfg"
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- $Revision: 1.73.6.2 $  $Date: 2006/07/17 21:46:42 $ -->

<phone$ext>
  <reg
      reg.1.displayName="$desc"
      reg.1.address="$ext"
      reg.1.label="$ext"
      reg.1.auth.userId="$ext"
      reg.1.auth.password="$password"/>
 </phone$ext>
]

I took out the "<reg"  before the "</phone>" line as the "/> after $password should close the "<reg" section. Let me know if you think I am wrong.
Regards

Gordon............

Offline SARK devs

  • ****
  • 2,806
  • +1/-0
    • http://sarkpbx.com
Re: Polycom Sip Definition
« Reply #12 on: November 01, 2011, 07:35:07 AM »
yes, I think you are correct, although it does seem to work anyway.

I'll change it in the next rev

Best

S