From 62581f99e45f8c738aff0bd1766bd32152b412f0 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Mon, 19 May 2014 20:59:17 +0100 Subject: [PATCH 1/3] Improve VLAN Inventory performance and show all VLANs (C. Stromsoe) --- Netdisco/Changes | 6 ++++++ .../App/Netdisco/Web/Plugin/Report/VlanInventory.pm | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Netdisco/Changes b/Netdisco/Changes index dc235650..22573345 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -1,3 +1,9 @@ +2.027005 - 2014-05-15 + + [BUG FIXES] + + * Improve VLAN Inventory performance and show all VLANs (C. Stromsoe) + 2.027004 - 2014-05-15 [BUG FIXES] diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/VlanInventory.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/VlanInventory.pm index fcd6bc2c..ff14bd1c 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/VlanInventory.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/VlanInventory.pm @@ -16,19 +16,19 @@ register_report( get '/ajax/content/report/vlaninventory' => require_login sub { my $set = schema('netdisco')->resultset('DeviceVlan')->search( - { 'vlan.description' => { '!=', 'NULL' } }, + { 'me.description' => { '!=', 'NULL' } }, { join => { 'ports' => 'vlan' }, select => [ - 'vlan.vlan', - 'vlan.description', + 'me.vlan', + 'me.description', { count => { distinct => 'ports.ip' } }, { count => 'ports.vlan' } ], as => [qw/ vlan description dcount pcount /], - group_by => [qw/ vlan.vlan vlan.description /], + group_by => [qw/ me.vlan me.description /], } ); - return unless $set->count; + return unless $set->has_rows; if ( request->is_ajax ) { template 'ajax/report/vlaninventory.tt', { results => $set, }, From ef4a94ae79c759c2ae96ad8183c2ddf9222d3c0f Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Wed, 21 May 2014 19:40:31 +0100 Subject: [PATCH 2/3] Support offline update of oui.txt and MIBs bundle --- Netdisco/Changes | 4 +++ Netdisco/Makefile.PL | 1 + Netdisco/bin/netdisco-deploy | 27 ++++++++++++++----- Netdisco/lib/App/Netdisco.pm | 4 ++- .../lib/App/Netdisco/Manual/Deployment.pod | 26 ++++++++++++++++++ 5 files changed, 54 insertions(+), 8 deletions(-) diff --git a/Netdisco/Changes b/Netdisco/Changes index 22573345..94f55686 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -1,5 +1,9 @@ 2.027005 - 2014-05-15 + [ENHANCEMENTS] + + * Support offline update of oui.txt and MIBs bundle + [BUG FIXES] * Improve VLAN Inventory performance and show all VLANs (C. Stromsoe) diff --git a/Netdisco/Makefile.PL b/Netdisco/Makefile.PL index b51175a8..4e2e7d6c 100644 --- a/Netdisco/Makefile.PL +++ b/Netdisco/Makefile.PL @@ -20,6 +20,7 @@ requires 'Dancer::Plugin::DBIC' => 0.2001; requires 'Dancer::Plugin::Auth::Extensible' => 0.30; requires 'Dancer::Plugin::Passphrase' => '2.0.1'; requires 'File::ShareDir' => 1.03; +requires 'File::Slurp' => 9999.19; requires 'Guard' => 1.022; requires 'HTML::Parser' => 3.70; requires 'HTTP::Tiny' => 0.029; diff --git a/Netdisco/bin/netdisco-deploy b/Netdisco/bin/netdisco-deploy index 7a6b57c0..bb0f5a7c 100755 --- a/Netdisco/bin/netdisco-deploy +++ b/Netdisco/bin/netdisco-deploy @@ -50,6 +50,7 @@ use Term::ANSIColor; use Archive::Extract; $Archive::Extract::PREFER_BIN = 1; +use File::Slurp (); use HTTP::Tiny; use Digest::MD5; use Try::Tiny; @@ -182,13 +183,20 @@ sub deploy_db { sub deploy_oui { my $schema = schema('netdisco'); $schema->storage->disconnect; - - my $url = 'http://standards.ieee.org/develop/regauth/oui/oui.txt'; - my $resp = HTTP::Tiny->new->get($url); + my @lines = (); my %data = (); - if ($resp->{success}) { - foreach my $line (split /\n/, $resp->{content}) { + if (@ARGV) { + @lines = File::Slurp::read_file($ARGV[0], err_mode => 'quiet'); + } + else { + my $url = 'http://standards.ieee.org/develop/regauth/oui/oui.txt'; + my $resp = HTTP::Tiny->new->get($url); + @lines = split /\n/, $resp->{content}; + } + + if (scalar @lines) { + foreach my $line (@lines) { if ($line =~ m/^\s*(.{2}-.{2}-.{2})\s+\(hex\)\s+(.*)\s*$/i) { my ($oui, $company) = ($1, $2); $oui =~ s/-/:/g; @@ -211,10 +219,15 @@ sub deploy_oui { ]); }); } + + print color 'bold blue'; + say 'OUI update complete.'; + } + else { + print color 'bold red'; + say 'OUI update failed.'; } - print color 'bold blue'; - say 'OUI update complete.'; print color 'reset'; } diff --git a/Netdisco/lib/App/Netdisco.pm b/Netdisco/lib/App/Netdisco.pm index b6d28d9b..e24ff071 100644 --- a/Netdisco/lib/App/Netdisco.pm +++ b/Netdisco/lib/App/Netdisco.pm @@ -212,7 +212,9 @@ take care of all this for you: ~/bin/netdisco-deploy -If this is a new installation of Netdisco 2, answer yes to all questions. +If this is a new installation of Netdisco 2, answer yes to all questions. If +you wish to deploy without Internet access, see the +L documentation. =head1 Startup diff --git a/Netdisco/lib/App/Netdisco/Manual/Deployment.pod b/Netdisco/lib/App/Netdisco/Manual/Deployment.pod index a340ea63..162c39e7 100644 --- a/Netdisco/lib/App/Netdisco/Manual/Deployment.pod +++ b/Netdisco/lib/App/Netdisco/Manual/Deployment.pod @@ -28,6 +28,32 @@ the database service): # TYPE DATABASE USER ADDRESS METHOD host all all 127.0.0.1/32 md5 +=head1 Deploy without Internet access + +The C script asks for Internet access but it is possible to +install off-line. You should download the following two files: + +=over 4 + +=item * + +http://standards.ieee.org/develop/regauth/oui/oui.txt + +=item * + +http://downloads.sourceforge.net/project/netdisco/netdisco-mibs/latest-snapshot/netdisco-mibs-snapshot.tar.gz + +=back + +Run the C script but pass the OUI file name as a parameter on +the command line: + + ~/bin/netdisco-deploy ./oui.txt + +Then answer yes to questions, even though you're not connected to the +Internet. For the MIBs you can simply extract the downloaded archive to the +home directory of Netdisco. + =head1 Relocating the Installation The installation process installs Netdisco self-contained to your home From ffcf6ed0990c862a78f9391cb23f9c697e58ce71 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Wed, 21 May 2014 20:36:00 +0100 Subject: [PATCH 3/3] Support Dancer::Debug at runtime with DANCER_DEBUG=1 env var --- Netdisco/Changes | 1 + Netdisco/bin/netdisco-web-fg | 10 +++++++--- Netdisco/lib/App/Netdisco/Manual/Deployment.pod | 12 ++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Netdisco/Changes b/Netdisco/Changes index 94f55686..92ef0a81 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -3,6 +3,7 @@ [ENHANCEMENTS] * Support offline update of oui.txt and MIBs bundle + * Support Dancer::Debug at runtime with DANCER_DEBUG=1 env var [BUG FIXES] diff --git a/Netdisco/bin/netdisco-web-fg b/Netdisco/bin/netdisco-web-fg index f0d53bf7..7b31bf26 100755 --- a/Netdisco/bin/netdisco-web-fg +++ b/Netdisco/bin/netdisco-web-fg @@ -38,9 +38,13 @@ set plack_middlewares => [ pass_through => 1, )], # install Dancer::Debug for this... - #[ Debug => ( - # panels => [qw/Dancer::Settings Parameters Dancer::Version DBITrace/], - #)], + ( + $ENV{DANCER_DEBUG} ? + [ Debug => ( + panels => [qw/Dancer::Settings Parameters Dancer::Version DBITrace/], + )] + : () + ) ]; use App::Netdisco::Web; diff --git a/Netdisco/lib/App/Netdisco/Manual/Deployment.pod b/Netdisco/lib/App/Netdisco/Manual/Deployment.pod index 162c39e7..0ae7c5fa 100644 --- a/Netdisco/lib/App/Netdisco/Manual/Deployment.pod +++ b/Netdisco/lib/App/Netdisco/Manual/Deployment.pod @@ -136,6 +136,18 @@ You are instead recommended to run C behind a reverse proxy as described elsewhere in this document. Apache can easily act as an SSL reverse proxy. +=head1 Debug Tricks + +You can see what HTTP Headers are received by Netdisco, and other information +such as how it's parsing the config file, by enabling the Dancer debug plugin. +First download the plugin: + + ~/bin/localenv cpanm --notest Dancer::Debug + +Then run the web daemon with the environment variable to enable the feature: + + DANCER_DEBUG=1 ~/bin/netdisco-web restart + =head1 Further Reading... Other ways to run and host the web application can be found in the