MT#21269 Implement Snom redirect service

Change-Id: I715346f1c8cd75bf2027f0db5296dbcd46abefa7
changes/32/7132/9
Irina Peshinskaya 9 years ago
parent 1d10d26802
commit 7ad8784610

@ -253,11 +253,12 @@ has_field 'bootstrap_method' => (
{ label => 'Panasonic', value => 'redirect_panasonic' },
{ label => 'Yealink', value => 'redirect_yealink' },
{ label => 'Polycom', value => 'redirect_polycom' },
{ label => 'Snom', value => 'redirect_snom' },
],
default => 'http',
element_attr => {
rel => ['tooltip'],
title => ['Method to configure the provisioning server on the phone. One of http, redirect_panasonic, redirect_yealink, redirect_polycom.'],
title => ['Method to configure the provisioning server on the phone. One of http, redirect_panasonic, redirect_yealink, redirect_polycom, redirect_snom.'],
javascript => ' onchange="bootstrapDynamicFields(this.options[this.selectedIndex].value);" ',
},
);
@ -267,7 +268,7 @@ has_field 'bootstrap_uri' => (
label => 'Bootstrap URI',
default => '',
#we don't show this field for polycom, because polycom doesn't support now any possibility to configure provisioning url via API
wrapper_class => [qw/ngcp-devicetype ngcp-devicetype-phone ngcp-bootstrap-config ngcp-bootstrap-config-http ngcp-bootstrap-config-redirect_panasonic ngcp-bootstrap-config-redirect_yealink/],
wrapper_class => [qw/ngcp-devicetype ngcp-devicetype-phone ngcp-bootstrap-config ngcp-bootstrap-config-http ngcp-bootstrap-config-redirect_panasonic ngcp-bootstrap-config-redirect_yealink ngcp-bootstrap-config-redirect_snom/],
element_attr => {
rel => ['tooltip'],
title => ['Custom provisioning server URI.'],
@ -391,6 +392,28 @@ has_field 'bootstrap_config_redirect_polycom_profile' => (
title => ['Preliminary created in ZeroTouch Provisioning console Polycom ZTP profile. Refer to documentation.'],
},
);
has_field 'bootstrap_config_redirect_snom_user' => (
type => 'Text',
required => 0,
label => 'Snom username',
default => '',
wrapper_class => [qw/ngcp-devicetype ngcp-devicetype-phone ngcp-bootstrap-config ngcp-bootstrap-config-redirect_snom/],
element_attr => {
rel => ['tooltip'],
title => ['Username used to configure bootstrap url on Snom redirect server. Obtained from Snom.'],
},
);
has_field 'bootstrap_config_redirect_snom_password' => (
type => 'Text',
required => 0,
label => 'Snom password',
default => '',
wrapper_class => [qw/ngcp-devicetype ngcp-devicetype-phone ngcp-bootstrap-config ngcp-bootstrap-config-redirect_snom/],
element_attr => {
rel => ['tooltip'],
title => ['Password used to configure bootstrap url on Snom redirect server. Obtained from Snom.'],
},
);
has_field 'save' => (
type => 'Submit',

@ -6,7 +6,7 @@ extends 'NGCP::Panel::Form::Device::ModelAdmin';
has_block 'fields' => (
tag => 'div',
class => [qw/modal-body/],
render_list => [qw/reseller vendor model type extensions_num connectable_models linerange bootstrap_method bootstrap_uri bootstrap_config_http_sync_method bootstrap_config_http_sync_uri bootstrap_config_http_sync_params bootstrap_config_redirect_panasonic_user bootstrap_config_redirect_panasonic_password bootstrap_config_redirect_yealink_user bootstrap_config_redirect_yealink_password bootstrap_config_redirect_polycom_user bootstrap_config_redirect_polycom_password bootstrap_config_redirect_polycom_profile/],
render_list => [qw/reseller vendor model type extensions_num connectable_models linerange bootstrap_method bootstrap_uri bootstrap_config_http_sync_method bootstrap_config_http_sync_uri bootstrap_config_http_sync_params bootstrap_config_redirect_panasonic_user bootstrap_config_redirect_panasonic_password bootstrap_config_redirect_yealink_user bootstrap_config_redirect_yealink_password bootstrap_config_redirect_polycom_user bootstrap_config_redirect_polycom_password bootstrap_config_redirect_polycom_profile bootstrap_config_redirect_snom_user bootstrap_config_redirect_snom_password/],
);
override 'field_list' => sub {

@ -29,7 +29,7 @@ has_field 'save' => (
has_block 'fields' => (
tag => 'div',
class => [qw/modal-body/],
render_list => [qw/reseller vendor model type extensions_num connectable_models linerange linerange_add bootstrap_method bootstrap_uri bootstrap_config_http_sync_method bootstrap_config_http_sync_uri bootstrap_config_http_sync_params bootstrap_config_redirect_panasonic_user bootstrap_config_redirect_panasonic_password bootstrap_config_redirect_yealink_user bootstrap_config_redirect_yealink_password bootstrap_config_redirect_polycom_user bootstrap_config_redirect_polycom_password bootstrap_config_redirect_polycom_profile front_image mac_image/],
render_list => [qw/reseller vendor model type extensions_num connectable_models linerange linerange_add bootstrap_method bootstrap_uri bootstrap_config_http_sync_method bootstrap_config_http_sync_uri bootstrap_config_http_sync_params bootstrap_config_redirect_panasonic_user bootstrap_config_redirect_panasonic_password bootstrap_config_redirect_yealink_user bootstrap_config_redirect_yealink_password bootstrap_config_redirect_polycom_user bootstrap_config_redirect_polycom_password bootstrap_config_redirect_polycom_profile bootstrap_config_redirect_snom_user bootstrap_config_redirect_snom_password front_image mac_image/],
);
has_block 'actions' => (

@ -7,6 +7,7 @@ use NGCP::Panel::Utils::DeviceBootstrap::VendorRPC;
use NGCP::Panel::Utils::DeviceBootstrap::Panasonic;
use NGCP::Panel::Utils::DeviceBootstrap::Yealink;
use NGCP::Panel::Utils::DeviceBootstrap::Polycom;
use NGCP::Panel::Utils::DeviceBootstrap::Snom;
sub dispatch{
my($c, $action, $fdev, $old_identifier) = @_;
@ -91,6 +92,8 @@ sub get_redirect_processor{
$redirect_processor = NGCP::Panel::Utils::DeviceBootstrap::Yealink->new( params => $params );
}elsif('redirect_polycom' eq $bootstrap_method){
$redirect_processor = NGCP::Panel::Utils::DeviceBootstrap::Polycom->new( params => $params );
}elsif('redirect_snom' eq $bootstrap_method){
$redirect_processor = NGCP::Panel::Utils::DeviceBootstrap::Snom->new( params => $params );
}elsif('http' eq $bootstrap_method){
#$ret = panasonic_bootstrap_register($params);
}

@ -0,0 +1,118 @@
package NGCP::Panel::Utils::DeviceBootstrap::Snom;
use strict;
use Moose;
use Data::Dumper;
extends 'NGCP::Panel::Utils::DeviceBootstrap::VendorRPC';
sub rpc_server_params{
my $self = shift;
my $cfg = {
proto => 'https',
host => 'provisioning.snom.com',
port => '8083',
path => '/xmlrpc',
};
$cfg->{headers} = { %{$self->get_basic_authorization($self->params->{credentials})} };
$self->{rpc_server_params} = $cfg;
return $self->{rpc_server_params};
}
sub register_content {
my $self = shift;
#<param><value><string>".URI::Escape::uri_escape($self->content_params->{uri})."</string></value></param>
#http://fox.snom.com/prv2.php?mac={mac}
$self->{register_content} = "<?xml version='1.0'?>
<methodCall>
<methodName>redirect.registerPhone</methodName>
<params>
<param>
<value><string>".$self->content_params->{mac}."</string></value>
</param>
<param>
<value><string>".$self->content_params->{uri}."</string></value>
</param>
</params>
</methodCall>";
return $self->{register_content};
}
sub unregister_content {
my $self = shift;
$self->{unregister_content} = "<?xml version='1.0'?>
<methodCall>
<methodName>redirect.deregisterPhone</methodName>
<params>
<param>
<value><string>".$self->content_params->{mac_old}."</string></value>
</param>
</params>
</methodCall>";
return $self->{unregister_content};
}
override 'extract_response_description' => sub {
my($self,$rpc_value) = @_;
my $c = $self->params->{c};
my $res = '';
if(ref $rpc_value eq 'ARRAY'){
#1 - success; 0 - error, error string is a second param
if($rpc_value->[0] eq '1'){
$res = '';#clear the error
}elsif($rpc_value->[0] eq '0'){
return $rpc_value->[1];
}else{
$res = $self->unknown_error;
}
}else{
$res = $self->unknown_error;
}
return $res;
};
override 'process_bootstrap_uri' => sub {
my($self,$uri) = @_;
$uri = super($uri);
$uri = $self->bootstrap_uri_mac($uri);
$self->content_params->{uri} = $uri;
return $self->content_params->{uri};
};
override 'bootstrap_uri_mac' => sub {
my($self, $uri) = @_;
if ($uri !~/\{mac\}$/){
if ($uri !~/\/$/){
$uri .= '/' ;
}
$uri .= '?mac={mac}' ;
}
return $uri;
};
1;
=head1 NAME
NGCP::Panel::Utils::DeviceBootstrap
=head1 DESCRIPTION
Make API requests to configure remote redirect servers for requested MAC with autorpov uri.
See http://wiki.snom.com/Category:HowTo:XMLRPC_Redirection.
=head1 METHODS
=head2 bootstrap
Dispatch to proper vendor API call.
=head1 AUTHOR
Irina Peshinskaya C<< <ipeshinskaya@sipwise.com> >>
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
# vim: set tabstop=4 expandtab:

@ -176,6 +176,12 @@ sub bootstrap_uri_conf{
};
return $cfg;
}
sub unknown_error{
my ($self) = @_;
my $c = $self->params->{c};
return $c->loc('Unknown error');
}
1;
=head1 NAME

@ -35,6 +35,8 @@ $fake_data->set_data_from_script({
bootstrap_config_redirect_polycom_user => "",
bootstrap_config_redirect_yealink_password => "",
bootstrap_config_redirect_yealink_user => "",
bootstrap_config_redirect_snom_password => "",
bootstrap_config_redirect_snom_user => "",
#TODO:implement checking against this number in the controller and api
#/3.7relative tests
"linerange"=>[

Loading…
Cancel
Save