From 64dd9c01e2dcc1f303321ef8def8fba11415fd4b Mon Sep 17 00:00:00 2001 From: Irina Peshinskaya Date: Thu, 6 Nov 2014 19:32:38 +0200 Subject: [PATCH] MT#9177 Bootstrap_uri logic and fixes. --- lib/NGCP/Panel/Controller/Device.pm | 6 +++--- lib/NGCP/Panel/Form/Device/Model.pm | 12 +++++++++++- lib/NGCP/Panel/Form/Device/ModelAPI.pm | 2 +- lib/NGCP/Panel/Form/Device/ModelAdmin.pm | 2 +- lib/NGCP/Panel/Utils/DeviceBootstrap/Panasonic.pm | 9 +++++++-- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/lib/NGCP/Panel/Controller/Device.pm b/lib/NGCP/Panel/Controller/Device.pm index 7b3dd2bb74..d6565e7073 100644 --- a/lib/NGCP/Panel/Controller/Device.pm +++ b/lib/NGCP/Panel/Controller/Device.pm @@ -286,10 +286,10 @@ sub devmod_edit :Chained('devmod_base') :PathPart('edit') :Args(0) :Does(ACL) :A push @{ $params->{linerange} }, $r; } #TODO: TO inflate/deflate, I think - foreach ( $c->model('DB')->resultset('autoprov_sync_parameters')->search_rs({ - 'me.bootstrap_method' => $c->stash->{devmod}->bootstrap_method, + foreach ( $c->model('DB')->resultset('autoprov_sync')->search_rs({ + device_id =>$c->stash->{devmod}->id, })->all ){ - $params->{'bootstrap_config_'.$c->stash->{devmod}->bootstrap_method.'_'.$_->parameter_name} = $_->parameter_value; + $params->{'bootstrap_config_'.$c->stash->{devmod}->bootstrap_method.'_'.$_->autoprov_sync_parameters->parameter_name} = $_->parameter_value; } my $credentials_rs = $c->model('DB')->resultset('autoprov_redirect_credentials')->search_rs({ 'me.device_id' => $c->stash->{devmod}->id, diff --git a/lib/NGCP/Panel/Form/Device/Model.pm b/lib/NGCP/Panel/Form/Device/Model.pm index 572f06fd11..64df1cecaf 100644 --- a/lib/NGCP/Panel/Form/Device/Model.pm +++ b/lib/NGCP/Panel/Form/Device/Model.pm @@ -213,6 +213,16 @@ has_field 'bootstrap_method' => ( javascript => ' onchange="bootstrapDynamicFields(this.options[this.selectedIndex].value);" ', }, ); +has_field 'bootstrap_uri' => ( + type => 'Text', + required => 0, + label => 'Bootstrap URI', + default => '', + element_attr => { + rel => ['tooltip'], + title => ['Custom provisioning server URI.'], + }, +); has_field 'bootstrap_config_http_sync_uri' => ( @@ -288,7 +298,7 @@ has_field 'save' => ( has_block 'fields' => ( tag => 'div', class => [qw/modal-body/], - render_list => [qw/vendor model linerange linerange_add bootstrap_method bootstrap_config_http_sync_uri bootstrap_config_http_sync_method bootstrap_config_http_sync_params bootstrap_config_redirect_panasonic_user bootstrap_config_redirect_panasonic_password front_image mac_image/], + render_list => [qw/vendor model linerange linerange_add bootstrap_uri bootstrap_method bootstrap_config_http_sync_uri bootstrap_config_http_sync_method bootstrap_config_http_sync_params bootstrap_config_redirect_panasonic_user bootstrap_config_redirect_panasonic_password front_image mac_image/], ); has_block 'actions' => ( diff --git a/lib/NGCP/Panel/Form/Device/ModelAPI.pm b/lib/NGCP/Panel/Form/Device/ModelAPI.pm index 3adceb5b9f..8db1a99430 100644 --- a/lib/NGCP/Panel/Form/Device/ModelAPI.pm +++ b/lib/NGCP/Panel/Form/Device/ModelAPI.pm @@ -7,7 +7,7 @@ use Moose::Util::TypeConstraints; has_block 'fields' => ( tag => 'div', class => [qw/modal-body/], - render_list => [qw/reseller vendor model linerange bootstrap_method bootstrap_config_http_sync_uri bootstrap_config_http_sync_method bootstrap_config_http_sync_params bootstrap_config_redirect_panasonic_user bootstrap_config_redirect_panasonic_password/], + render_list => [qw/reseller vendor model linerange bootstrap_uri bootstrap_method bootstrap_config_http_sync_uri bootstrap_config_http_sync_method bootstrap_config_http_sync_params bootstrap_config_redirect_panasonic_user bootstrap_config_redirect_panasonic_password/], ); override 'field_list' => sub { diff --git a/lib/NGCP/Panel/Form/Device/ModelAdmin.pm b/lib/NGCP/Panel/Form/Device/ModelAdmin.pm index dd67ca387b..e59cccf43d 100644 --- a/lib/NGCP/Panel/Form/Device/ModelAdmin.pm +++ b/lib/NGCP/Panel/Form/Device/ModelAdmin.pm @@ -26,7 +26,7 @@ has_field 'save' => ( has_block 'fields' => ( tag => 'div', class => [qw/modal-body/], - render_list => [qw/reseller vendor model linerange linerange_add bootstrap_method bootstrap_config_http_sync_uri bootstrap_config_http_sync_method bootstrap_config_http_sync_params bootstrap_config_redirect_panasonic_user bootstrap_config_redirect_panasonic_password front_image mac_image/], + render_list => [qw/reseller vendor model linerange linerange_add bootstrap_uri bootstrap_method bootstrap_config_http_sync_uri bootstrap_config_http_sync_method bootstrap_config_http_sync_params bootstrap_config_redirect_panasonic_user bootstrap_config_redirect_panasonic_password front_image mac_image/], ); has_block 'actions' => ( diff --git a/lib/NGCP/Panel/Utils/DeviceBootstrap/Panasonic.pm b/lib/NGCP/Panel/Utils/DeviceBootstrap/Panasonic.pm index aa43a27590..12535c454f 100644 --- a/lib/NGCP/Panel/Utils/DeviceBootstrap/Panasonic.pm +++ b/lib/NGCP/Panel/Utils/DeviceBootstrap/Panasonic.pm @@ -25,8 +25,13 @@ sub prepare { $p->{auth} = encode_base64($creds->user.':'.$creds->password); } - $p->{uri} = NGCP::Panel::Utils::DeviceBootstrap::get_baseuri($c); - $p->{uri} .= '{MAC}'; + $p->{uri} = ($devmod->bootstrap_uri) + ? $devmod->bootstrap_uri + : NGCP::Panel::Utils::DeviceBootstrap::get_baseuri($c); + + if ($p->{uri} !~/\{MAC\}$/){ + $p->{uri} .= '{MAC}' ; + } $p->{uri} = URI::Escape::uri_escape($p->{uri}); return $p;