summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlevinse <levinse>2011-01-16 03:34:04 +0000
committerlevinse <levinse>2011-01-16 03:34:04 +0000
commit9926da3bbc4ef46dfcc686644b4fdccded44e545 (patch)
tree20be01a13a80d5ff16a29e16fbe44835ad0b22c8
parent490098bc286345648d6c6c866b10a89d365b68a3 (diff)
OpenSIPS provisioning, RT10993
-rw-r--r--FS/FS/Schema.pm1
-rw-r--r--FS/FS/part_export/phone_sqlopensips.pm29
-rw-r--r--FS/FS/svc_phone.pm6
-rw-r--r--httemplate/edit/svc_phone.cgi1
-rw-r--r--httemplate/view/svc_phone.cgi2
5 files changed, 35 insertions, 4 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 979a5f7cf..af38878ba 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -2774,6 +2774,7 @@ sub tables_hashref {
'domsvc', 'int', 'NULL', '', '', '',
'locationnum', 'int', 'NULL', '', '', '',
'route', 'varchar', 'NULL', $char_d, '', '',
+ 'gwlist', 'varchar', 'NULL', $char_d, '', '',
'forwarddst', 'varchar', 'NULL', 15, '', '',
'email', 'varchar', 'NULL', 255, '', '',
'lnp_status', 'varchar', 'NULL', $char_d, '', '',
diff --git a/FS/FS/part_export/phone_sqlopensips.pm b/FS/FS/part_export/phone_sqlopensips.pm
index 8a3d3a17b..cb644a0a1 100644
--- a/FS/FS/part_export/phone_sqlopensips.pm
+++ b/FS/FS/part_export/phone_sqlopensips.pm
@@ -7,6 +7,7 @@ use FS::Record qw( dbh qsearch qsearchs );
use FS::part_export;
use FS::svc_phone;
use FS::export_svc;
+use LWP::UserAgent;
@ISA = qw(FS::part_export);
@@ -14,6 +15,7 @@ tie %options, 'Tie::IxHash',
'datasrc' => { label=>'DBI data source ' },
'username' => { label=>'Database username' },
'password' => { label=>'Database password' },
+ 'xmlrpc_url' => { label=>'XMLRPC URL' },
;
%info = (
@@ -31,10 +33,10 @@ sub _export_insert {
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 @@ sub _export_replace {
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 ',@update);
my $dbh = $self->opensips_connect;
@@ -66,6 +73,7 @@ sub _export_replace {
push @paramvalues, $old->phonenum;
$sth->execute(@paramvalues) or die $sth->errstr;
$dbh->disconnect;
+ return $self->dr_reload;
}
'';
}
@@ -87,6 +95,21 @@ sub _export_delete {
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;
+ '';
}
diff --git a/FS/FS/svc_phone.pm b/FS/FS/svc_phone.pm
index cffe1e3f6..deb12c29a 100644
--- a/FS/FS/svc_phone.pm
+++ b/FS/FS/svc_phone.pm
@@ -83,6 +83,10 @@ Optional svcnum from svc_pbx
Route id/number
+=item gwlist
+
+OpenSIPS dr_rules gwlist - OpenSIPS dynamic routing
+
=item forwarddst
Forwarding destination
@@ -178,6 +182,7 @@ sub table_info {
'route' => { label => 'Route',
%dis2,
},
+ 'gwlist' => { label => 'OpenSIPS gwlist', %dis2 },
'forwarddst' => { label => 'Forward Destination',
%dis2,
},
@@ -478,6 +483,7 @@ sub check {
|| $self->ut_foreign_keyn('domsvc', 'svc_domain', 'svcnum' )
|| $self->ut_foreign_keyn('locationnum', 'cust_location', 'locationnum')
|| $self->ut_textn('route')
+ || $self->ut_textn('gwlist')
|| $self->ut_numbern('forwarddst')
|| $self->ut_textn('email')
|| $self->ut_numbern('lrn')
diff --git a/httemplate/edit/svc_phone.cgi b/httemplate/edit/svc_phone.cgi
index 1623ed38a..f542ec216 100644
--- a/httemplate/edit/svc_phone.cgi
+++ b/httemplate/edit/svc_phone.cgi
@@ -38,6 +38,7 @@ push @fields, { field => 'pbxsvc',
maxlength => $conf->config('svc_phone-phone_name-max_length'),
},
'route',
+ 'gwlist',
'forwarddst',
'email',
diff --git a/httemplate/view/svc_phone.cgi b/httemplate/view/svc_phone.cgi
index 7b0ea7071..433ea1761 100644
--- a/httemplate/view/svc_phone.cgi
+++ b/httemplate/view/svc_phone.cgi
@@ -19,7 +19,7 @@ my %labels = map { $_ => ( ref($fields->{$_})
my @fields = qw( countrycode phonenum );
push @fields, 'domain' if $conf->exists('svc_phone-domain');
-push @fields, qw( pbx_title sip_password pin phone_name route forwarddst email );
+push @fields, qw( pbx_title sip_password pin phone_name route gwlist forwarddst email );
if ( $conf->exists('svc_phone-lnp') ) {
push @fields, 'lnp_status',