MT#21609 add possibility to register peer_auth at only one instance

Change-Id: I965eb4708535498575f7aa926b3f52a2913c1950
changes/74/7474/2
Gerhard Jungwirth 9 years ago
parent b2843a640d
commit 9f7566ed88

@ -12,6 +12,11 @@ sub create_peer_registration {
return 1;
}
my $all = 1;
if($c->config->{sems}->{single_host_registration}) {
$all = 0;
}
my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new;
$c->log->debug("creating peer registration for subscriber '".$prov_subscriber->username.'@'.$prov_subscriber->domain->domain."'");
@ -20,7 +25,7 @@ sub create_peer_registration {
my $uuid = $prov_subscriber->uuid;
my $contact = $c->config->{sip}->{lb_ext};
my @ret = $dispatcher->dispatch($c, "appserver", 1, 1, <<EOF);
my @ret = $dispatcher->dispatch($c, "appserver", $all, 1, <<EOF);
<?xml version="1.0"?>
<methodCall>
<methodName>db_reg_agent.createRegistration</methodName>
@ -34,6 +39,10 @@ sub create_peer_registration {
</methodCall>
EOF
if (!$all && @ret && $ret[-1][1] == 1 && $ret[-1][2] =~ m#<value>OK</value>#) { # single host okay
return 1;
}
if(grep { $$_[1] != 1 or $$_[2] !~ m#<value>OK</value># } @ret) { # error
$c->log->error("Failed XML-RPC call to appserver: ". Dumper \@ret);
@ -63,6 +72,11 @@ sub update_peer_registration {
return 1;
}
my $all = 1;
if($c->config->{sems}->{single_host_registration}) {
$all = 0;
}
my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new;
$c->log->debug("trying to update peer registration for subscriber '".$prov_subscriber->username.'@'.$prov_subscriber->domain->domain."'");
@ -78,7 +92,7 @@ sub update_peer_registration {
$c->log->debug("+++++++++++++++++++ uuid=$uuid");
$c->log->debug("+++++++++++++++++++ contact=$contact");
my @ret = $dispatcher->dispatch($c, "appserver", 1, 1, <<EOF);
my @ret = $dispatcher->dispatch($c, "appserver", $all, 1, <<EOF);
<?xml version="1.0"?>
<methodCall>
<methodName>db_reg_agent.updateRegistration</methodName>
@ -92,6 +106,10 @@ sub update_peer_registration {
</methodCall>
EOF
if (!$all && @ret && $ret[-1][1] == 1 && $ret[-1][2] =~ m#<value>OK</value>#) { # single host okay
return 1;
}
if(grep { $$_[1] != 1 or $$_[2] !~ m#<value>OK</value># } @ret) { # error
$c->log->error("Failed XML-RPC call to appserver: ". Dumper \@ret);
@ -125,6 +143,11 @@ sub delete_peer_registration {
return 1;
}
my $all = 1;
if($c->config->{sems}->{single_host_registration}) {
$all = 0;
}
my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new;
$c->log->debug("trying to delete peer registration for subscriber '".$prov_subscriber->username.'@'.$prov_subscriber->domain->domain."'");
@ -133,7 +156,7 @@ sub delete_peer_registration {
my $uuid = $prov_subscriber->uuid;
my $contact = $c->config->{sip}->{lb_ext};
my @ret = $dispatcher->dispatch($c, "appserver", 1, 1, <<EOF);
my @ret = $dispatcher->dispatch($c, "appserver", $all, 1, <<EOF);
<?xml version="1.0"?>
<methodCall>
<methodName>db_reg_agent.removeRegistration</methodName>
@ -143,6 +166,10 @@ sub delete_peer_registration {
</methodCall>
EOF
if (!$all && @ret && $ret[-1][1] == 1 && $ret[-1][2] =~ m#<value>OK</value>#) { # single host okay
return 1;
}
if(grep { $$_[1] != 1 or $$_[2] !~ m#<value>OK</value># } @ret) { # error
$c->log->error("Failed XML-RPC call to appserver: ". Dumper \@ret);

@ -28,7 +28,7 @@ sub dispatch {
else {
my $host_rs = $schema->resultset('xmlgroups')
->search_rs({name => $target})
->search_related('xmlhostgroups')->search_related('host');
->search_related('xmlhostgroups')->search_related('host', {}, { order_by => 'id' });
$hosts = [map +{ip => $_->ip, port => $_->port, path => $_->path,
id => $_->id}, $host_rs->all];
}

@ -380,5 +380,9 @@ log4perl.appender.Default.layout.ConversionPattern=%d{ISO8601} [%p] [%F +%L] %m{
iv tww21lQe6cmywrp3
</vouchers>
<sems>
single_host_registration 0
</sems>
<external_documentation>
</external_documentation>

Loading…
Cancel
Save