diff --git a/lib/NGCP/Panel/Controller/Peering.pm b/lib/NGCP/Panel/Controller/Peering.pm index 13a808538f..911b770503 100644 --- a/lib/NGCP/Panel/Controller/Peering.pm +++ b/lib/NGCP/Panel/Controller/Peering.pm @@ -32,10 +32,12 @@ sub group_list :Chained('/') :PathPart('peering') :CaptureArgs(0) { ]); $c->stash(template => 'peering/list.tt'); + return; } sub root :Chained('group_list') :PathPart('') :Args(0) { my ($self, $c) = @_; + return; } sub ajax :Chained('group_list') :PathPart('ajax') :Args(0) { @@ -45,6 +47,7 @@ sub ajax :Chained('group_list') :PathPart('ajax') :Args(0) { NGCP::Panel::Utils::Datatables::process($c, $resultset, $c->stash->{peering_group_dt_columns}); $c->detach( $c->view("JSON") ); + return; } sub base :Chained('group_list') :PathPart('') :CaptureArgs(1) { @@ -97,6 +100,7 @@ sub base :Chained('group_list') :PathPart('') :CaptureArgs(1) { $c->stash(group => {$res->get_columns}); $c->stash->{group}->{'contract.id'} = $res->peering_contract_id; $c->stash(group_result => $res); + return; } sub edit :Chained('base') :PathPart('edit') { @@ -133,11 +137,12 @@ sub edit :Chained('base') :PathPart('edit') { desc => $c->loc('Failed to update peering group'), ); }; - NGCP::Panel::Utils::Navigation::back_or($c, $c->uri_for) + NGCP::Panel::Utils::Navigation::back_or($c, $c->uri_for); } $c->stash(form => $form); $c->stash(edit_flag => 1); + return; } sub delete :Chained('base') :PathPart('delete') { @@ -164,6 +169,7 @@ sub delete :Chained('base') :PathPart('delete') { ); }; $c->response->redirect($c->uri_for()); + return; } sub create :Chained('group_list') :PathPart('create') :Args(0) { @@ -208,15 +214,18 @@ sub create :Chained('group_list') :PathPart('create') :Args(0) { $c->stash(close_target => $c->uri_for_action('/peering/root')); $c->stash(create_flag => 1); $c->stash(form => $form); + return; } sub servers_list :Chained('base') :PathPart('servers') :CaptureArgs(0) { my ($self, $c) = @_; $c->stash(template => 'peering/servers_rules.tt'); + return; } sub servers_root :Chained('servers_list') :PathPart('') :Args(0) { my ($self, $c) = @_; + return; } sub servers_ajax :Chained('servers_list') :PathPart('s_ajax') :Args(0) { @@ -225,6 +234,7 @@ sub servers_ajax :Chained('servers_list') :PathPart('s_ajax') :Args(0) { my $resultset = $c->stash->{group_result}->voip_peer_hosts; NGCP::Panel::Utils::Datatables::process($c, $resultset, $c->stash->{server_dt_columns}); $c->detach( $c->view("JSON") ); + return; } sub servers_create :Chained('servers_list') :PathPart('create') :Args(0) { @@ -240,7 +250,7 @@ sub servers_create :Chained('servers_list') :PathPart('create') :Args(0) { c => $c, form => $form, fields => {}, - back_uri => $c->req->uri + back_uri => $c->req->uri, ); if($posted && $form->validated) { try { @@ -275,6 +285,7 @@ sub servers_create :Chained('servers_list') :PathPart('create') :Args(0) { servers_create_flag => 1, servers_form => $form, ); + return; } sub servers_base :Chained('servers_list') :PathPart('') :CaptureArgs(1) { @@ -304,6 +315,7 @@ sub servers_base :Chained('servers_list') :PathPart('') :CaptureArgs(1) { } $c->stash(server => {$res->get_columns}); $c->stash(server_result => $res); + return; } sub servers_edit :Chained('servers_base') :PathPart('edit') :Args(0) { @@ -320,7 +332,7 @@ sub servers_edit :Chained('servers_base') :PathPart('edit') :Args(0) { c => $c, form => $form, fields => {}, - back_uri => $c->req->uri + back_uri => $c->req->uri, ); if($posted && $form->validated) { try { @@ -343,8 +355,9 @@ sub servers_edit :Chained('servers_base') :PathPart('edit') :Args(0) { $c->stash( close_target => $c->uri_for_action('/peering/servers_root', [$c->req->captures->[0]]), servers_form => $form, - servers_edit_flag => 1 + servers_edit_flag => 1, ); + return; } sub servers_delete :Chained('servers_base') :PathPart('delete') :Args(0) { @@ -366,6 +379,7 @@ sub servers_delete :Chained('servers_base') :PathPart('delete') :Args(0) { ); }; NGCP::Panel::Utils::Navigation::back_or($c, $c->uri_for_action('/peering/servers_root', [$c->req->captures->[0]])); + return; } sub servers_flash_dialogic :Chained('servers_base') :PathPart('edit/dialogic') :Args(0) { @@ -397,7 +411,7 @@ my $pref_out_codecs = NGCP::Panel::Utils::Preferences::get_peer_preference_rs( my $api = NGCP::Panel::Utils::DialogicImg->new( server => 'https://' . $pref_ip_config->value, ); - my @configured_out_codecs = map { s/^\s+|\s+$//gr } split(',', $pref_out_codecs->value); + my @configured_out_codecs = map { s/^\s+|\s+$//gr } split(m/,/, $pref_out_codecs->value); $api->login( $c->config->{dialogic}{username}, $c->config->{dialogic}{password} ); my $resp = $api->obtain_lock(); die "Couldn't connect to dialogic" @@ -413,7 +427,17 @@ my $pref_out_codecs = NGCP::Panel::Utils::Preferences::get_peer_preference_rs( }; $resp = $api->create_all_sipsip($config, 1); - my $config_hash = $api->hash_config($config); + } elsif ($pref_mode->value eq 'sipisdn') { + my $config = { + ip_sip => $c->stash->{server_result}->ip, + ip_rtp => $pref_ip_rtp->value, + ip_client => $c->config->{dialogic}{own_ip}, + out_codecs => \@configured_out_codecs, + ip_config => $pref_ip_config->value, # just for the config hash + dialogic_mode => $pref_mode->value, + }; + + $resp = $api->create_all_sipisdn($config, 1); } } NGCP::Panel::Utils::Message->info( @@ -429,6 +453,7 @@ my $pref_out_codecs = NGCP::Panel::Utils::Preferences::get_peer_preference_rs( ); }; NGCP::Panel::Utils::Navigation::back_or($c, $c->uri_for_action('/peering/servers_root', [$c->req->captures->[0]])); + return; } sub servers_preferences_list :Chained('servers_base') :PathPart('preferences') :CaptureArgs(0) { @@ -437,7 +462,7 @@ sub servers_preferences_list :Chained('servers_base') :PathPart('preferences') : my $x_pref_values = $c->model('DB') ->resultset('voip_preferences') ->search({ - 'peer_host.id' => $c->stash->{server}->{id} + 'peer_host.id' => $c->stash->{server}->{id}, },{ prefetch => {'voip_peer_preferences' => 'peer_host'}, }); @@ -445,9 +470,8 @@ sub servers_preferences_list :Chained('servers_base') :PathPart('preferences') : my %pref_values; foreach my $value($x_pref_values->all) { - $pref_values{$value->attribute} = [ - map {$_->value} $value->voip_peer_preferences->all - ]; + $pref_values{$value->attribute} = + [ map {$_->value} $value->voip_peer_preferences->all ]; } my $rewrite_rule_sets_rs = $c->model('DB') @@ -461,10 +485,11 @@ sub servers_preferences_list :Chained('servers_base') :PathPart('preferences') : ); $c->stash(template => 'peering/preferences.tt'); + return; } sub servers_preferences_root :Chained('servers_preferences_list') :PathPart('') :Args(0) { - + return; } sub servers_preferences_base :Chained('servers_preferences_list') :PathPart('') :CaptureArgs(1) { @@ -474,7 +499,7 @@ sub servers_preferences_base :Chained('servers_preferences_list') :PathPart('') ->resultset('voip_preferences') ->search({ -or => ['voip_preferences_enums.peer_pref' => 1, - 'voip_preferences_enums.peer_pref' => undef] + 'voip_preferences_enums.peer_pref' => undef], },{ prefetch => 'voip_preferences_enums', }) @@ -490,6 +515,7 @@ sub servers_preferences_base :Chained('servers_preferences_list') :PathPart('') }); my @values = $c->stash->{preference}->get_column("value")->all; $c->stash->{preference_values} = \@values; + return; } sub servers_preferences_edit :Chained('servers_preferences_base') :PathPart('edit') :Args(0) { @@ -509,6 +535,7 @@ sub servers_preferences_edit :Chained('servers_preferences_base') :PathPart('edi base_uri => $c->uri_for_action('/peering/servers_preferences_root', [@{ $c->req->captures }[0,1]]), edit_uri => $c->uri_for_action('/peering/servers_preferences_edit', $c->req->captures), ); + return; } sub rules_list :Chained('base') :PathPart('rules') :CaptureArgs(0) { @@ -518,6 +545,7 @@ sub rules_list :Chained('base') :PathPart('rules') :CaptureArgs(0) { '/peering/servers_root', [$c->req->captures->[0]]); $c->stash(sr_list_uri => $sr_list_uri); $c->stash(template => 'peering/servers_rules.tt'); + return; } sub rules_ajax :Chained('rules_list') :PathPart('r_ajax') :Args(0) { @@ -526,6 +554,7 @@ sub rules_ajax :Chained('rules_list') :PathPart('r_ajax') :Args(0) { my $resultset = $c->stash->{group_result}->voip_peer_rules; NGCP::Panel::Utils::Datatables::process($c, $resultset, $c->stash->{rules_dt_columns}); $c->detach( $c->view("JSON") ); + return; } sub rules_create :Chained('rules_list') :PathPart('create') :Args(0) { @@ -541,7 +570,7 @@ sub rules_create :Chained('rules_list') :PathPart('create') :Args(0) { c => $c, form => $form, fields => {}, - back_uri => $c->req->uri + back_uri => $c->req->uri, ); if($posted && $form->validated) { try { @@ -567,6 +596,7 @@ sub rules_create :Chained('rules_list') :PathPart('create') :Args(0) { rules_create_flag => 1, rules_form => $form, ); + return; } sub rules_base :Chained('rules_list') :PathPart('') :CaptureArgs(1) { @@ -596,6 +626,7 @@ sub rules_base :Chained('rules_list') :PathPart('') :CaptureArgs(1) { } $c->stash(rule => {$res->get_columns}); $c->stash(rule_result => $res); + return; } sub rules_edit :Chained('rules_base') :PathPart('edit') :Args(0) { @@ -612,7 +643,7 @@ sub rules_edit :Chained('rules_base') :PathPart('edit') :Args(0) { c => $c, form => $form, fields => {}, - back_uri => $c->req->uri + back_uri => $c->req->uri, ); if($posted && $form->validated) { try { @@ -638,6 +669,7 @@ sub rules_edit :Chained('rules_base') :PathPart('edit') :Args(0) { rules_form => $form, rules_edit_flag => 1, ); + return; } sub rules_delete :Chained('rules_base') :PathPart('delete') :Args(0) { @@ -659,6 +691,7 @@ sub rules_delete :Chained('rules_base') :PathPart('delete') :Args(0) { ); }; NGCP::Panel::Utils::Navigation::back_or($c, $c->uri_for_action('/peering/servers_root', [$c->req->captures->[0]])); + return; } sub _sip_lcr_reload { diff --git a/lib/NGCP/Panel/Utils/DialogicImg.pm b/lib/NGCP/Panel/Utils/DialogicImg.pm index 4cf44ffee6..7579a22324 100644 --- a/lib/NGCP/Panel/Utils/DialogicImg.pm +++ b/lib/NGCP/Panel/Utils/DialogicImg.pm @@ -94,11 +94,36 @@ has 'classinfo' => ( is => 'ro', isa => HashRef, default => sub{ parent => 'packet_facility_collection', revalidate => 0, }, + ds1_spans => { + name => 'SpanGroup', + parent => 'facility', + revalidate => 0, + }, signaling => { name => 'Signaling', parent => 'bn2020', revalidate => 0, }, + isdn => { + name => 'ISDN', + parent => 'signaling', + revalidate => 0, + }, + isdn_d_chan => { + name => 'ISDNDChan', + parent => 'isdn', + revalidate => 1, + }, + isdn_group => { + name => 'ISDNGroup', + parent => 'isdn_d_chan', + revalidate => 0, + }, + isdn_circuit_group => { + name => 'ISDNCircuitGroup', + parent => 'isdn_group', + revalidate => 1, + }, sip => { name => 'SIP', parent => 'signaling', @@ -124,7 +149,6 @@ has 'classinfo' => ( is => 'ro', isa => HashRef, default => sub{ parent => 'ip_profile_collection', revalidate => 1, }, - # ... vocoder_profile => { name => 'VocoderProfile', parent => 'ip_profile', @@ -140,6 +164,16 @@ has 'classinfo' => ( is => 'ro', isa => HashRef, default => sub{ parent => 'sip_profile_collection', revalidate => 0, }, + tdm_profile_collection => { + name => 'TDMProfiles', + parent => 'profile_collection', + revalidate => 0, + }, + e1_profile => { + name => 'E1Profile', + parent => 'tdm_profile_collection', + revalidate => 0, + }, external_network_elements => { name => 'ExternalNetworkElements', parent => 'root', @@ -168,7 +202,7 @@ has 'classinfo' => ( is => 'ro', isa => HashRef, default => sub{ channel_group => { name => 'ChannelGroup', parent => 'channel_group_collection', - revalidate => 0, + revalidate => 1, }, route_table_collection => { name => 'RoutingTables', @@ -195,6 +229,11 @@ has 'classinfo' => ( is => 'ro', isa => HashRef, default => sub{ parent => 'cg_network_element', revalidate => 0, }, + cg_isdn_circuit_group => { + name => 'SSLCircuitGroup', + parent => 'channel_group', + revalidate => 0, + }, }; }); @@ -294,12 +333,42 @@ sub create_packet_facility { return $self->_create_generic($options, 'packet_facility'); } +sub create_ds1_spans { + my ( $self, $options ) = @_; + + return $self->_create_generic($options, 'ds1_spans'); +} + sub create_signaling { my ( $self, $options ) = @_; return $self->_create_generic($options, 'signaling'); } +sub create_isdn { + my ( $self, $options ) = @_; + + return $self->_create_generic($options, 'isdn'); +} + +sub create_isdn_d_chan { + my ( $self, $options ) = @_; + + return $self->_create_generic($options, 'isdn_d_chan'); +} + +sub create_isdn_group { + my ( $self, $options ) = @_; + + return $self->_create_generic($options, 'isdn_group'); +} + +sub create_isdn_circuit_group { + my ( $self, $options ) = @_; + + return $self->_create_generic($options, 'isdn_circuit_group'); +} + sub create_sip { my ( $self, $options ) = @_; @@ -348,6 +417,18 @@ sub create_sip_profile { return $self->_create_generic($options, 'sip_profile'); } +sub create_tdm_profile_collection { + my ( $self, $options ) = @_; + + return $self->_create_generic($options, 'tdm_profile_collection'); +} + +sub create_e1_profile { + my ( $self, $options ) = @_; + + return $self->_create_generic($options, 'e1_profile'); +} + sub create_external_network_elements { my ( $self ) = @_; @@ -414,6 +495,12 @@ sub create_node_association { return $self->_create_generic($options, 'node_association'); } +sub create_cg_isdn_circuit_group { + my ( $self, $options ) = @_; + + return $self->_create_generic($options, 'cg_isdn_circuit_group'); +} + sub _create_generic { my ($self, $options, $class) = @_; @@ -573,6 +660,166 @@ sub create_all_sipsip { return 0; } +# log: 0: none, 1: short +# necessary keys: ip_sip, ip_rtp, ip_client, out_codecs, optional: in_codecs +sub create_all_sipisdn { + my ($self, $settings, $log) = @_; + + $self->_create_indent; + + my $in_codecs = ['G711 ulaw', 'G711 alaw', 'G729', 'AMR', + 'AMR Bandwidth Efficient', 'AMR-WB', 'AMR-WB Bandwidth Efficient', + 'Clear Channel', 'G723 5.3 Kbps', 'G723 6.3 Kbps', 'G722', 'iLBC 30ms', + 'GSM-FR Static Payload Type', 'GSM-FR Dynamic Payload Type', + 'G726-32/G721 Static Payload Type', 'G726-32/G721 Dynamic Payload Type', + 'GSM-EFR']; + + my $resp = $self->create_bn2020; + my @in_schedule = map { + { + name => 'vocoder_profile', options => + { PayloadType => $_ }, + }; + } @{ $settings->{in_codecs} // $in_codecs }; + my @out_schedule = map { + { + name => 'vocoder_profile', options => + { PayloadType => $_ }, + }; + } @{ $settings->{out_codecs} }; + my $schedule = [ + {name => 'network', options => undef}, + {name => 'interface_collection', options => undef}, + {name => 'interface', options => undef}, + {name => 'ip_address', options => { + NIIPAddress => $settings->{ip_sip}, + NIIPPhy => 'Services', + }}, + {name => 'interface', options => undef}, + {name => 'ip_address', options => { + NIIPAddress => $settings->{ip_rtp}, + NIIPPhy => 'Media 0', + }}, + {name => 'facility', options => undef}, + {name => 'packet_facility_collection', options => undef}, + {name => 'packet_facility', options => { + ChannelCount => 50, + }}, + {name => 'signaling', options => undef}, + {name => 'sip', options => undef}, + {name => 'sip_ip', options => { + IPAddress => $settings->{ip_sip}, + }}, + {name => 'isdn', options => undef}, + + {name => 'profile_collection', options => undef}, + {name => 'ip_profile_collection', options => undef}, + {name => 'ip_profile', options => { + DigitRelay => 'DTMF Packetized', + Name => 'ngcp_in_profile', + }}, + @in_schedule, + {name => 'ip_profile', options => { + DigitRelay => 'DTMF Packetized', + Name => 'ngcp_out_profile', + }}, + @out_schedule, + {name => 'sip_profile_collection', options => undef}, + {name => 'sip_profile', options => undef}, + {name => 'tdm_profile_collection', options => undef}, + {name => 'e1_profile', options => undef}, + {name => 'ds1_spans', options => { + EndingOffset => '3', + }}, + {name => 'isdn_d_chan', options => undef}, + {name => 'isdn_group', options => undef}, + {name => 'isdn_circuit_group', options => { + EndChannel => 'Span ID: 0 CID: 30', + }}, + {name => 'isdn_d_chan', options => { + BaseVariant => 'Euro-ISDN User Side', + BChanSelection => 'Linear Counter Clockwise', + }}, + {name => 'isdn_group', options => undef}, + {name => 'isdn_circuit_group', options => { + EndChannel => 'Span ID: 1 CID: 30', + }}, + #{run => 'download_profiles'}, + {name => 'external_network_elements', options => undef}, + {name => 'external_gateway_collection', options => undef}, + {name => 'external_gateway', options => { + Name => 'Phone1', + IPAddress => $settings->{ip_client}, + IPAddress4 => $settings->{ip_client}, + }}, + {name => 'routing_configuration', options => undef}, + {name => 'channel_group_collection', options => undef}, + {name => 'route_table_collection', options => undef}, + {name => 'route_table', options => { + Name => 'ngcp_route_table', + }}, + {name => 'channel_group', options => { + SignalingType => 'SIP', + InRouteTable => 'ngcp_route_table - ID: 5', + InIPProfile => 'ngcp_in_profile', + InIPProfileId => '1', + OutIPProfile => 'ngcp_out_profile', + SupportA2F => 'True', + Name => 'CGPhone1', + }}, + {name => 'cg_network_element', options => undef}, + {name => 'node_association', options => undef}, + {name => 'channel_group', options => { + SignalingType => 'ISDN', + InRouteTable => 'ngcp_route_table - ID: 5', + SupportA2F => 'True', + Name => 'CGisdn1', + }}, + {name => 'cg_isdn_circuit_group', options => undef}, + {name => 'channel_group', options => { + SignalingType => 'ISDN', + InRouteTable => 'ngcp_route_table - ID: 5', + SupportA2F => 'True', + Name => 'CGisdn2', + }}, + {name => 'cg_isdn_circuit_group', options => undef}, + {name => 'route_element', options => { + StringType => 'Channel Group', + InChannelGroup => 'CGPhone1', + RouteActionType => 'Channel Group', + RouteActionList => 'CGisdn1', + }}, + {name => 'route_element', options => { + StringType => 'Channel Group', + InChannelGroup => 'CGisdn2', + RouteActionType => 'Channel Group', + RouteActionList => 'CGPhone1', + }}, + #{run => 'download_route_table'}, + #{run => 'download_channel_groups'}, + ]; + + for my $elem (@{ $schedule }) { + my ($name, $options) = @{ $elem }{('name', 'options')}; + my $fun = "create_$name"; + $resp = $self->$fun($options); + # $resp = $self->_create_generic($options, $name); + if ($log >= 1) { + my $ind = " " x ($self->classinfo->{$name}{indent}*4); + printf "%-37s: %d\n", "$ind$name", $resp->code; + if ($resp->code != 200) { + use DDP; p $resp->data; + } + } + } + + $self->download_profiles; + $self->download_route_table; + $self->download_channel_groups; + + return 0; +} + ###### OTHER STUFF ###### sub hash_config { @@ -773,7 +1020,7 @@ sub reboot_and_wait { sleep 2; # not to catch the old server for (my $i = 0; $i < 100; $i++) { # 500 seconds on 5 seconds timeout $resp = $self->get("/"); - last if $resp->code < 500; + last if $resp->code < 400; } return $resp; } diff --git a/share/tools/dialogic-test-client.pl b/share/tools/dialogic-test-client.pl index 98a67daa0c..b5b2ac2692 100644 --- a/share/tools/dialogic-test-client.pl +++ b/share/tools/dialogic-test-client.pl @@ -7,15 +7,14 @@ use Data::Dumper; exit if try_parse_file(@ARGV); +my $resp; + my $test = NGCP::Panel::Utils::DialogicImg->new( server => 'https://10.15.20.150', ); p $test->login( 'dialogic', 'Dial0gic' ); -my $resp - = $test->get( '/oamp/configuration/objects', { appid => $test->appid } ); - $resp = $test->obtain_lock(); p $resp->code; @@ -43,9 +42,15 @@ print "LOGGED IN, LOCK OBTAINED ############################\n"; # #p $test->classinfo; # exit; -my $result = $test->create_all_sipsip({ - ip1 => '10.15.20.92', - ip2 => '10.15.21.10', +# $test->pids->{facility} = 10008; +# $resp = $test->create_ds1_spans; +# p $resp; +# p $resp->data; +# exit; + +my $result = $test->create_all_sipisdn({ + ip_sip => '10.15.20.92', + ip_rtp => '10.15.21.10', ip_client => '10.15.20.199', in_codecs => ['G711 ulaw', 'G711 alaw', 'G729', 'AMR'], out_codecs => ['G711 ulaw', 'G711 alaw', 'G729', 'AMR'],