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

Andreas Granig agranig at sipwise.com
Mon Apr 16 17:35:26 EDT 2012


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 900 bytes
Desc: OpenPGP digital signature
URL: <http://lists.sipwise.com/pipermail/spce-user_lists.sipwise.com/attachments/20120416/7680663a/attachment-0001.asc>


More information about the Spce-user mailing list