From dfeacd12e22cb6a512da60f407358c6f71f8ee0b Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 9 Jun 2013 11:30:06 +0100 Subject: [PATCH] several bug fixes --- Netdisco/META.yml | 3 +- Netdisco/Makefile.PL | 1 + Netdisco/bin/netdisco-daemon-fg | 2 +- Netdisco/bin/netdisco-deploy | 2 +- Netdisco/lib/App/Netdisco.pm | 37 ++++++++++++++++------- Netdisco/lib/App/Netdisco/Daemon/Queue.pm | 2 +- Netdisco/lib/App/Netdisco/Util/SNMP.pm | 2 +- Netdisco/lib/App/Netdisco/Web/AuthN.pm | 3 +- Netdisco/share/views/js/admintask.js | 19 +++++------- 9 files changed, 42 insertions(+), 29 deletions(-) diff --git a/Netdisco/META.yml b/Netdisco/META.yml index 06f403d4..d8c88685 100644 --- a/Netdisco/META.yml +++ b/Netdisco/META.yml @@ -50,6 +50,7 @@ requires: Starman: 0.3008 Template: 2.24 YAML: 0.84 + YAML::XS: 0.41 namespace::clean: 0.24 perl: 5.10.0 version: 0.9902 @@ -59,4 +60,4 @@ resources: homepage: http://netdisco.org/ license: http://opensource.org/licenses/bsd-license.php repository: git://git.code.sf.net/p/netdisco/netdisco-ng -version: 2.007000_003 +version: 2.007000_004 diff --git a/Netdisco/Makefile.PL b/Netdisco/Makefile.PL index 8898d0ca..ec98fac5 100644 --- a/Netdisco/Makefile.PL +++ b/Netdisco/Makefile.PL @@ -35,6 +35,7 @@ requires 'SNMP::Info' => 3.01; requires 'SQL::Translator' => 0.11016; requires 'Template' => 2.24; requires 'YAML' => 0.84; +requires 'YAML::XS' => 0.41; requires 'namespace::clean' => 0.24; requires 'version' => 0.9902; diff --git a/Netdisco/bin/netdisco-daemon-fg b/Netdisco/bin/netdisco-daemon-fg index 3ce39b0c..e8046468 100755 --- a/Netdisco/bin/netdisco-daemon-fg +++ b/Netdisco/bin/netdisco-daemon-fg @@ -71,7 +71,7 @@ sub build_tasks_list { info sprintf "MCE will load %s tasks: %s Manager, %s Scheduler, %s Poller, %s Interactive", (scalar @$tasks), - ((setting('workers')-{pollers} or setting('workers')->{interactives}) ? 1 : 0), + ((setting('workers')->{pollers} or setting('workers')->{interactives}) ? 1 : 0), (setting('housekeeping') ? 1 : 0), (setting('workers')->{pollers} || 0), (setting('workers')->{interactives} || 0); diff --git a/Netdisco/bin/netdisco-deploy b/Netdisco/bin/netdisco-deploy index 65edb676..570eda0e 100755 --- a/Netdisco/bin/netdisco-deploy +++ b/Netdisco/bin/netdisco-deploy @@ -73,11 +73,11 @@ for its use. say 'This is the Netdisco II deployment script.'; say ''; say 'Before we continue, the following prerequisites must be in place:'; -say ' * Internet access'; say ' * Database added to PostgreSQL for Netdisco'; say ' * User added to PostgreSQL with rights to the Netdisco Database'; say ' * "~/environments/deployment.yml" file configured with Database dsn/user/pass'; say ' * A full backup of any existing Netdisco database data'; +say ' * Internet access (for OUIs and MIBs)'; say ''; say 'You will be asked to confirm all changes to your system.'; say ''; diff --git a/Netdisco/lib/App/Netdisco.pm b/Netdisco/lib/App/Netdisco.pm index 4adb7ffb..dd9359ec 100644 --- a/Netdisco/lib/App/Netdisco.pm +++ b/Netdisco/lib/App/Netdisco.pm @@ -7,7 +7,7 @@ use 5.010_000; use File::ShareDir 'dist_dir'; use Path::Class; -our $VERSION = '2.007000_003'; +our $VERSION = '2.007000_004'; BEGIN { if (not length ($ENV{DANCER_APPDIR} || '') @@ -28,6 +28,15 @@ BEGIN { $ENV{DANCER_PUBLIC} ||= $auto->subdir('public')->stringify; $ENV{DANCER_VIEWS} ||= $auto->subdir('views')->stringify; } + + { + # Dancer 1 uses the broken YAML.pm module + # This is a global sledgehammer - could just apply to Dancer::Config + use YAML; + use YAML::XS; + no warnings 'redefine'; + *YAML::LoadFile = sub { goto \&YAML::XS::LoadFile }; + } } =head1 NAME @@ -41,10 +50,9 @@ network management tool. Pieces are still missing however, so if you're a new user please see L for further information on the project and how to download the current official release. -L provides a web frontend and a backend daemon to handle -interactive requests such as changing port or device properties. There is not -yet a device poller, so please still use the old Netdisco's discovery, arpnip, -and macsuck. +L provides a web frontend with built-in web server, and a +backend daemon to handle interactive requests such as changing port or device +properties. If you have any trouble getting the frontend running, speak to someone in the C<#netdisco> IRC channel (on freenode). Before installing or upgrading please @@ -131,6 +139,8 @@ take care of all this for you: ~/bin/netdisco-deploy +Answer yes to all questions, if this is a new installation of Netdisco 2. + =head1 Startup Run the following command to start the web-app server as a backgrounded daemon @@ -138,12 +148,17 @@ Run the following command to start the web-app server as a backgrounded daemon ~/bin/netdisco-web start +If the Inventory is empty because this is a new installation, you probably +want to either run some polling jobs from the command-line, or give a web user +some admin rights (see L, below). + Run the following command to start the job control daemon (port control, etc): ~/bin/netdisco-daemon start You should take care not to run this Netdisco daemon and the legacy daemon at -the same time. +the same time. Similarly, if you use the device discovery with Netdisco 2, +disable your system's cron jobs for the Netdisco 1 poller. =head1 Upgrading @@ -153,13 +168,13 @@ Notes|App::Netdisco::Manual::ReleaseNotes>. Then, the process is as follows: # upgrade Netdisco ~/bin/localenv cpanm --notest App::Netdisco - # apply database schema updates (optionally, get latest OIDs/MIBs) + # apply database schema updates ~/bin/netdisco-deploy # restart web service ~/bin/netdisco-web restart - # optionally, restart job daemon if you use it + # restart job daemon (if you use it) ~/bin/netdisco-daemon restart =head1 Tips and Tricks @@ -172,8 +187,8 @@ or MAC addreses, VLAN numbers, and so on. =head2 User Rights -When user authentication is disabled (C) the default username is -"guest", which has no special privilege. To grant port and device control +When user authentication is disabled (C) the default username +is "guest", which has no special privilege. To grant port and device control rights to this user, create a row in the C table of the Netdisco database with a username of C and appropriate flags set to true: @@ -237,7 +252,7 @@ Oliver Gorwits =head1 COPYRIGHT AND LICENSE -This software is copyright (c) 2012 by The Netdisco Developer Team. +This software is copyright (c) 2012, 2013 by The Netdisco Developer Team. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/Netdisco/lib/App/Netdisco/Daemon/Queue.pm b/Netdisco/lib/App/Netdisco/Daemon/Queue.pm index c5ae3a8d..803d7086 100644 --- a/Netdisco/lib/App/Netdisco/Daemon/Queue.pm +++ b/Netdisco/lib/App/Netdisco/Daemon/Queue.pm @@ -52,7 +52,7 @@ sub capacity_for { my $current = $queue->search({role => $role})->count; - return ($current < setting('workers')->{$setting})); + return ($current < setting('workers')->{$setting}); } sub take_jobs { diff --git a/Netdisco/lib/App/Netdisco/Util/SNMP.pm b/Netdisco/lib/App/Netdisco/Util/SNMP.pm index a2703288..d4afee09 100644 --- a/Netdisco/lib/App/Netdisco/Util/SNMP.pm +++ b/Netdisco/lib/App/Netdisco/Util/SNMP.pm @@ -147,7 +147,7 @@ sub _try_connect { } sub _build_mibdirs { - my $home = (setting('mibhome') || $ENV{NETDISCO_HOME} || $ENV{HOME}); + my $home = (setting('mibhome') || dir(($ENV{NETDISCO_HOME} || $ENV{HOME}), 'netdisco-mibs')); return map { dir($home, $_) } @{ setting('mibdirs') || _get_mibdirs_content($home) }; } diff --git a/Netdisco/lib/App/Netdisco/Web/AuthN.pm b/Netdisco/lib/App/Netdisco/Web/AuthN.pm index 12afd6ef..62eb153d 100644 --- a/Netdisco/lib/App/Netdisco/Web/AuthN.pm +++ b/Netdisco/lib/App/Netdisco/Web/AuthN.pm @@ -20,7 +20,8 @@ hook 'before' => sub { ->find(session('user'))); # really just for dev work, to quieten the logs - var('user')->port_control(0) if setting('no_port_control'); + var('user')->port_control(0) + if var('user') and setting('no_port_control'); } }; diff --git a/Netdisco/share/views/js/admintask.js b/Netdisco/share/views/js/admintask.js index a8ac096c..5dd9997f 100644 --- a/Netdisco/share/views/js/admintask.js +++ b/Netdisco/share/views/js/admintask.js @@ -10,18 +10,13 @@ // but which cannot use jQuery delegation via .on() function inner_view_processing(tab) { - // reload this table every 10 seconds + // reload this table every 5 seconds if (tab == 'jobqueue') { - $('#nd_device-name').text('10'); - nd_timers.push(setTimeout(function() { $('#nd_device-name').text('9') }, 1000 )); - nd_timers.push(setTimeout(function() { $('#nd_device-name').text('8') }, 2000 )); - nd_timers.push(setTimeout(function() { $('#nd_device-name').text('7') }, 3000 )); - nd_timers.push(setTimeout(function() { $('#nd_device-name').text('6') }, 4000 )); - nd_timers.push(setTimeout(function() { $('#nd_device-name').text('5') }, 5000 )); - nd_timers.push(setTimeout(function() { $('#nd_device-name').text('4') }, 6000 )); - nd_timers.push(setTimeout(function() { $('#nd_device-name').text('3') }, 7000 )); - nd_timers.push(setTimeout(function() { $('#nd_device-name').text('2') }, 8000 )); - nd_timers.push(setTimeout(function() { $('#nd_device-name').text('1') }, 9000 )); + $('#nd_device-name').text('5'); + nd_timers.push(setTimeout(function() { $('#nd_device-name').text('4') }, 1000 )); + nd_timers.push(setTimeout(function() { $('#nd_device-name').text('3') }, 2000 )); + nd_timers.push(setTimeout(function() { $('#nd_device-name').text('2') }, 3000 )); + nd_timers.push(setTimeout(function() { $('#nd_device-name').text('1') }, 4000 )); nd_timers.push(setTimeout(function() { // clear any running timers for (var i = 0; i < nd_timers.length; i++) { @@ -29,7 +24,7 @@ } // reload the tab content $('#' + tab + '_form').trigger('submit'); - }, 10000)); + }, 5000)); } // activate typeahead on the topo boxes