[Spce-user] fast way to import a few hundred peering rules

Matthew Ogden matthew at tenacit.net
Mon Nov 12 18:12:09 EST 2012


Hi,



I ended up using SOAP as that was also something more up my alley than Perl.



I only had under a thousand, so it was’t impractical via SOAP.



Regards



*From:* spce-user-bounces at lists.sipwise.com [mailto:
spce-user-bounces at lists.sipwise.com] *On Behalf Of *Skyler
*Sent:* 13 November 2012 01:08 AM
*To:* Andreas Granig
*Cc:* spce-user at lists.sipwise.com
*Subject:* Re: [Spce-user] fast way to import a few hundred peering rules



Hi Matthew,



 Did this example help you by chance? I am looking to import 300k or so of
peering rules but Perl is not my strength. I'm thinking if this example
from Andreas is used with loop reading from a CSV it could be very useful
as a tool within SPCE.



 Would you mind sharing your final solution?



Skyler

On Mon, Apr 16, 2012 at 2:35 PM, Andreas Granig <agranig at sipwise.com> wrote:

Ok, actually tried to run it in Perl, here's the syntactically correct
version


#!/usr/bin/perl -w
use strict;
use Sipwise::Provisioning::Voip;
my $prov = Sipwise::Provisioning::Voip->new();
my $params = {

        group_id => 'your peering group id here',

        data => {
                caller_prefix => 'your caller pattern',
                callee_prefix => 'your callee prefix',
                description   => 'your rule description',
        },
};
eval {
        my $res = $prov->handle_request('create_peer_rule', {
                authentication => {
                        type=>'admin',
                        username=>'your admin panel user',
                        password=>'your admin panel pass',
                },
                parameters => $params
        });
};
if($@) {
        if(ref $@ eq 'SOAP::Fault') {
                die "ossbss call failed: ". $@->faultstring;
        } else {
                die "ossbss call failed: $@";
        }
}

Andreas


On 04/16/2012 11:31 PM, Andreas Granig wrote:
> Hi Mattew,
>
> On 04/15/2012 04:50 PM, Matthew Ogden wrote:
>> Where can one find the peering rules config files if you want to import
>> a large number of peering rules into them?
>
> There is no such thing as a config file, the data is stored in MySQL.
> However the intended way is to use either the SOAP interface for mass
> provisioning, or (even faster, but only works directly on the system),
> use the ossbss libs in a perl script, like this (just out of my head,
> really not tested):
>
> #!/usr/bin/perl -w
> use strict;
> use Sipwise::Provisioning::Voip;
> my $prov = Sipwise::Provisioning::Voip->new();
> my $params = {
>       group_id => your peering group id here,
>       data => {
>               caller_prefix => 'your caller pattern',
>               callee_prefix => 'your callee prefix',
>               description   => 'your rule description',
>       },
> };
> eval {
>       my $res = $prov->handle_request('create_peer_rule', {
>               authentication => {
>                       type='admin',
>                       username='your admin panel user',
>                       password='your admin panel pass',
>               },
>               parameters => $params
>       });
> };
> if($@) {
>       if(ref $@ eq 'SOAP::Fault') {
>               die "ossbss call failed: ". $@->faultstring;
>       } else {
>               die "ossbss call failed: $@";
>       }
> }
>
> Adapt (and fix) as needed to work in a loop for all your rules.
>
> Andreas
>
>
>
>

> _______________________________________________
> Spce-user mailing list
> Spce-user at lists.sipwise.com
> http://lists.sipwise.com/listinfo/spce-user


_______________________________________________
Spce-user mailing list
Spce-user at lists.sipwise.com
http://lists.sipwise.com/listinfo/spce-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sipwise.com/pipermail/spce-user_lists.sipwise.com/attachments/20121113/e29f70d6/attachment-0001.html>


More information about the Spce-user mailing list