From b106891f680f92f495ba8987a22b552b063e3bec Mon Sep 17 00:00:00 2001 From: Alexander Lutay Date: Fri, 1 Oct 2021 16:09:25 +0200 Subject: [PATCH] TT#141802 Add MAC to default SNOM 'bootstrap' URL on SRAPS By default NGCP created bootstrap URL on SRAPS as: > http://ngcp.server.com:1445/device/autoprov/bootstrap/ while we need to append it with MAC at the end, as SNOM has device specific firmwares and NGCP need to know MAC to find the device model and return proper firmware to upgrade. The proper bootstrap URL is: > http://ngcp.server.com:1445/device/autoprov/bootstrap/{mac} After firmware upgrade SNOM device will connect to secure URL: > https://ngcp.server.com:1444/device/autoprov/config/{mac} P.S. re-using Panasonic approach for SNOM devices with a difference: Panasonic uses label '{MAC}' and SNOM uses '{mac}'. Change-Id: Ib1530f1adf1154deb5a8fb8a7d856810885f4736 --- lib/NGCP/Panel/Utils/DeviceBootstrap/Panasonic.pm | 2 +- lib/NGCP/Panel/Utils/DeviceBootstrap/Snom.pm | 8 ++++++++ lib/NGCP/Panel/Utils/DeviceBootstrap/VendorRPC.pm | 10 +++++----- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/NGCP/Panel/Utils/DeviceBootstrap/Panasonic.pm b/lib/NGCP/Panel/Utils/DeviceBootstrap/Panasonic.pm index 14dd58178a..a7d3dd5b00 100644 --- a/lib/NGCP/Panel/Utils/DeviceBootstrap/Panasonic.pm +++ b/lib/NGCP/Panel/Utils/DeviceBootstrap/Panasonic.pm @@ -55,7 +55,7 @@ EOS_XML around 'process_bootstrap_uri' => sub { my($orig_method, $self, $uri) = @_; $uri = $self->$orig_method($uri); - $uri = $self->bootstrap_uri_mac($uri); + $uri = $self->bootstrap_uri_mac($uri, "{MAC}"); $self->content_params->{uri} = $uri; return $self->content_params->{uri}; }; diff --git a/lib/NGCP/Panel/Utils/DeviceBootstrap/Snom.pm b/lib/NGCP/Panel/Utils/DeviceBootstrap/Snom.pm index b0ed4a48a3..82f99ce953 100644 --- a/lib/NGCP/Panel/Utils/DeviceBootstrap/Snom.pm +++ b/lib/NGCP/Panel/Utils/DeviceBootstrap/Snom.pm @@ -293,4 +293,12 @@ sub generate_normalized_string { return $normalized; } +around 'process_bootstrap_uri' => sub { + my($orig_method, $self, $uri) = @_; + $uri = $self->$orig_method($uri); + $uri = $self->bootstrap_uri_mac($uri, "{mac}"); + $self->content_params->{uri} = $uri; + return $self->content_params->{uri}; +}; + 1; diff --git a/lib/NGCP/Panel/Utils/DeviceBootstrap/VendorRPC.pm b/lib/NGCP/Panel/Utils/DeviceBootstrap/VendorRPC.pm index 314ec0266d..4f111c12d0 100644 --- a/lib/NGCP/Panel/Utils/DeviceBootstrap/VendorRPC.pm +++ b/lib/NGCP/Panel/Utils/DeviceBootstrap/VendorRPC.pm @@ -215,12 +215,12 @@ sub bootstrap_uri_protocol{ return $uri; } sub bootstrap_uri_mac{ - my($self, $uri) = @_; - if ($uri !~/\{MAC\}$/){ - if ($uri !~/\/$/){ - $uri .= '/' ; + my($self, $uri, $label) = @_; + if ($uri !~ /\Q$label\E$/) { + if ($uri !~ /\/$/) { + $uri .= '/'; } - $uri .= '{MAC}' ; + $uri .= $label; } return $uri; }