[freeside-commits] freeside/FS/FS/part_export phone_sqlopensips.pm, 1.1, 1.2
Erik Levinson
levinse at wavetail.420.am
Sat Jan 15 19:34:01 PST 2011
Update of /home/cvs/cvsroot/freeside/FS/FS/part_export
In directory wavetail.420.am:/tmp/cvs-serv31801/FS/FS/part_export
Modified Files:
phone_sqlopensips.pm
Log Message:
OpenSIPS provisioning, RT10993
Index: phone_sqlopensips.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_export/phone_sqlopensips.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- phone_sqlopensips.pm 7 Jan 2011 23:13:58 -0000 1.1
+++ phone_sqlopensips.pm 16 Jan 2011 03:33:59 -0000 1.2
@@ -7,6 +7,7 @@
use FS::part_export;
use FS::svc_phone;
use FS::export_svc;
+use LWP::UserAgent;
@ISA = qw(FS::part_export);
@@ -14,6 +15,7 @@
'datasrc' => { label=>'DBI data source ' },
'username' => { label=>'Database username' },
'password' => { label=>'Database password' },
+ 'xmlrpc_url' => { label=>'XMLRPC URL' },
;
%info = (
@@ -31,10 +33,10 @@
my $sth = $dbh->prepare("insert into dr_rules ".
"( groupid, prefix, timerec, routeid, gwlist, description ) ".
" values ( ?, ?, ?, ?, ?, ? )") or die $dbh->errstr;
- $sth->execute('0',$svc_x->phonenum,'',$svc_x->route,'',
+ $sth->execute('0',$svc_x->phonenum,'',$svc_x->route,$svc_x->gwlist,
$svc_x->phone_name) or die $sth->errstr;
$dbh->disconnect;
- '';
+ $self->dr_reload;
}
sub opensips_connect {
@@ -58,6 +60,11 @@
push @paramvalues, $new->phone_name;
}
+ if($old->gwlist ne $new->gwlist) {
+ push @update, 'gwlist = ?';
+ push @paramvalues, $new->gwlist;
+ }
+
if(scalar(@update)) {
my $update_str = join(' and ', at update);
my $dbh = $self->opensips_connect;
@@ -66,6 +73,7 @@
push @paramvalues, $old->phonenum;
$sth->execute(@paramvalues) or die $sth->errstr;
$dbh->disconnect;
+ return $self->dr_reload;
}
'';
}
@@ -87,6 +95,21 @@
or die $dbh->errstr;
$sth->execute($svc_x->phonenum) or die $sth->errstr;
$dbh->disconnect;
+ $self->dr_reload;
+}
+
+sub dr_reload {
+ my $self = shift;
+ my $reqxml = "<?xml version=\"1.0\"?>
+<methodCall>
+ <methodName>dr_reload</methodName>
+</methodCall>";
+ my $ua = LWP::UserAgent->new;
+ my $resp = $ua->post( $self->option('xmlrpc_url'),
+ Content_Type => 'text/xml',
+ Content => $reqxml );
+ return "invalid HTTP response from OpenSIPS: " . $resp->status_line
+ unless $resp->is_success;
'';
}
More information about the freeside-commits
mailing list