diff --git a/lib/NGCP/Panel/Controller/API/CallControls.pm b/lib/NGCP/Panel/Controller/API/CallControls.pm new file mode 100644 index 0000000000..27b139718b --- /dev/null +++ b/lib/NGCP/Panel/Controller/API/CallControls.pm @@ -0,0 +1,140 @@ +package NGCP::Panel::Controller::API::CallControls; +use Sipwise::Base; +use namespace::sweep; +use boolean qw(true); +use Data::HAL qw(); +use Data::HAL::Link qw(); +use HTTP::Headers qw(); +use HTTP::Status qw(:constants); +use MooseX::ClassAttribute qw(class_has); +use NGCP::Panel::Utils::DateTime; +use Path::Tiny qw(path); +use Safe::Isa qw($_isa); + +use NGCP::Panel::Utils::Sems; + +BEGIN { extends 'Catalyst::Controller::ActionRole'; } +require Catalyst::ActionRole::ACL; +require Catalyst::ActionRole::CheckTrailingSlash; +require Catalyst::ActionRole::HTTPMethods; +require Catalyst::ActionRole::RequireSSL; + +class_has 'api_description' => ( + is => 'ro', + isa => 'Str', + default => + 'Allows to place calls via the API.', +); + +class_has 'query_params' => ( + is => 'ro', + isa => 'ArrayRef', + default => sub {[ + ]}, +); + +with 'NGCP::Panel::Role::API::CallControls'; + +class_has('resource_name', is => 'ro', default => 'callcontrols'); +class_has('dispatch_path', is => 'ro', default => '/api/callcontrols/'); +class_has('relation', is => 'ro', default => 'http://purl.org/sipwise/ngcp-api/#rel-callcontrols'); + +__PACKAGE__->config( + action => { + map { $_ => { + ACLDetachTo => '/api/root/invalid_user', + AllowedRole => [qw/admin reseller/], + Args => 0, + Does => [qw(ACL CheckTrailingSlash RequireSSL)], + Method => $_, + Path => __PACKAGE__->dispatch_path, + } } @{ __PACKAGE__->allowed_methods } + }, + action_roles => [qw(HTTPMethods)], +); + +sub auto :Private { + my ($self, $c) = @_; + + $self->set_body($c); + $self->log_request($c); +} + +sub OPTIONS :Allow { + my ($self, $c) = @_; + my $allowed_methods = $self->allowed_methods; + $c->response->headers(HTTP::Headers->new( + Allow => $allowed_methods->join(', '), + Accept_Post => 'application/hal+json; profile=http://purl.org/sipwise/ngcp-api/#rel-'.$self->resource_name, + )); + $c->response->content_type('application/json'); + $c->response->body(JSON::to_json({ methods => $allowed_methods })."\n"); + return; +} + +sub POST :Allow { + my ($self, $c) = @_; + my $guard = $c->model('DB')->txn_scope_guard; + { + my $resource = $self->get_valid_post_data( + c => $c, + media_type => 'application/json', + ); + last unless $resource; + + my $form = $self->get_form($c); + last unless $self->validate_form( + c => $c, + resource => $resource, + form => $form, + exceptions => [qw/subscriber_id/], + ); + + # TODO: fetch subscriber by id + + my $subscriber_rs = $c->model('DB')->resultset('voip_subscribers')->search({ + id => $resource->{subscriber_id}, + status => { '!=' => 'terminated' }, + }); + if($c->user->roles eq "admin") { + } elsif($c->user->roles eq "reseller") { + $subscriber_rs = $subscriber_rs->search({ + 'contact.reseller_id' => $c->user->reseller_id, + },{ + join => { contract => 'contact' }, + }); + } + my $subscriber = $subscriber_rs->first; + unless($subscriber) { + $c->log->error("invalid subscriber id $$resource{subscriber_id} for outbound call"); + $self->error($c, HTTP_NOT_FOUND, "Calling subscriber not found."); + last; + } + + my ($callee_user, $callee_domain) = split /\@/, $resource->{destination}; + $callee_domain //= $subscriber->domain->domain; + + try { + NGCP::Panel::Utils::Sems::dial_out($c, $subscriber->provisioning_voip_subscriber, + $callee_user, $callee_domain); + } catch($e) { + $c->log->error("failed to dial out: $e"); + $self->error($c, HTTP_INTERNAL_SERVER_ERROR, "Failed to create call."); + last; + } + + $guard->commit; + + $c->response->status(HTTP_OK); + $c->response->body(q()); + } + return; +} + +sub end : Private { + my ($self, $c) = @_; + + $self->log_response($c); +} + +# vim: set tabstop=4 expandtab: diff --git a/lib/NGCP/Panel/Controller/Domain.pm b/lib/NGCP/Panel/Controller/Domain.pm index 2380f8056c..027a50ffc8 100644 --- a/lib/NGCP/Panel/Controller/Domain.pm +++ b/lib/NGCP/Panel/Controller/Domain.pm @@ -144,7 +144,7 @@ sub create :Chained('dom_list') :PathPart('create') :Args() { NGCP::Panel::Utils::Navigation::back_or($c, $c->uri_for('/domain')); } - $self->_sip_domain_reload; + $self->_sip_domain_reload($c); $c->flash(messages => [{type => 'success', text => $c->loc('Domain successfully created') }]); NGCP::Panel::Utils::Navigation::back_or($c, $c->uri_for('/domain')); } @@ -213,7 +213,7 @@ sub edit :Chained('base') :PathPart('edit') :Args(0) { return; } - $self->_sip_domain_reload; + $self->_sip_domain_reload($c); $c->flash(messages => [{type => 'success', text => $c->loc('Domain successfully updated') }]); $c->response->redirect($c->uri_for()); @@ -246,7 +246,7 @@ sub delete :Chained('base') :PathPart('delete') :Args(0) { return; } - $self->_sip_domain_reload; + $self->_sip_domain_reload($c); $c->flash(messages => [{type => 'success', text => $c->loc('Domain successfully deleted!') }]); $c->response->redirect($c->uri_for()); @@ -370,7 +370,7 @@ sub load_preference_list :Private { } sub _sip_domain_reload { - my ($self) = @_; + my ($self, $c) = @_; my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; $dispatcher->dispatch("proxy-ng", 1, 1, < diff --git a/lib/NGCP/Panel/Controller/Peering.pm b/lib/NGCP/Panel/Controller/Peering.pm index fa4723a1d0..e1e0557844 100644 --- a/lib/NGCP/Panel/Controller/Peering.pm +++ b/lib/NGCP/Panel/Controller/Peering.pm @@ -117,7 +117,7 @@ sub edit :Chained('base') :PathPart('edit') { if($posted && $form->validated) { try { $c->stash->{group_result}->update($form->custom_get_values); - $self->_sip_lcr_reload; + $self->_sip_lcr_reload($c); delete $c->session->{created_objects}->{contract}; $c->flash(messages => [{type => 'success', text => $c->loc('Peering group successfully updated')}]); } catch ($e) { @@ -144,7 +144,7 @@ sub delete :Chained('base') :PathPart('delete') { $p->delete; } $c->stash->{group_result}->delete; - $self->_sip_lcr_reload; + $self->_sip_lcr_reload($c); $c->flash(messages => [{type => 'success', text => $c->loc('Peering Group successfully deleted') }]); } catch ($e) { NGCP::Panel::Utils::Message->error( @@ -178,7 +178,7 @@ sub create :Chained('group_list') :PathPart('create') :Args(0) { try { $c->model('DB')->resultset('voip_peer_groups')->create( $formdata ); - $self->_sip_lcr_reload; + $self->_sip_lcr_reload($c); delete $c->session->{created_objects}->{contract}; $c->flash(messages => [{type => 'success', text => $c->loc('Peering group successfully created') }]); } catch ($e) { @@ -232,7 +232,7 @@ sub servers_create :Chained('servers_list') :PathPart('create') :Args(0) { if($posted && $form->validated) { try { $c->stash->{group_result}->voip_peer_hosts->create($form->values); - $self->_sip_lcr_reload; + $self->_sip_lcr_reload($c); $c->flash(messages => [{type => 'success', text => $c->loc('Peering server successfully created') }]); } catch($e) { NGCP::Panel::Utils::Message->error( @@ -299,7 +299,7 @@ sub servers_edit :Chained('servers_base') :PathPart('edit') :Args(0) { if($posted && $form->validated) { try { $c->stash->{server_result}->update($form->values); - $self->_sip_lcr_reload; + $self->_sip_lcr_reload($c); $c->flash(messages => [{type => 'success', text => $c->loc('Peering server successfully updated') }]); } catch ($e) { NGCP::Panel::Utils::Message->error( @@ -323,7 +323,7 @@ sub servers_delete :Chained('servers_base') :PathPart('delete') :Args(0) { try { $c->stash->{server_result}->delete; - $self->_sip_lcr_reload; + $self->_sip_lcr_reload($c); $c->flash(messages => [{type => 'success', text => $c->loc('Peering server successfully deleted') }]); } catch ($e) { NGCP::Panel::Utils::Message->error( @@ -451,7 +451,7 @@ sub rules_create :Chained('rules_list') :PathPart('create') :Args(0) { try { $form->values->{callee_prefix} //= ''; $c->stash->{group_result}->voip_peer_rules->create($form->values); - $self->_sip_lcr_reload; + $self->_sip_lcr_reload($c); $c->flash(rules_messages => [{type => 'success', text => $c->loc('Peering rule successfully created') }]); } catch ($e) { NGCP::Panel::Utils::Message->error( @@ -519,7 +519,7 @@ sub rules_edit :Chained('rules_base') :PathPart('edit') :Args(0) { try { $form->values->{callee_prefix} //= ''; $c->stash->{rule_result}->update($form->values); - $self->_sip_lcr_reload; + $self->_sip_lcr_reload($c); $c->flash(rules_messages => [{type => 'success', text => $c->loc('Peering rule successfully changed') }]); } catch ($e) { NGCP::Panel::Utils::Message->error( @@ -543,7 +543,7 @@ sub rules_delete :Chained('rules_base') :PathPart('delete') :Args(0) { try { $c->stash->{rule_result}->delete; - $self->_sip_lcr_reload; + $self->_sip_lcr_reload($c); $c->flash(rules_messages => [{type => 'success', text => $c->loc('Peering rule successfully deleted') }]); } catch ($e) { NGCP::Panel::Utils::Message->error( @@ -556,9 +556,9 @@ sub rules_delete :Chained('rules_base') :PathPart('delete') :Args(0) { } sub _sip_lcr_reload { - my ($self) = @_; + my ($self, $c) = @_; my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; - $dispatcher->dispatch("proxy-ng", 1, 1, <dispatch($c, "proxy-ng", 1, 1, < lcr.reload diff --git a/lib/NGCP/Panel/Controller/Rewrite.pm b/lib/NGCP/Panel/Controller/Rewrite.pm index 9e21882ac0..6383b43cb9 100644 --- a/lib/NGCP/Panel/Controller/Rewrite.pm +++ b/lib/NGCP/Panel/Controller/Rewrite.pm @@ -384,7 +384,7 @@ sub rules_edit :Chained('rules_base') :PathPart('edit') { if($posted && $form->validated) { try { $c->stash->{rule_result}->update($form->values); - $self->_sip_dialplan_reload(); + $self->_sip_dialplan_reload($c); $c->flash(messages => [{type => 'success', text => $c->loc('Rewrite rule successfully updated')}]); } catch($e) { NGCP::Panel::Utils::Message->error( @@ -405,7 +405,7 @@ sub rules_delete :Chained('rules_base') :PathPart('delete') { try { $c->stash->{rule_result}->delete; - $self->_sip_dialplan_reload(); + $self->_sip_dialplan_reload($c); $c->flash(messages => [{type => 'success', text => $c->loc('Rewrite rule successfully deleted') }]); } catch($e) { NGCP::Panel::Utils::Message->error( @@ -437,7 +437,7 @@ sub rules_create :Chained('rules_list') :PathPart('create') :Args(0) { my $last_priority = $c->stash->{rules_rs}->get_column('priority')->max() || 49; $form->values->{priority} = int($last_priority) + 1; $c->stash->{rules_rs}->create($form->values); - $self->_sip_dialplan_reload(); + $self->_sip_dialplan_reload($c); $c->flash(messages => [{type => 'success', text => $c->loc('Rewrite rule successfully created') }]); } catch($e) { NGCP::Panel::Utils::Message->error( @@ -454,9 +454,9 @@ sub rules_create :Chained('rules_list') :PathPart('create') :Args(0) { } sub _sip_dialplan_reload { - my ($self) = @_; + my ($self, $c) = @_; my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; - $dispatcher->dispatch("proxy-ng", 1, 1, <dispatch($c, "proxy-ng", 1, 1, < dialplan.reload diff --git a/lib/NGCP/Panel/Controller/Security.pm b/lib/NGCP/Panel/Controller/Security.pm index 7eb7f48049..537bedee23 100644 --- a/lib/NGCP/Panel/Controller/Security.pm +++ b/lib/NGCP/Panel/Controller/Security.pm @@ -34,7 +34,7 @@ sub index :Chained('/') :PathPart('security') :Args(0) { EOF - my $ip_res = $dispatcher->dispatch("loadbalancer", 1, 1, $ip_xml); + my $ip_res = $dispatcher->dispatch($c, "loadbalancer", 1, 1, $ip_xml); my @ips = (); for my $host (grep {$$_[1]} @$ip_res) { @@ -70,7 +70,7 @@ EOF EOF - my $user_res = $dispatcher->dispatch("loadbalancer", 1, 1, $user_xml); + my $user_res = $dispatcher->dispatch($c, "loadbalancer", 1, 1, $user_xml); my @users = (); my $usr = {}; for my $host (grep {$$_[1]} @$user_res) { @@ -140,7 +140,7 @@ sub ip_unban :Chained('ip_base') :PathPart('unban') :Args(0) { EOF - $dispatcher->dispatch("loadbalancer", 1, 1, $xml); + $dispatcher->dispatch($c, "loadbalancer", 1, 1, $xml); $c->flash(messages => [{type => 'success', text => $c->loc('IP successfully unbanned')}]); NGCP::Panel::Utils::Navigation::back_or($c, $c->uri_for('/security')); @@ -170,7 +170,7 @@ sub user_unban :Chained('user_base') :PathPart('unban') :Args(0) { EOF - $dispatcher->dispatch("loadbalancer", 1, 1, $xml); + $dispatcher->dispatch($c, "loadbalancer", 1, 1, $xml); } $c->flash(messages => [{type => 'success', text => $c->loc('User successfully unbanned')}]); diff --git a/lib/NGCP/Panel/Controller/Sound.pm b/lib/NGCP/Panel/Controller/Sound.pm index b445515ed5..eedca7ba90 100644 --- a/lib/NGCP/Panel/Controller/Sound.pm +++ b/lib/NGCP/Panel/Controller/Sound.pm @@ -569,7 +569,7 @@ sub handles_edit :Chained('handles_base') :PathPart('edit') { given($file_result->handle->group->name) { when([qw/calling_card/]) { try { - NGCP::Panel::Utils::Sems::clear_audio_cache("appserver", $file_result->set_id, $file_result->handle->name); + NGCP::Panel::Utils::Sems::clear_audio_cache($c, "appserver", $file_result->set_id, $file_result->handle->name); } catch ($e) { NGCP::Panel::Utils::Message->error( c => $c, @@ -584,10 +584,10 @@ sub handles_edit :Chained('handles_base') :PathPart('edit') { try { if(!$file_result->set->contract_id) { $service = "appserver"; - NGCP::Panel::Utils::Sems::clear_audio_cache($service, $file_result->set_id, $file_result->handle->name); + NGCP::Panel::Utils::Sems::clear_audio_cache($c, $service, $file_result->set_id, $file_result->handle->name); } else { $service = "pbx"; - NGCP::Panel::Utils::Sems::clear_audio_cache($service, $file_result->set_id, $file_result->handle->name); + NGCP::Panel::Utils::Sems::clear_audio_cache($c, $service, $file_result->set_id, $file_result->handle->name); } } catch ($e) { NGCP::Panel::Utils::Message->error( diff --git a/lib/NGCP/Panel/Form/CallControl/CallAPI.pm b/lib/NGCP/Panel/Form/CallControl/CallAPI.pm new file mode 100644 index 0000000000..9ca2ea7ad7 --- /dev/null +++ b/lib/NGCP/Panel/Form/CallControl/CallAPI.pm @@ -0,0 +1,43 @@ +package NGCP::Panel::Form::CallControl::CallAPI; + +use HTML::FormHandler::Moose; +extends 'HTML::FormHandler'; +use Moose::Util::TypeConstraints; + +use HTML::FormHandler::Widget::Block::Bootstrap; + +has '+widget_wrapper' => ( default => 'Bootstrap' ); +has_field 'submitid' => ( type => 'Hidden' ); +sub build_render_list {[qw/submitid fields actions/]} +sub build_form_element_class {[qw(form-horizontal)]} + +has_field 'subscriber_id' => ( + type => 'PosInteger', + label => 'Subscriber #', + required => 1, + maxlength => 255, + element_attr => { + rel => ['tooltip'], + title => ['The ID of the calling subscriber'] + }, +); + +has_field 'destination' => ( + type => 'Text', + label => 'Destination URI, user or number', + required => 1, + element_attr => { + rel => ['tooltip'], + title => ['The destination URI, user or number as dialed by the end user'] + }, +); + +has_block 'fields' => ( + tag => 'div', + class => [qw/modal-body/], + render_list => [qw/subscriber_id destination/], +); + +1; + +# vim: set tabstop=4 expandtab: diff --git a/lib/NGCP/Panel/Role/API.pm b/lib/NGCP/Panel/Role/API.pm index ba02ec6b2a..992d5843a7 100644 --- a/lib/NGCP/Panel/Role/API.pm +++ b/lib/NGCP/Panel/Role/API.pm @@ -481,6 +481,7 @@ sub item_rs {} around 'item_rs' => sub { my ($orig, $self, @orig_params) = @_; my $item_rs = $self->$orig(@orig_params); + return unless($item_rs); # no query params defined in collection controller unless($self->can('query_params') && @{ $self->query_params }) { diff --git a/lib/NGCP/Panel/Role/API/CallControls.pm b/lib/NGCP/Panel/Role/API/CallControls.pm new file mode 100644 index 0000000000..4d2e2b83f9 --- /dev/null +++ b/lib/NGCP/Panel/Role/API/CallControls.pm @@ -0,0 +1,26 @@ +package NGCP::Panel::Role::API::CallControls; +use Moose::Role; +use Sipwise::Base; +with 'NGCP::Panel::Role::API' => { + -alias =>{ item_rs => '_item_rs', }, + -excludes => [ 'item_rs' ], +}; + +use boolean qw(true); +use TryCatch; +use Data::HAL qw(); +use Data::HAL::Link qw(); +use HTTP::Status qw(:constants); + +use NGCP::Panel::Form::CallControl::CallAPI; + +sub item_rs { +} + +sub get_form { + my ($self, $c) = @_; + return NGCP::Panel::Form::CallControl::CallAPI->new; +} + +1; +# vim: set tabstop=4 expandtab: diff --git a/lib/NGCP/Panel/Role/API/Domains.pm b/lib/NGCP/Panel/Role/API/Domains.pm index 65c248945e..f572a89a93 100644 --- a/lib/NGCP/Panel/Role/API/Domains.pm +++ b/lib/NGCP/Panel/Role/API/Domains.pm @@ -130,7 +130,7 @@ sub item_by_id { sub sip_domain_reload { my ($self, $c) = @_; my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; - $dispatcher->dispatch("proxy-ng", 1, 1, <dispatch($c, "proxy-ng", 1, 1, < domain.reload diff --git a/lib/NGCP/Panel/Utils/Kamailio.pm b/lib/NGCP/Panel/Utils/Kamailio.pm index d1a9afc1e3..4d8ac32b14 100644 --- a/lib/NGCP/Panel/Utils/Kamailio.pm +++ b/lib/NGCP/Panel/Utils/Kamailio.pm @@ -10,7 +10,7 @@ sub delete_location_contact { my $aor = $prov_subscriber->username . '@' . $prov_subscriber->domain->domain; my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; - my $ret = $dispatcher->dispatch("proxy-ng", 1, 1, <dispatch($c, "proxy-ng", 1, 1, < ul.rm_contact @@ -29,7 +29,7 @@ sub delete_location { my $aor = $prov_subscriber->username . '@' . $prov_subscriber->domain->domain; my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; - my $ret = $dispatcher->dispatch("proxy-ng", 1, 1, <dispatch($c, "proxy-ng", 1, 1, < ul.rm @@ -55,7 +55,7 @@ sub create_location { $flags //= 0; $cflags //= 0; my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; - my $ret = $dispatcher->dispatch("proxy-ng", 1, 1, <dispatch($c, "proxy-ng", 1, 1, < ul.add diff --git a/lib/NGCP/Panel/Utils/Sems.pm b/lib/NGCP/Panel/Utils/Sems.pm index 40cbce253e..6425009fb3 100644 --- a/lib/NGCP/Panel/Utils/Sems.pm +++ b/lib/NGCP/Panel/Utils/Sems.pm @@ -20,7 +20,7 @@ sub create_peer_registration { my $uuid = $prov_subscriber->uuid; my $contact = $c->config->{sip}->{lb_ext}; - my @ret = $dispatcher->dispatch("appserver", 1, 1, <dispatch($c, "appserver", 1, 1, < db_reg_agent.createRegistration @@ -39,7 +39,7 @@ EOF # remove reg from successsful backends foreach my $ret (grep {!$$_[1]} @ret) { # successful backends - $dispatcher->dispatch($$ret[0], 1, 1, <dispatch($c, $$ret[0], 1, 1, < db_reg_agent.removeRegistration @@ -78,7 +78,7 @@ sub update_peer_registration { $c->log->debug("+++++++++++++++++++ uuid=$uuid"); $c->log->debug("+++++++++++++++++++ contact=$contact"); - my @ret = $dispatcher->dispatch("appserver", 1, 1, <dispatch($c, "appserver", 1, 1, < db_reg_agent.updateRegistration @@ -97,7 +97,7 @@ EOF # undo update on successsful backends foreach my $ret (grep {!$$_[1]} @ret) { # successful backends - $dispatcher->dispatch($$ret[0], 1, 1, <dispatch($c, $$ret[0], 1, 1, < db_reg_agent.updateRegistration @@ -133,7 +133,7 @@ sub delete_peer_registration { my $uuid = $prov_subscriber->uuid; my $contact = $c->config->{sip}->{lb_ext}; - my @ret = $dispatcher->dispatch("appserver", 1, 1, <dispatch($c, "appserver", 1, 1, < db_reg_agent.removeRegistration @@ -148,7 +148,7 @@ EOF # remove reg from successsful backends foreach my $ret (grep {!$$_[1]} @ret) { # successful backends - $dispatcher->dispatch($ret[0], 1, 1, <dispatch($c, $ret[0], 1, 1, < db_reg_agent.createRegistration @@ -170,11 +170,11 @@ EOF } sub clear_audio_cache { - my ($service, $sound_set_id, $handle_name) = @_; + my ($c, $service, $sound_set_id, $handle_name) = @_; my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; - my @ret = $dispatcher->dispatch($service, 1, 1, <dispatch($c, $service, 1, 1, < postDSMEvent @@ -209,6 +209,54 @@ EOF return 1; } +sub dial_out { + my ($c, $prov_subscriber, $callee_user, $callee_domain) = @_; + # TODO: what about announcement + my $announcement = 'test.wav'; + + my $proxy_rs = $c->model('DB')->resultset('xmlhosts')->search({ + 'group.name' => 'proxy', + },{ + join => { xmlhostgroups => 'group' }, + order_by => \'rand()', + }); + my $proxy = $proxy_rs->first; + unless($proxy) { + die "failed to fetch proxy for dial-out, none available"; + } + my $proxyuri = $proxy->ip . ':' . $proxy->sip_port; + + my $caller_username = $prov_subscriber->username; + my $caller_domain = $prov_subscriber->domain->domain; + my $caller_password = $prov_subscriber->password; + + my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new; + my $ret = $dispatcher->dispatch($c, "appserver", 0, 1, < + + dial_auth_b2b + + click2dial + $announcement + sip:$caller_username\@$caller_domain + sip:$callee_user\@$callee_domain + sip:$caller_username\@$proxyuri;sw_domain=$caller_domain + sip:$callee_user\@$proxyuri;sw_domain=$callee_domain + $caller_domain + $caller_username + $caller_password + + +EOF + + use Data::Dumper; + $c->log->info("received from dispatcher: " . Dumper $ret); + if(!$ret or $ret->[1] != 1 or $ret->[2] =~ m#faultString#) { + die "failed to trigger dial-out"; + } + return 1; +} + 1; # vim: set tabstop=4 expandtab: diff --git a/lib/NGCP/Panel/Utils/XMLDispatcher.pm b/lib/NGCP/Panel/Utils/XMLDispatcher.pm index 633670f65b..c52d2b8d40 100644 --- a/lib/NGCP/Panel/Utils/XMLDispatcher.pm +++ b/lib/NGCP/Panel/Utils/XMLDispatcher.pm @@ -12,7 +12,7 @@ has 'schema' => ( ); sub dispatch { - my ($self, $target, $all, $sync, $body) = @_; + my ($self, $c, $target, $all, $sync, $body) = @_; my $schema = $self->schema; @@ -33,7 +33,7 @@ sub dispatch { for my $host (@$hosts) { my ($meth, $ip, $port, $path, $hostid) = ("http", $host->{ip}, $host->{port}, $host->{path}, $host->{id}); - Log::Log4perl->get_logger($self)->info("dispatching xmlrpc $target request to ".$ip.":".$port.$path); + $c->log->info("dispatching xmlrpc $target request to ".$ip.":".$port.$path); my $ret = eval { # catch exceptions my $s = Net::HTTP->new(Host => $ip, KeepAlive => 0, PeerPort => $port || 80, Timeout => 5); @@ -72,7 +72,7 @@ sub dispatch { # failure - Log::Log4perl->get_logger($self)->info("failure: $@"); + $c->log->info("failure: $@"); $all or next;