+ fixed block iterator counts + removed voip_cf_destinations.announcement_id from trunk dao + prevent "mysql gone away" error: - xa_db connection for ncos level lookups - *reverted* - set net_read_timeout to a higher value than default 30 secs - implement sql connection pinger for managed conenctions + fix processor thread wrong rowcount + write trusted sources for permanent registration's contact IP addresses + write a default ncos level for subscribers without barring + set mysql connection encoding to utf8 + create multi-subscriber contracts properly + properly skip subscribers with non-unique contracts + generate sip password if empty Change-Id: I533149a2d6328a0aa1f20ab7eab795ffff720020changes/84/16384/20
parent
06b3781a7a
commit
5a07957ff3
@ -0,0 +1,180 @@
|
||||
package NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_trusted_sources;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::Logging qw(
|
||||
getlogger
|
||||
rowinserted
|
||||
rowsdeleted
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::ConnectorPool qw(
|
||||
get_provisioning_db
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::SqlProcessor qw(
|
||||
checktableinfo
|
||||
insert_record
|
||||
copy_row
|
||||
);
|
||||
use NGCP::BulkProcessor::SqlRecord qw();
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::SqlRecord);
|
||||
our @EXPORT_OK = qw(
|
||||
gettablename
|
||||
check_table
|
||||
insert_row
|
||||
|
||||
countby_subscriberid
|
||||
|
||||
$PROTOCOL_UDP
|
||||
$PROTOCOL_TCP
|
||||
$PROTOCOL_TLS
|
||||
$PROTOCOL_ANY
|
||||
);
|
||||
|
||||
my $tablename = 'voip_trusted_sources';
|
||||
my $get_db = \&get_provisioning_db;
|
||||
|
||||
my $expected_fieldnames = [
|
||||
'id',
|
||||
'subscriber_id',
|
||||
'src_ip',
|
||||
'protocol',
|
||||
'from_pattern',
|
||||
'uuid',
|
||||
|
||||
];
|
||||
|
||||
my $indexes = {};
|
||||
|
||||
my $insert_unique_fields = [];
|
||||
|
||||
our $PROTOCOL_UDP = 'UDP';
|
||||
our $PROTOCOL_TCP = 'TCP';
|
||||
our $PROTOCOL_TLS = 'TLS';
|
||||
our $PROTOCOL_ANY = 'ANY';
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::SqlRecord->new($class,$get_db,
|
||||
$tablename,$expected_fieldnames,$indexes);
|
||||
|
||||
copy_row($self,shift,$expected_fieldnames);
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub countby_subscriberid {
|
||||
|
||||
my ($subscriber_id) = @_;
|
||||
|
||||
check_table();
|
||||
my $db = &$get_db();
|
||||
my $table = $db->tableidentifier($tablename);
|
||||
|
||||
my $stmt = 'SELECT COUNT(*) FROM ' . $table;
|
||||
my @params = ();
|
||||
my @terms = ();
|
||||
if (defined $subscriber_id) {
|
||||
push(@terms,$db->columnidentifier('subscriber_id') . ' = ?');
|
||||
push(@params,$subscriber_id);
|
||||
}
|
||||
if ((scalar @terms) > 0) {
|
||||
$stmt .= ' WHERE ' . join(' AND ',@terms);
|
||||
}
|
||||
|
||||
return $db->db_get_value($stmt,@params);
|
||||
|
||||
}
|
||||
|
||||
sub insert_row {
|
||||
|
||||
my $db = &$get_db();
|
||||
my $xa_db = shift // $db;
|
||||
if ('HASH' eq ref $_[0]) {
|
||||
my ($data,$insert_ignore) = @_;
|
||||
check_table();
|
||||
if (insert_record($db,$xa_db,__PACKAGE__,$data,$insert_ignore,$insert_unique_fields)) {
|
||||
return $xa_db->db_last_insert_id();
|
||||
}
|
||||
} else {
|
||||
my %params = @_;
|
||||
my ($subscriber_id,
|
||||
$src_ip,
|
||||
$protocol,
|
||||
$from_pattern,
|
||||
$uuid) = @params{qw/
|
||||
subscriber_id
|
||||
src_ip
|
||||
protocol
|
||||
from_pattern
|
||||
uuid
|
||||
/};
|
||||
|
||||
if ($xa_db->db_do('INSERT INTO ' . $db->tableidentifier($tablename) . ' (' .
|
||||
$db->columnidentifier('subscriber_id') . ', ' .
|
||||
$db->columnidentifier('src_ip') . ', ' .
|
||||
$db->columnidentifier('protocol') . ', ' .
|
||||
$db->columnidentifier('from_pattern') . ', ' .
|
||||
$db->columnidentifier('uuid') . ') VALUES (' .
|
||||
'?, ' .
|
||||
'?, ' .
|
||||
'?, ' .
|
||||
'?, ' .
|
||||
'?)',
|
||||
$subscriber_id,
|
||||
$src_ip,
|
||||
$protocol,
|
||||
$from_pattern,
|
||||
$uuid,
|
||||
)) {
|
||||
rowinserted($db,$tablename,getlogger(__PACKAGE__));
|
||||
return $xa_db->db_last_insert_id();
|
||||
}
|
||||
}
|
||||
return undef;
|
||||
|
||||
}
|
||||
|
||||
sub buildrecords_fromrows {
|
||||
|
||||
my ($rows,$load_recursive) = @_;
|
||||
|
||||
my @records = ();
|
||||
my $record;
|
||||
|
||||
if (defined $rows and ref $rows eq 'ARRAY') {
|
||||
foreach my $row (@$rows) {
|
||||
$record = __PACKAGE__->new($row);
|
||||
|
||||
# transformations go here ...
|
||||
|
||||
push @records,$record;
|
||||
}
|
||||
}
|
||||
|
||||
return \@records;
|
||||
|
||||
}
|
||||
|
||||
sub gettablename {
|
||||
|
||||
return $tablename;
|
||||
|
||||
}
|
||||
|
||||
sub check_table {
|
||||
|
||||
return checktableinfo($get_db,
|
||||
__PACKAGE__,$tablename,
|
||||
$expected_fieldnames,
|
||||
$indexes);
|
||||
|
||||
}
|
||||
|
||||
1;
|
@ -1,19 +1,22 @@
|
||||
mapping:
|
||||
Junet:
|
||||
default: 'Junet 38'
|
||||
21: 'Junet 21'
|
||||
25: 'Junet 25'
|
||||
29: 'Junet 29'
|
||||
33: 'Junet 33'
|
||||
Teleman:
|
||||
default: 'Teleman 38'
|
||||
21: 'Teleman 21'
|
||||
25: 'Teleman 25'
|
||||
29: 'Teleman 29'
|
||||
33: 'Teleman 33'
|
||||
Teletek:
|
||||
default: 'Teletek 38'
|
||||
21: 'Teletek 21'
|
||||
25: 'Teletek 25'
|
||||
27: 'Teletek 27'
|
||||
29: 'Teletek 29'
|
||||
33: 'Teletek 33'
|
||||
25_29: 'Teletek 25 29'
|
||||
25_33: 'Teletek 25 33'
|
||||
25_29: 'Teletek 25'
|
||||
25_33: 'Teletek 25'
|
||||
|
Loading…
Reference in new issue