diff --git a/lib/App/Netdisco/DB/ResultSet/Device.pm b/lib/App/Netdisco/DB/ResultSet/Device.pm index 23a3ee1c..993733cf 100644 --- a/lib/App/Netdisco/DB/ResultSet/Device.pm +++ b/lib/App/Netdisco/DB/ResultSet/Device.pm @@ -709,8 +709,8 @@ sub delete { { ip => { '-in' => $devices->as_query } }, )->delete; - Dancer::Logger::debug sprintf ' [%s] db/device - removed %d %s from %s', - $ip, $gone, _plural($gone), $set if defined Dancer::Logger::logger(); + Dancer::Logger::debug( sprintf( ' [%s] db/device - removed %d %s from %s', + $ip, $gone, _plural($gone), $set ) ) if defined Dancer::Logger::logger(); } foreach my $set (qw/ @@ -729,8 +729,8 @@ sub delete { ], })->delete; - Dancer::Logger::debug sprintf ' [%s] db/device - removed %d manual topology %s', - $ip, $gone, _plural($gone) if defined Dancer::Logger::logger(); + Dancer::Logger::debug( sprintf( ' [%s] db/device - removed %d manual topology %s', + $ip, $gone, _plural($gone) ) ) if defined Dancer::Logger::logger(); $schema->resultset('DevicePort')->search( { ip => { '-in' => $devices->as_query } }, diff --git a/lib/App/Netdisco/DB/ResultSet/DevicePort.pm b/lib/App/Netdisco/DB/ResultSet/DevicePort.pm index 30afb730..7a18b9a2 100644 --- a/lib/App/Netdisco/DB/ResultSet/DevicePort.pm +++ b/lib/App/Netdisco/DB/ResultSet/DevicePort.pm @@ -262,8 +262,8 @@ sub delete { { ip => { '-in' => $ports->as_query }}, )->delete; - Dancer::Logger::debug sprintf ' [%s] db/ports - removed %d port %s from %s', - $ip, $gone, _plural($gone), $set if defined Dancer::Logger::logger(); + Dancer::Logger::debug( sprintf( ' [%s] db/ports - removed %d port %s from %s', + $ip, $gone, _plural($gone), $set ) ) if defined Dancer::Logger::logger(); } $schema->resultset('Node')->search( diff --git a/lib/App/Netdisco/JobQueue.pm b/lib/App/Netdisco/JobQueue.pm index 7e5448bd..e2b71ccf 100644 --- a/lib/App/Netdisco/JobQueue.pm +++ b/lib/App/Netdisco/JobQueue.pm @@ -2,9 +2,14 @@ package App::Netdisco::JobQueue; use Dancer qw/:moose :syntax :script/; +BEGIN { + $ENV{ND_QUEUE_ENGINE} ||= + setting('workers') ? setting('workers')->{queue} : 'PostgreSQL'; +} + use Module::Load (); Module::Load::load - 'App::Netdisco::JobQueue::' . setting('workers')->{queue} => ':all'; + 'App::Netdisco::JobQueue::' . $ENV{ND_QUEUE_ENGINE} => ':all'; use base 'Exporter'; our @EXPORT = (); diff --git a/lib/App/Netdisco/Web/API/Objects.pm b/lib/App/Netdisco/Web/API/Objects.pm index 68eaf9c8..9b44ae42 100644 --- a/lib/App/Netdisco/Web/API/Objects.pm +++ b/lib/App/Netdisco/Web/API/Objects.pm @@ -9,7 +9,7 @@ use Try::Tiny; swagger_path { tags => ['Objects'], - path => setting('api_base').'/object/device/{ip}', + path => (setting('api_base') || '').'/object/device/{ip}', description => 'Returns a row from the device table', parameters => [ ip => { @@ -28,7 +28,7 @@ swagger_path { foreach my $rel (qw/device_ips vlans ports modules port_vlans wireless_ports ssids powered_ports/) { swagger_path { tags => ['Objects'], - path => setting('api_base')."/object/device/{ip}/$rel", + path => (setting('api_base') || '')."/object/device/{ip}/$rel", description => "Returns $rel rows for a given device", parameters => [ ip => { @@ -49,7 +49,7 @@ foreach my $rel (qw/nodes active_nodes nodes_with_age active_nodes_with_age vlan swagger_path { tags => ['Objects'], description => "Returns $rel rows for a given port", - path => setting('api_base')."/object/device/{ip}/port/{port}/$rel", + path => (setting('api_base') || '')."/object/device/{ip}/port/{port}/$rel", parameters => [ ip => { description => 'Canonical IP of the Device. Use Search methods to find this.', @@ -76,7 +76,7 @@ foreach my $rel (qw/power properties ssid wireless agg_master neighbor last_node swagger_path { tags => ['Objects'], description => "Returns the related $rel table entry for a given port", - path => setting('api_base')."/object/device/{ip}/port/{port}/$rel", + path => (setting('api_base') || '')."/object/device/{ip}/port/{port}/$rel", parameters => [ ip => { description => 'Canonical IP of the Device. Use Search methods to find this.', @@ -103,7 +103,7 @@ foreach my $rel (qw/power properties ssid wireless agg_master neighbor last_node swagger_path { tags => ['Objects'], description => 'Returns a row from the device_port table', - path => setting('api_base').'/object/device/{ip}/port/{port}', + path => (setting('api_base') || '').'/object/device/{ip}/port/{port}', parameters => [ ip => { description => 'Canonical IP of the Device. Use Search methods to find this.', @@ -127,7 +127,7 @@ swagger_path { swagger_path { tags => ['Objects'], - path => setting('api_base').'/object/device/{ip}/nodes', + path => (setting('api_base') || '').'/object/device/{ip}/nodes', description => "Returns the nodes found on a given Device", parameters => [ ip => { @@ -153,7 +153,7 @@ swagger_path { swagger_path { tags => ['Objects'], - path => setting('api_base').'/object/vlan/{vlan}/nodes', + path => (setting('api_base') || '').'/object/vlan/{vlan}/nodes', description => "Returns the nodes found in a given VLAN", parameters => [ vlan => { diff --git a/lib/App/Netdisco/Web/AuthN.pm b/lib/App/Netdisco/Web/AuthN.pm index 95bc8d24..71fc8d05 100644 --- a/lib/App/Netdisco/Web/AuthN.pm +++ b/lib/App/Netdisco/Web/AuthN.pm @@ -5,6 +5,7 @@ use Dancer::Plugin::DBIC; use Dancer::Plugin::Auth::Extensible; use Dancer::Plugin::Swagger; +use App::Netdisco; # a safe noop but needed for standalone testing use App::Netdisco::Util::Web 'request_is_api'; use MIME::Base64; @@ -85,7 +86,7 @@ hook 'before' => sub { swagger_path { description => 'Obtain an API Key', tags => ['General'], - path => setting('url_base')->with('/login')->path, + path => (setting('url_base') ? setting('url_base')->with('/login')->path : '/login'), parameters => [], responses => { default => { examples => { 'application/json' => { api_key => 'cc9d5c02d8898e5728b7d7a0339c0785' } } }, @@ -159,14 +160,14 @@ post '/login' => sub { # ugh, *puke*, but D::P::Swagger has no way to set this with swagger_path # must be after the path is declared, above. Dancer::Plugin::Swagger->instance->doc - ->{paths}->{ setting('url_base')->with('/login')->path } + ->{paths}->{ (setting('url_base') ? setting('url_base')->with('/login')->path : '/login') } ->{post}->{security}->[0]->{BasicAuth} = []; # we override the default login_handler, so logout has to be handled as well swagger_path { description => 'Destroy user API Key and session cookie', tags => ['General'], - path => setting('url_base')->with('/logout')->path, + path => (setting('url_base') ? setting('url_base')->with('/logout')->path : '/logout'), parameters => [], responses => { default => { examples => { 'application/json' => {} } } }, },