projects
/
freeside.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
RADIUS group attributes, #15017
[freeside.git]
/
FS
/
FS
/
part_export
/
netsapiens.pm
diff --git
a/FS/FS/part_export/netsapiens.pm
b/FS/FS/part_export/netsapiens.pm
index
a1957d4
..
31d16a8
100644
(file)
--- a/
FS/FS/part_export/netsapiens.pm
+++ b/
FS/FS/part_export/netsapiens.pm
@@
-1,12
+1,12
@@
package FS::part_export::netsapiens;
package FS::part_export::netsapiens;
-use vars qw(@ISA %info);
-use URI;
+use vars qw(@ISA $me %info);
use MIME::Base64;
use Tie::IxHash;
use FS::part_export;
@ISA = qw(FS::part_export);
use MIME::Base64;
use Tie::IxHash;
use FS::part_export;
@ISA = qw(FS::part_export);
+$me = '[FS::part_export::netsapiens]';
tie my %options, 'Tie::IxHash',
'login' => { label=>'NetSapiens tac2 User API username' },
tie my %options, 'Tie::IxHash',
'login' => { label=>'NetSapiens tac2 User API username' },
@@
-16,10
+16,11
@@
tie my %options, 'Tie::IxHash',
'device_password' => { label=>'NetSapiens tac2 Device API password' },
'device_url' => { label=>'NetSapiens tac2 Device URL' },
'domain' => { label=>'NetSapiens Domain' },
'device_password' => { label=>'NetSapiens tac2 Device API password' },
'device_url' => { label=>'NetSapiens tac2 Device URL' },
'domain' => { label=>'NetSapiens Domain' },
+ 'debug' => { label=>'Enable debugging', type=>'checkbox' },
;
%info = (
;
%info = (
- 'svc' =>
'svc_phon
e',
+ 'svc' =>
[ 'svc_phone', ], # 'part_devic
e',
'desc' => 'Provision phone numbers to NetSapiens',
'options' => \%options,
'notes' => <<'END'
'desc' => 'Provision phone numbers to NetSapiens',
'options' => \%options,
'notes' => <<'END'
@@
-38,10
+39,10
@@
sub ns_command {
sub ns_device_command {
my $self = shift;
sub ns_device_command {
my $self = shift;
- $self->_ns_command('device', @_);
+ $self->_ns_command('device
_
', @_);
}
}
-sub ns_command {
+sub
_
ns_command {
my( $self, $prefix, $method, $command ) = splice(@_,0,4);
eval 'use REST::Client';
my( $self, $prefix, $method, $command ) = splice(@_,0,4);
eval 'use REST::Client';
@@
-59,6
+60,9
@@
sub ns_command {
$args[0] .= $ns->buildQuery( { @_ } );
}
$args[0] .= $ns->buildQuery( { @_ } );
}
+ warn "$me $method ". $self->option($prefix.'url'). join(', ', @args). "\n"
+ if $self->option('debug');
+
my $auth = encode_base64( $self->option($prefix.'login'). ':'.
$self->option($prefix.'password') );
push @args, { 'Authorization' => "Basic $auth" };
my $auth = encode_base64( $self->option($prefix.'login'). ':'.
$self->option($prefix.'password') );
push @args, { 'Authorization' => "Basic $auth" };
@@
-67,10
+71,15
@@
sub ns_command {
$ns;
}
$ns;
}
+sub ns_domain {
+ my($self, $svc_phone) = (shift, shift);
+ $svc_phone->domain || $self->option('domain');
+}
+
sub ns_subscriber {
my($self, $svc_phone) = (shift, shift);
sub ns_subscriber {
my($self, $svc_phone) = (shift, shift);
- my $domain = $self->
option('domain'
);
+ my $domain = $self->
ns_domain($svc_phone
);
my $phonenum = $svc_phone->phonenum;
"/domains_config/$domain/subscriber_config/$phonenum";
my $phonenum = $svc_phone->phonenum;
"/domains_config/$domain/subscriber_config/$phonenum";
@@
-79,10
+88,6
@@
sub ns_subscriber {
sub ns_registrar {
my($self, $svc_phone) = (shift, shift);
sub ns_registrar {
my($self, $svc_phone) = (shift, shift);
- my $domain = $self->option('domain');
- my $countrycode = $svc_phone->countrycode;
- my $phonenum = $svc_phone->phonenum;
-
$self->ns_subscriber($svc_phone).
'/registrar_config/'. $self->ns_devicename($svc_phone);
}
$self->ns_subscriber($svc_phone).
'/registrar_config/'. $self->ns_devicename($svc_phone);
}
@@
-90,20
+95,22
@@
sub ns_registrar {
sub ns_devicename {
my( $self, $svc_phone ) = (shift, shift);
sub ns_devicename {
my( $self, $svc_phone ) = (shift, shift);
- my $domain = $self->
option('domain'
);
- my $countrycode = $svc_phone->countrycode;
+ my $domain = $self->
ns_domain($svc_phone
);
+
#
my $countrycode = $svc_phone->countrycode;
my $phonenum = $svc_phone->phonenum;
my $phonenum = $svc_phone->phonenum;
- "sip:$countrycode$phonenum@$domain";
+ #"sip:$countrycode$phonenum\@$domain";
+ "sip:$phonenum\@$domain";
}
sub ns_dialplan {
my($self, $svc_phone) = (shift, shift);
}
sub ns_dialplan {
my($self, $svc_phone) = (shift, shift);
- my $countrycode = $svc_phone->countrycode;
+
#
my $countrycode = $svc_phone->countrycode;
my $phonenum = $svc_phone->phonenum;
my $phonenum = $svc_phone->phonenum;
- "/dialplans/DID+Table/dialplan_config/sip:$countrycode$phonenum@*"
+ #"/dialplans/DID+Table/dialplan_config/sip:$countrycode$phonenum\@*"
+ "/domains_config/admin-only/dialplans/DID+Table/dialplan_config/sip:$phonenum\@*,*,*,*,*,*,*";
}
sub ns_device {
}
sub ns_device {
@@
-112,14
+119,14
@@
sub ns_device {
#my $countrycode = $svc_phone->countrycode;
#my $phonenum = $svc_phone->phonenum;
#my $countrycode = $svc_phone->countrycode;
#my $phonenum = $svc_phone->phonenum;
- "/phones_config/".
$phone_device->mac_addr
;
+ "/phones_config/".
lc($phone_device->mac_addr)
;
}
sub ns_create_or_update {
my($self, $svc_phone, $dial_policy) = (shift, shift, shift);
}
sub ns_create_or_update {
my($self, $svc_phone, $dial_policy) = (shift, shift, shift);
- my $domain = $self->
option('domain'
);
- my $countrycode = $svc_phone->countrycode;
+ my $domain = $self->
ns_domain($svc_phone
);
+
#
my $countrycode = $svc_phone->countrycode;
my $phonenum = $svc_phone->phonenum;
my( $firstname, $lastname );
my $phonenum = $svc_phone->phonenum;
my( $firstname, $lastname );
@@
-152,6
+159,7
@@
sub ns_create_or_update {
#Piece 2 - sip device creation
my $ns2 = $self->ns_command( 'PUT', $self->ns_registrar($svc_phone),
#Piece 2 - sip device creation
my $ns2 = $self->ns_command( 'PUT', $self->ns_registrar($svc_phone),
+ 'termination_match' => $self->ns_devicename($svc_phone)
);
if ( $ns2->responseCode !~ /^2/ ) {
);
if ( $ns2->responseCode !~ /^2/ ) {
@@
-162,7
+170,7
@@
sub ns_create_or_update {
#Piece 3 - DID mapping to user
my $ns3 = $self->ns_command( 'PUT', $self->ns_dialplan($svc_phone),
#Piece 3 - DID mapping to user
my $ns3 = $self->ns_command( 'PUT', $self->ns_dialplan($svc_phone),
- 'to_user' => $
countrycode.$
phonenum,
+ 'to_user' => $phonenum,
'to_host' => $domain,
);
'to_host' => $domain,
);
@@
-234,17
+242,15
@@
sub _export_unsuspend {
sub export_device_insert {
my( $self, $svc_phone, $phone_device ) = (shift, shift, shift);
sub export_device_insert {
my( $self, $svc_phone, $phone_device ) = (shift, shift, shift);
-
#my $domain = $self->option('domain'
);
+
my $domain = $self->ns_domain($svc_phone
);
my $countrycode = $svc_phone->countrycode;
my $phonenum = $svc_phone->phonenum;
my $countrycode = $svc_phone->countrycode;
my $phonenum = $svc_phone->phonenum;
- my $device = $self->ns_devicename($svc_phone);
-
my $ns = $self->ns_device_command(
'PUT', $self->ns_device($svc_phone, $phone_device),
'line1_enable' => 'yes',
'device1' => $self->ns_devicename($svc_phone),
my $ns = $self->ns_device_command(
'PUT', $self->ns_device($svc_phone, $phone_device),
'line1_enable' => 'yes',
'device1' => $self->ns_devicename($svc_phone),
- 'line1_ext' => $
countrycode.$
phonenum,
+ 'line1_ext' => $phonenum,
,
#'line2_enable' => 'yes',
#'device2' =>
,
#'line2_enable' => 'yes',
#'device2' =>
@@
-252,7
+258,7
@@
sub export_device_insert {
#'notes' =>
'server' => 'SiPbx',
#'notes' =>
'server' => 'SiPbx',
- 'domain' => $
self->option('domain')
,
+ 'domain' => $
domain
,
'brand' => $phone_device->part_device->devicename,
'brand' => $phone_device->part_device->devicename,
@@
-281,7
+287,6
@@
sub export_device_delete {
'';
'';
-
}
}