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

Andreas Granig agranig at sipwise.com
Mon Apr 16 17:31:29 EDT 2012


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

-------------- 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/mailman/private/spce-user_lists.sipwise.com/attachments/20120416/a5da5d86/attachment.asc>


More information about the Spce-user mailing list