|
|
|
@ -13,6 +13,7 @@ use NGCP::BulkProcessor::Projects::Migration::IPGallery::Settings qw(
|
|
|
|
|
|
|
|
|
|
$domain_name
|
|
|
|
|
$reseller_id
|
|
|
|
|
$subsciber_username_prefix
|
|
|
|
|
$set_barring_profiles_multithreading
|
|
|
|
|
$set_barring_profiles_numofthreads
|
|
|
|
|
$barring_profiles
|
|
|
|
@ -20,6 +21,10 @@ use NGCP::BulkProcessor::Projects::Migration::IPGallery::Settings qw(
|
|
|
|
|
$set_peer_auth_multithreading
|
|
|
|
|
$set_peer_auth_numofthreads
|
|
|
|
|
$peer_auth_realm
|
|
|
|
|
|
|
|
|
|
$set_allowed_ips_multithreading
|
|
|
|
|
$set_allowed_ips_numofthreads
|
|
|
|
|
$allowed_ips
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
use NGCP::BulkProcessor::Logging qw (
|
|
|
|
@ -64,6 +69,9 @@ our @EXPORT_OK = qw(
|
|
|
|
|
set_peer_auth
|
|
|
|
|
set_peer_auth_batch
|
|
|
|
|
|
|
|
|
|
set_allowed_ips
|
|
|
|
|
set_allowed_ips_batch
|
|
|
|
|
|
|
|
|
|
clear_preferences
|
|
|
|
|
set_preference
|
|
|
|
|
|
|
|
|
@ -384,7 +392,7 @@ sub _reset_context {
|
|
|
|
|
|
|
|
|
|
my $userpassword = NGCP::BulkProcessor::Projects::Migration::IPGallery::Dao::import::UsernamePassword::findby_fqdn($context->{cli});
|
|
|
|
|
if (defined $userpassword) {
|
|
|
|
|
$context->{username} = $userpassword->{username};
|
|
|
|
|
$context->{username} = (defined $subsciber_username_prefix ? $subsciber_username_prefix : '') . $userpassword->{username};
|
|
|
|
|
$context->{password} = $userpassword->{password};
|
|
|
|
|
$context->{userpassworddelta} = $userpassword->{delta};
|
|
|
|
|
} else {
|
|
|
|
@ -680,6 +688,313 @@ sub _reset_set_peer_auth_context {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sub set_allowed_ips {
|
|
|
|
|
|
|
|
|
|
my ($mode) = @_;
|
|
|
|
|
my $static_context = { mode => $mode };
|
|
|
|
|
my $result = _set_allowed_ips_checks($static_context);
|
|
|
|
|
|
|
|
|
|
destroy_all_dbs();
|
|
|
|
|
my $warning_count :shared = 0;
|
|
|
|
|
return ($result && NGCP::BulkProcessor::Projects::Migration::IPGallery::Dao::import::Subscriber::process_records(
|
|
|
|
|
static_context => $static_context,
|
|
|
|
|
process_code => sub {
|
|
|
|
|
my ($context,$records,$row_offset) = @_;
|
|
|
|
|
my $rownum = $row_offset;
|
|
|
|
|
foreach my $imported_subscriber (@$records) {
|
|
|
|
|
$rownum++;
|
|
|
|
|
next unless _reset_set_allowed_ips_context($context,$imported_subscriber,$rownum);
|
|
|
|
|
_set_allowed_ips($context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#return 0;
|
|
|
|
|
return 1;
|
|
|
|
|
},
|
|
|
|
|
init_process_context_code => sub {
|
|
|
|
|
my ($context)= @_;
|
|
|
|
|
$context->{db} = &get_xa_db();
|
|
|
|
|
$context->{error_count} = 0;
|
|
|
|
|
$context->{warning_count} = 0;
|
|
|
|
|
# below is not mandatory..
|
|
|
|
|
_check_insert_tables();
|
|
|
|
|
},
|
|
|
|
|
uninit_process_context_code => sub {
|
|
|
|
|
my ($context)= @_;
|
|
|
|
|
undef $context->{db};
|
|
|
|
|
destroy_all_dbs();
|
|
|
|
|
{
|
|
|
|
|
lock $warning_count;
|
|
|
|
|
$warning_count += $context->{warning_count};
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
load_recursive => 0,
|
|
|
|
|
multithreading => $set_allowed_ips_multithreading,
|
|
|
|
|
numofthreads => $set_allowed_ips_numofthreads,
|
|
|
|
|
),$warning_count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sub set_allowed_ips_batch {
|
|
|
|
|
|
|
|
|
|
my ($mode) = @_;
|
|
|
|
|
my $static_context = { mode => $mode };
|
|
|
|
|
my $result = _set_allowed_ips_checks($static_context);
|
|
|
|
|
|
|
|
|
|
destroy_all_dbs();
|
|
|
|
|
my $warning_count :shared = 0;
|
|
|
|
|
return ($result && NGCP::BulkProcessor::Projects::Migration::IPGallery::Dao::import::Batch::process_records(
|
|
|
|
|
static_context => $static_context,
|
|
|
|
|
process_code => sub {
|
|
|
|
|
my ($context,$records,$row_offset) = @_;
|
|
|
|
|
my $rownum = $row_offset;
|
|
|
|
|
foreach my $record (@$records) {
|
|
|
|
|
$rownum++;
|
|
|
|
|
my $imported_subscriber = NGCP::BulkProcessor::Projects::Migration::IPGallery::Dao::import::Subscriber::findby_subscribernumber($record->{number});
|
|
|
|
|
if (defined $imported_subscriber) {
|
|
|
|
|
next unless _reset_set_allowed_ips_context($context,$imported_subscriber,$rownum);
|
|
|
|
|
_set_allowed_ips($context);
|
|
|
|
|
} else {
|
|
|
|
|
if ($skip_errors) {
|
|
|
|
|
_warn($context,'record ' . $rownum . ' - no subscriber record for batch number found: ' . $record->{number});
|
|
|
|
|
next;
|
|
|
|
|
} else {
|
|
|
|
|
_error($context,'record ' . $rownum . ' - no subscriber record for batch number found: ' . $record->{number});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#return 0;
|
|
|
|
|
return 1;
|
|
|
|
|
},
|
|
|
|
|
init_process_context_code => sub {
|
|
|
|
|
my ($context)= @_;
|
|
|
|
|
$context->{db} = &get_xa_db();
|
|
|
|
|
$context->{error_count} = 0;
|
|
|
|
|
$context->{warning_count} = 0;
|
|
|
|
|
# below is not mandatory..
|
|
|
|
|
_check_insert_tables();
|
|
|
|
|
},
|
|
|
|
|
uninit_process_context_code => sub {
|
|
|
|
|
my ($context)= @_;
|
|
|
|
|
undef $context->{db};
|
|
|
|
|
destroy_all_dbs();
|
|
|
|
|
{
|
|
|
|
|
lock $warning_count;
|
|
|
|
|
$warning_count += $context->{warning_count};
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
load_recursive => 0,
|
|
|
|
|
multithreading => $set_allowed_ips_multithreading,
|
|
|
|
|
numofthreads => $set_allowed_ips_numofthreads,
|
|
|
|
|
),$warning_count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sub _set_allowed_ips {
|
|
|
|
|
my ($context) = @_;
|
|
|
|
|
_set_subscriber_preference($context,\&_set_allowed_ips_preferences);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sub _set_allowed_ips_checks {
|
|
|
|
|
my ($context) = @_;
|
|
|
|
|
|
|
|
|
|
my $result = _checks($context);
|
|
|
|
|
|
|
|
|
|
eval {
|
|
|
|
|
$context->{peer_auth_user_attribute} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::findby_attribute(
|
|
|
|
|
$NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::PEER_AUTH_USER);
|
|
|
|
|
};
|
|
|
|
|
if ($@ or not defined $context->{peer_auth_user_attribute}) {
|
|
|
|
|
rowprocessingerror(threadid(),'cannot find peer_auth_user attribute',getlogger(__PACKAGE__));
|
|
|
|
|
$result = 0; #even in skip-error mode..
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
eval {
|
|
|
|
|
$context->{peer_auth_pass_attribute} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::findby_attribute(
|
|
|
|
|
$NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::PEER_AUTH_PASS);
|
|
|
|
|
};
|
|
|
|
|
if ($@ or not defined $context->{peer_auth_pass_attribute}) {
|
|
|
|
|
rowprocessingerror(threadid(),'cannot find peer_auth_pass attribute',getlogger(__PACKAGE__));
|
|
|
|
|
$result = 0; #even in skip-error mode..
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
eval {
|
|
|
|
|
$context->{peer_auth_realm_attribute} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::findby_attribute(
|
|
|
|
|
$NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::PEER_AUTH_REALM);
|
|
|
|
|
};
|
|
|
|
|
if ($@ or not defined $context->{peer_auth_realm_attribute}) {
|
|
|
|
|
rowprocessingerror(threadid(),'cannot find peer_auth_realm attribute',getlogger(__PACKAGE__));
|
|
|
|
|
$result = 0; #even in skip-error mode..
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
eval {
|
|
|
|
|
$context->{peer_auth_register_attribute} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::findby_attribute(
|
|
|
|
|
$NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::PEER_AUTH_REGISTER);
|
|
|
|
|
};
|
|
|
|
|
if ($@ or not defined $context->{peer_auth_register_attribute}) {
|
|
|
|
|
rowprocessingerror(threadid(),'cannot find peer_auth_register attribute',getlogger(__PACKAGE__));
|
|
|
|
|
$result = 0; #even in skip-error mode..
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
eval {
|
|
|
|
|
$context->{force_inbound_calls_to_peer_attribute} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::findby_attribute(
|
|
|
|
|
$NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::FORCE_INBOUND_CALLS_TO_PEER);
|
|
|
|
|
};
|
|
|
|
|
if ($@ or not defined $context->{force_inbound_calls_to_peer_attribute}) {
|
|
|
|
|
rowprocessingerror(threadid(),'cannot find force_inbound_calls_to_peer attribute',getlogger(__PACKAGE__));
|
|
|
|
|
$result = 0; #even in skip-error mode..
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#eval {
|
|
|
|
|
# $context->{force_outbound_calls_to_peer_attribute} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::findby_attribute(
|
|
|
|
|
# $NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::FORCE_OUTBOUND_CALLS_TO_PEER);
|
|
|
|
|
#};
|
|
|
|
|
#if ($@ or not defined $context->{force_outbound_calls_to_peer_attribute}) {
|
|
|
|
|
# rowprocessingerror(threadid(),'cannot find force_outbound_calls_to_peer attribute',getlogger(__PACKAGE__));
|
|
|
|
|
# $result = 0; #even in skip-error mode..
|
|
|
|
|
#}
|
|
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sub _set_allowed_ips_preferences {
|
|
|
|
|
|
|
|
|
|
my ($context) = @_;
|
|
|
|
|
|
|
|
|
|
#if ($INIT_PEER_AUTH_MODE eq $context->{mode}) {
|
|
|
|
|
#
|
|
|
|
|
# $context->{peer_auth_user_preference_id} = set_preference($context,$context->{provisioning_voip_subscriber}->{id},
|
|
|
|
|
# $context->{peer_auth_user_attribute},$context->{username});
|
|
|
|
|
# $context->{peer_auth_pass_preference_id} = set_preference($context,$context->{provisioning_voip_subscriber}->{id},
|
|
|
|
|
# $context->{peer_auth_pass_attribute},$context->{password});
|
|
|
|
|
# $context->{peer_auth_realm_preference_id} = set_preference($context,$context->{provisioning_voip_subscriber}->{id},
|
|
|
|
|
# $context->{peer_auth_realm_attribute},$context->{realm});
|
|
|
|
|
#
|
|
|
|
|
# $context->{peer_auth_register_attribute_preference_id} = set_preference($context,$context->{provisioning_voip_subscriber}->{id},
|
|
|
|
|
# $context->{peer_auth_register_attribute},$NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_usr_preferences::FALSE);
|
|
|
|
|
# $context->{force_inbound_calls_to_peer_preference_id} = set_preference($context,$context->{provisioning_voip_subscriber}->{id},
|
|
|
|
|
# $context->{force_inbound_calls_to_peer_attribute},$NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_usr_preferences::TRUE);
|
|
|
|
|
#
|
|
|
|
|
# _info($context,"($context->{rownum}) " . $context->{mode} . ' peer authentication preferences for subscriber ' . $context->{cli},1);
|
|
|
|
|
#
|
|
|
|
|
#} elsif ($SWITCHOVER_PEER_AUTH_MODE eq $context->{mode}) {
|
|
|
|
|
#
|
|
|
|
|
# $context->{peer_auth_user_preference_id} = set_preference($context,$context->{provisioning_voip_subscriber}->{id},
|
|
|
|
|
# $context->{peer_auth_user_attribute},$context->{username});
|
|
|
|
|
# $context->{peer_auth_pass_preference_id} = set_preference($context,$context->{provisioning_voip_subscriber}->{id},
|
|
|
|
|
# $context->{peer_auth_pass_attribute},$context->{password});
|
|
|
|
|
# $context->{peer_auth_realm_preference_id} = set_preference($context,$context->{provisioning_voip_subscriber}->{id},
|
|
|
|
|
# $context->{peer_auth_realm_attribute},$context->{realm});
|
|
|
|
|
#
|
|
|
|
|
# $context->{peer_auth_register_attribute_preference_id} = set_preference($context,$context->{provisioning_voip_subscriber}->{id},
|
|
|
|
|
# $context->{peer_auth_register_attribute},$NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_usr_preferences::TRUE);
|
|
|
|
|
# $context->{force_inbound_calls_to_peer_preference_id} = set_preference($context,$context->{provisioning_voip_subscriber}->{id},
|
|
|
|
|
# $context->{force_inbound_calls_to_peer_attribute},$NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_usr_preferences::FALSE);
|
|
|
|
|
#
|
|
|
|
|
# _info($context,"($context->{rownum}) " . $context->{mode} . ' peer authentication preferences for subscriber ' . $context->{cli},1);
|
|
|
|
|
#
|
|
|
|
|
#} elsif ($CLEAR_PEER_AUTH_MODE eq $context->{mode}) {
|
|
|
|
|
#
|
|
|
|
|
# $context->{peer_auth_user_preference_id} = set_preference($context,$context->{provisioning_voip_subscriber}->{id},
|
|
|
|
|
# $context->{peer_auth_user_attribute},undef);
|
|
|
|
|
# $context->{peer_auth_pass_preference_id} = set_preference($context,$context->{provisioning_voip_subscriber}->{id},
|
|
|
|
|
# $context->{peer_auth_pass_attribute},undef);
|
|
|
|
|
# $context->{peer_auth_realm_preference_id} = set_preference($context,$context->{provisioning_voip_subscriber}->{id},
|
|
|
|
|
# $context->{peer_auth_realm_attribute},undef);
|
|
|
|
|
#
|
|
|
|
|
# $context->{peer_auth_register_attribute_preference_id} = set_preference($context,$context->{provisioning_voip_subscriber}->{id},
|
|
|
|
|
# $context->{peer_auth_register_attribute},undef);
|
|
|
|
|
# $context->{force_inbound_calls_to_peer_preference_id} = set_preference($context,$context->{provisioning_voip_subscriber}->{id},
|
|
|
|
|
# $context->{force_inbound_calls_to_peer_attribute},undef);
|
|
|
|
|
#
|
|
|
|
|
# _info($context,"($context->{rownum}) " . $context->{mode} . ' peer authentication preferences for subscriber ' . $context->{cli},1);
|
|
|
|
|
#
|
|
|
|
|
#}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sub _reset_set_allowed_ips_context {
|
|
|
|
|
|
|
|
|
|
my ($context,$imported_subscriber,$rownum) = @_;
|
|
|
|
|
|
|
|
|
|
my $result = _reset_context($context,$imported_subscriber,$rownum);
|
|
|
|
|
|
|
|
|
|
$context->{realm} = $peer_auth_realm;
|
|
|
|
|
#$context->{mode} = $mode;
|
|
|
|
|
|
|
|
|
|
delete $context->{peer_auth_user_preference_id};
|
|
|
|
|
delete $context->{peer_auth_pass_preference_id};
|
|
|
|
|
delete $context->{peer_auth_realm_preference_id};
|
|
|
|
|
|
|
|
|
|
delete $context->{peer_auth_register_attribute_preference_id};
|
|
|
|
|
delete $context->{force_inbound_calls_to_peer_preference_id};
|
|
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|