diff --git a/lib/NGCP/Panel/Form/Device/Model.pm b/lib/NGCP/Panel/Form/Device/Model.pm index 7c579612be..0b7173187f 100644 --- a/lib/NGCP/Panel/Form/Device/Model.pm +++ b/lib/NGCP/Panel/Form/Device/Model.pm @@ -267,15 +267,13 @@ has_field 'bootstrap_method' => ( { label => 'Polycom', value => 'redirect_polycom' }, { label => 'Snom', value => 'redirect_snom' }, { label => 'Grandstream', value => 'redirect_grandstream' }, - { label => 'Sipwise Redirect', value => 'redirect_sipwise' }, - { label => 'Sipwise Profile', value => 'profile_sipwise' }, { label => 'ALE', value => 'redirect_ale' }, { label => 'None', value => 'none' }, ], 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, redirect_snom, redirect_grandstream, redirect_sipwise, profile_sipwise, redirect_ale, none.'], + title => ['Method to configure the provisioning server on the phone. One of http, redirect_panasonic, redirect_yealink, redirect_polycom, redirect_snom, redirect_grandstream, redirect_ale, none.'], javascript => ' onchange="bootstrapDynamicFields(this.options[this.selectedIndex].value);" ', }, ); @@ -482,51 +480,6 @@ has_field 'bootstrap_config_redirect_grandstream_key' => ( }, ); -has_field 'bootstrap_config_redirect_sipwise_user' => ( - type => 'Text', - required => 0, - label => 'Sipwise EDS username', - default => '', - wrapper_class => [qw/ngcp-devicetype ngcp-devicetype-phone ngcp-bootstrap-config ngcp-bootstrap-config-redirect_sipwise/], - element_attr => { - rel => ['tooltip'], - title => ['Username used to configure device on Sipwise EDS.'], - }, -); -has_field 'bootstrap_config_redirect_sipwise_password' => ( - type => 'Text', - required => 0, - label => 'Sipwise EDS password', - default => '', - wrapper_class => [qw/ngcp-devicetype ngcp-devicetype-phone ngcp-bootstrap-config ngcp-bootstrap-config-redirect_sipwise/], - element_attr => { - rel => ['tooltip'], - title => ['Password used to configure device on Sipwise EDS.'], - }, -); - -has_field 'bootstrap_config_profile_sipwise_user' => ( - type => 'Text', - required => 0, - label => 'Sipwise EDS username', - default => '', - wrapper_class => [qw/ngcp-devicetype ngcp-devicetype-phone ngcp-bootstrap-config ngcp-bootstrap-config-profile_sipwise/], - element_attr => { - rel => ['tooltip'], - title => ['Username used to configure device on Sipwise EDS.'], - }, -); -has_field 'bootstrap_config_profile_sipwise_password' => ( - type => 'Text', - required => 0, - label => 'Sipwise EDS password', - default => '', - wrapper_class => [qw/ngcp-devicetype ngcp-devicetype-phone ngcp-bootstrap-config ngcp-bootstrap-config-profile_sipwise/], - element_attr => { - rel => ['tooltip'], - title => ['Password used to configure device on Sipwise EDS.'], - }, -); has_field 'bootstrap_config_redirect_ale_user' => ( type => 'Text', required => 0, @@ -560,7 +513,7 @@ has_field 'save' => ( has_block 'fields' => ( tag => 'div', class => [qw/modal-body/], - render_list => [qw/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 bootstrap_config_redirect_snom_profile bootstrap_config_redirect_snom_product_family bootstrap_config_redirect_grandstream_cid bootstrap_config_redirect_grandstream_key bootstrap_config_redirect_sipwise_user bootstrap_config_redirect_sipwise_password bootstrap_config_profile_sipwise_user bootstrap_config_profile_sipwise_password bootstrap_config_redirect_ale_user bootstrap_config_redirect_ale_password front_image front_thumbnail mac_image/], + render_list => [qw/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 bootstrap_config_redirect_snom_profile bootstrap_config_redirect_snom_product_family bootstrap_config_redirect_grandstream_cid bootstrap_config_redirect_grandstream_key bootstrap_config_redirect_ale_user bootstrap_config_redirect_ale_password front_image front_thumbnail mac_image/], ); has_block 'actions' => ( diff --git a/lib/NGCP/Panel/Utils/DeviceBootstrap.pm b/lib/NGCP/Panel/Utils/DeviceBootstrap.pm index 37e2091865..4a2c53173a 100644 --- a/lib/NGCP/Panel/Utils/DeviceBootstrap.pm +++ b/lib/NGCP/Panel/Utils/DeviceBootstrap.pm @@ -11,8 +11,6 @@ use NGCP::Panel::Utils::DeviceBootstrap::Yealink; use NGCP::Panel::Utils::DeviceBootstrap::Polycom; use NGCP::Panel::Utils::DeviceBootstrap::Snom; use NGCP::Panel::Utils::DeviceBootstrap::Grandstream; -use NGCP::Panel::Utils::DeviceBootstrap::SipwiseRedirect; -use NGCP::Panel::Utils::DeviceBootstrap::SipwiseProfile; use NGCP::Panel::Utils::DeviceBootstrap::ALE; my $redirect_processor; @@ -113,10 +111,6 @@ sub get_redirect_processor{ $redirect_processor = NGCP::Panel::Utils::DeviceBootstrap::Snom->new( params => $params ); }elsif('redirect_grandstream' eq $bootstrap_method){ $redirect_processor = NGCP::Panel::Utils::DeviceBootstrap::Grandstream->new( params => $params ); - }elsif('redirect_sipwise' eq $bootstrap_method){ - $redirect_processor = NGCP::Panel::Utils::DeviceBootstrap::SipwiseRedirect->new( params => $params ); - }elsif('profile_sipwise' eq $bootstrap_method){ - $redirect_processor = NGCP::Panel::Utils::DeviceBootstrap::SipwiseProfile->new( params => $params ); }elsif('redirect_ale' eq $bootstrap_method){ $redirect_processor = NGCP::Panel::Utils::DeviceBootstrap::ALE->new( params => $params ); }elsif('http' eq $bootstrap_method){ diff --git a/lib/NGCP/Panel/Utils/DeviceBootstrap/SipwiseProfile.pm b/lib/NGCP/Panel/Utils/DeviceBootstrap/SipwiseProfile.pm deleted file mode 100644 index 56a7650eaf..0000000000 --- a/lib/NGCP/Panel/Utils/DeviceBootstrap/SipwiseProfile.pm +++ /dev/null @@ -1,189 +0,0 @@ -package NGCP::Panel::Utils::DeviceBootstrap::SipwiseProfile; - -use strict; -use warnings; - -use URI::Escape; -use Moo; -use Types::Standard qw(Str); -use JSON qw/encode_json decode_json/; -use MIME::Base64; - -extends 'NGCP::Panel::Utils::DeviceBootstrap::VendorREST'; - -sub rpc_server_params { - my $self = shift; - my $cfg = { - proto => 'https', - host => 'api.eds.sipwise.com', - port => '443', - path => 'api', - }; - $self->{rpc_server_params} = $cfg; - return $self->{rpc_server_params}; -} - -sub register_model { - my($self) = @_; - $self->rpc_server_params; - my $c = $self->params->{c}; - - $c->log->error("++++ SipwiseProfile register_model"); - - my $cfg = $self->{rpc_server_params}; - my $redirect_url = $self->get_config_uri(); - - # first, fetch profile from eds - my $url = "$$cfg{proto}://$$cfg{host}:$$cfg{port}/$$cfg{path}/profiles?q=ngcp"; - $c->log->debug("SipwiseProfile check profile '$url'"); - my $req = HTTP::Request->new(GET => $url); - $req->header(%{$self->get_basic_authorization($self->params->{credentials})}); - my $res = $self->_ua->request($req); - my $prof; - - if ($res->is_success) { - $c->log->debug("SipwiseProfile check profile query successful, data: " . $res->decoded_content); - my $data = decode_json($res->decoded_content); - if (ref $data eq 'HASH' && exists $data->{data} && ref $data->{data} eq 'ARRAY' && @{ $data->{data} }) { - # profile exists, nothing to do - $prof = shift @{ $data->{data} }; - } elsif (ref $data eq 'HASH' && exists $data->{data} && ref $data->{data} eq 'ARRAY' && @{ $data->{data} } == 0) { - # profile does not exist, create it - $c->log->debug("SipwiseProfile ngcp profile not available for this reseller, create it"); - - # first we need to create the blob containing the - # server's ca cert - my $cert = $c->model('CA')->get_server_ca_cert($c); - $c->log->debug("SipwiseProfile got ca cert, encode"); - my $cacert = encode_base64($cert); - $c->log->debug("SipwiseProfile got encoded ca cert, send"); - $url = "$$cfg{proto}://$$cfg{host}:$$cfg{port}/$$cfg{path}/blobs"; - $c->log->debug("SipwiseProfile create blob '$url'"); - my $req = HTTP::Request->new(POST => $url); - $req->header(%{$self->get_basic_authorization($self->params->{credentials})}); - $req->content(encode_json({ data => { name => 'ngcp-ca-cert.pem', b64body => $cacert, content_type => 'application/octet-stream' } })); - $req->content_type('application/json'); - $res = $self->_ua->request($req); - if ($res->is_success) { - $c->log->debug("SipwiseProfile create blob query successful"); - } else { - $c->log->error("SipwiseProfile create blob query failed (" . $res->status_line . "): " . $res->decoded_content); - return; - } - - # now create the profile, referring to the blob and the - # server's provisioning url - my $profile_body = "<\/settings>"; - - $url = "$$cfg{proto}://$$cfg{host}:$$cfg{port}/$$cfg{path}/profiles"; - $c->log->debug("SipwiseProfile create profile '$url'"); - $req = HTTP::Request->new(POST => $url); - $req->header(%{$self->get_basic_authorization($self->params->{credentials})}); - $req->content(encode_json({ data => { body => $profile_body, content_type => 'text/xml', description => 'ngcp' } })); - $req->content_type('application/json'); - $res = $self->_ua->request($req); - if ($res->is_success) { - $c->log->debug("SipwiseProfile create profile query successful, data: " . $res->decoded_content); - $data = decode_json($res->decoded_content); - if (ref $data eq 'HASH' && exists $data->{data} && ref $data->{data} eq 'HASH') { - $prof = $data->{data}; - } else { - $c->log->error("SipwiseProfile create profile query failed with invalid data: " . $res->decoded_content); - return; - } - } else { - $c->log->error("SipwiseProfile create profile query failed (" . $res->status_line . "): " . $res->decoded_content); - return; - } - } else { - $c->log->error("SipwiseProfile check profile query failed due to invalid body"); - return; - } - } else { - $c->log->error("SipwiseProfile fetch profile query failed (" . $res->status_line . "): " . $res->decoded_content); - return; - } - - return 1; -} - - -sub rest_prepare_request { - my ($self, $action) = @_; - my $c = $self->params->{c}; - my $ret; - my $new_mac = $self->content_params->{mac}; - my $old_mac = $self->content_params->{mac_old}; - - $self->{rpc_server_params} //= $self->rpc_server_params; - my $cfg = $self->{rpc_server_params}; - - $c->log->debug("SipwiseProfile prepare request for action $action"); - - if ($action eq 'register_content') { - - # first, fetch profile from eds - my $url = "$$cfg{proto}://$$cfg{host}:$$cfg{port}/$$cfg{path}/profiles?q=ngcp"; - $c->log->debug("SipwiseProfile check profile '$url'"); - my $req = HTTP::Request->new(GET => $url); - $req->header(%{$self->get_basic_authorization($self->params->{credentials})}); - my $res = $self->_ua->request($req); - my $prof; - - if ($res->is_success) { - $c->log->debug("SipwiseProfile check profile query successful, data: " . $res->decoded_content); - my $data = decode_json($res->decoded_content); - if (ref $data eq 'HASH' && exists $data->{data} && ref $data->{data} eq 'ARRAY' && @{ $data->{data} }) { - # profile exists, nothing to do - $prof = shift @{ $data->{data} }; - } elsif (ref $data eq 'HASH' && exists $data->{data} && ref $data->{data} eq 'ARRAY' && @{ $data->{data} } == 0) { - $c->log->error("SipwiseProfile ngcp profile does not exist"); - return; - } else { - $c->log->error("SipwiseProfile check profile query failed due to invalid body"); - return; - } - $ret = { - method =>'POST', - url => "$$cfg{proto}://$$cfg{host}:$$cfg{port}/$$cfg{path}/devices", - body => { data => { mac => $new_mac, profile_id => $prof->{id}, url => undef} }, - }; - } else { - $c->log->error("SipwiseProfile unregister query failed (" . $res->status_line . "): " . $res->decoded_content); - return; - } - } elsif ($action eq 'unregister_content') { - # we've to fetch the id first before constructing the delete request - my $url = "$$cfg{proto}://$$cfg{host}:$$cfg{port}/$$cfg{path}/devices?q=$old_mac"; - $c->log->debug("SipwiseProfile unregister via url '$url'"); - my $req = HTTP::Request->new(GET => $url); - $req->header(%{$self->get_basic_authorization($self->params->{credentials})}); - my $res = $self->_ua->request($req); - if ($res->is_success) { - $c->log->debug("SipwiseProfile unregister query successful, data: " . $res->decoded_content); - my $data = decode_json($res->decoded_content); - my $dev; - if (ref $data eq 'HASH' && exists $data->{data} && ref $data->{data} eq 'ARRAY' && @{ $data->{data} }) { - $dev = shift @{ $data->{data} }; - } else { - $c->log->error("SipwiseProfile unregister query failed due to invalid body"); - return; - } - $ret = { - method =>'DELETE', - url => "$$cfg{proto}://$$cfg{host}:$$cfg{port}/$$cfg{path}/devices/$$dev{id}", - body => undef, - }; - } else { - $c->log->error("SipwiseProfile unregister query failed (" . $res->status_line . "): " . $res->decoded_content); - return; - } - } - - - return $ret; -} - -1; - -# vim: set tabstop=4 expandtab: diff --git a/lib/NGCP/Panel/Utils/DeviceBootstrap/SipwiseRedirect.pm b/lib/NGCP/Panel/Utils/DeviceBootstrap/SipwiseRedirect.pm deleted file mode 100644 index ddfc9801da..0000000000 --- a/lib/NGCP/Panel/Utils/DeviceBootstrap/SipwiseRedirect.pm +++ /dev/null @@ -1,76 +0,0 @@ -package NGCP::Panel::Utils::DeviceBootstrap::SipwiseRedirect; - -use strict; -use warnings; - -use URI::Escape; -use Moo; -use Types::Standard qw(Str); -use JSON qw/encode_json decode_json/; - -extends 'NGCP::Panel::Utils::DeviceBootstrap::VendorREST'; - -sub rpc_server_params { - my $self = shift; - my $cfg = { - proto => 'https', - host => 'api.eds.sipwise.com', - port => '443', - path => 'api', - }; - $self->{rpc_server_params} = $cfg; - return $self->{rpc_server_params}; -} - -sub rest_prepare_request { - my ($self, $action) = @_; - my $c = $self->params->{c}; - my $ret; - my $new_mac = $self->content_params->{mac}; - my $old_mac = $self->content_params->{mac_old}; - my $redirect_url = $self->get_bootstrap_uri(); - - $self->{rpc_server_params} //= $self->rpc_server_params; - my $cfg = $self->{rpc_server_params}; - - if ($action eq 'register_content') { - $ret = { - method =>'POST', - url => "$$cfg{proto}://$$cfg{host}:$$cfg{port}/$$cfg{path}/devices", - body => { data => { mac => $new_mac, profile_id => undef, url => $redirect_url} }, - }; - } elsif ($action eq 'unregister_content') { - # we've to fetch the id first before constructing the delete request - my $url = "$$cfg{proto}://$$cfg{host}:$$cfg{port}/$$cfg{path}/devices?q=$old_mac"; - $c->log->debug("SipwiseRedirect unregister via url '$url'"); - my $req = HTTP::Request->new(GET => $url); - $req->header(%{$self->get_basic_authorization($self->params->{credentials})}); - my $res = $self->_ua->request($req); - if ($res->is_success) { - $c->log->debug("SipwiseRedirect unregister query successful, data: " . $res->decoded_content); - my $data = decode_json($res->decoded_content); - my $dev; - if (ref $data eq 'HASH' && exists $data->{data} && ref $data->{data} eq 'ARRAY' && @{ $data->{data} }) { - $dev = shift @{ $data->{data} }; - } else { - $c->log->error("SipwiseRedirect unregister query failed due to invalid body"); - return; - } - $ret = { - method =>'DELETE', - url => "$$cfg{proto}://$$cfg{host}:$$cfg{port}/$$cfg{path}/devices/$$dev{id}", - body => undef, - }; - } else { - $c->log->error("SipwiseRedirect unregister query failed (" . $res->status_line . "): " . $res->decoded_content); - return; - } - } - - - return $ret; -} - -1; - -# vim: set tabstop=4 expandtab: