diff --git a/Netdisco/Changes b/Netdisco/Changes index b13b6360..5beaec8e 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -1,17 +1,25 @@ 2.007000_002 - - * NOTE this version requires SNMP::Info 3.x - [NEW FEATURES] * Finally we have a discover/refresh daemon job :) * Also... a Scheduler which removes need for crontab installation * The netdisco-do script can run a one-off discover for a device + * Can select MAC Address display format on Node and Device Port search + + [ENHANCEMENTS] + + * SNMP connection now uses cached info if available + * Better handling of MIBs home location in deploy script + * Port filter in device port display is now highlighted green + * Navbar search is fuzzier + * Phone node icon is a little phone handset [BUG FIXES] * Rename plugins developer doc to .pod * Update to latest Bootstrap and JQuery, and temp. fix #7326 in Bootstrap + * Partial Name in Port search now working 2.007000_001 - 2013-03-17 diff --git a/Netdisco/Makefile.PL b/Netdisco/Makefile.PL index db37bbb5..1d7c2bf7 100644 --- a/Netdisco/Makefile.PL +++ b/Netdisco/Makefile.PL @@ -4,38 +4,38 @@ name 'App-Netdisco'; license 'bsd'; all_from 'lib/App/Netdisco.pm'; -requires 'Algorithm::Cron' => 0; -requires 'App::cpanminus' => 0; -requires 'App::local::lib::helper' => 0; +requires 'Algorithm::Cron' => 0.07; +requires 'App::cpanminus' => 1.6108; +requires 'App::local::lib::helper' => 0.07; requires 'DBD::Pg' => 0; -requires 'DBD::SQLite' => 0; -requires 'DBIx::Class' => 0; -requires 'DBIx::Class::Helper::Row::SubClass' => 0; -requires 'Daemon::Control' => 0; -requires 'Dancer' => 1.3098; -requires 'Dancer::Plugin::DBIC' => 0; -requires 'File::ShareDir' => 0; -requires 'HTML::Entities' => 0; -requires 'HTTP::Tiny' => 0; +requires 'DBD::SQLite' => 1.37; +requires 'DBIx::Class' => 0.08210; +requires 'DBIx::Class::Helpers' => 2.016006; +requires 'Daemon::Control' => 0.001000; +requires 'Dancer' => 1.3112; +requires 'Dancer::Plugin::DBIC' => 0.1802; +requires 'File::ShareDir' => 1.03; +requires 'HTML::Parser' => 3.70; +requires 'HTTP::Tiny' => 0.029; requires 'JSON' => 0; -requires 'List::MoreUtils' => 0; -requires 'Moo' => 0; -requires 'MCE' => 1.405; -requires 'Net::DNS' => 0; -requires 'Net::MAC' => 0; -requires 'NetAddr::IP' => '4.059'; -requires 'Path::Class' => 0; -requires 'Plack' => 1.0006; -requires 'Plack::Middleware::Expires' => 0; -requires 'Role::Tiny' => 0; -requires 'Socket6' => 0; -requires 'Starman' => 0; -requires 'SNMP::Info' => '3.01'; -requires 'SQL::Translator' => 0; -requires 'Template' => 0; -requires 'YAML' => 0; -requires 'namespace::clean' => 0; -requires 'version' => 0.9901; +requires 'List::MoreUtils' => 0.33; +requires 'Moo' => 1.001000; +requires 'MCE' => 1.408; +requires 'Net::DNS' => 0.72; +requires 'Net::MAC' => 2.103622; +requires 'NetAddr::IP' => 4.068; +requires 'Path::Class' => 0.32; +requires 'Plack' => 1.0023; +requires 'Plack::Middleware::Expires' => 0.03; +requires 'Role::Tiny' => 1.002005; +requires 'Socket6' => 0.23; +requires 'Starman' => 0.3008; +requires 'SNMP::Info' => 3.01; +requires 'SQL::Translator' => 0.11016; +requires 'Template::Toolkit' => 2.24; +requires 'YAML' => 0.84; +requires 'namespace::clean' => 0.24; +requires 'version' => 0.9902; install_share 'share'; diff --git a/Netdisco/bin/netdisco-deploy b/Netdisco/bin/netdisco-deploy index b3e9d863..a03bf1f2 100755 --- a/Netdisco/bin/netdisco-deploy +++ b/Netdisco/bin/netdisco-deploy @@ -42,6 +42,7 @@ use Term::UI; use Term::ReadLine; use Archive::Extract; +$Archive::Extract::PREFER_BIN = 1; use HTTP::Tiny; use Try::Tiny; @@ -96,15 +97,27 @@ deploy_db() if $bool; say ''; $bool = $term->ask_yn( - prompt => 'Would you like to download and update vendor MAC prefixes (OUI data)?', default => 'n', + prompt => 'Download and update vendor MAC prefixes (OUI data)?', default => 'n', ); deploy_oui() if $bool; say ''; -$bool = $term->ask_yn( - prompt => 'Would you like to download and update MIB files?', default => 'n', -); -deploy_mibs() if $bool; +my $default_mibhome = dir($home, 'netdisco-mibs'); +if (setting('mibhome') and setting('mibhome') ne $default_mibhome) { + my $mibhome = $term->get_reply( + print_me => "MIB home options:", + prompt => "Download and update MIB files to...?", + choices => [setting('mibhome'), $default_mibhome, 'Skip this.'], + default => 'Skip this.', + ); + deploy_mibs($mibhome) if $mibhome and $mibhome ne 'Skip this.'; +} +else { + $bool = $term->ask_yn( + prompt => "Download and update MIB files?", default => 'n', + ); + deploy_mibs($default_mibhome) if $bool; +} sub deploy_db { system 'netdisco-db-deploy'; @@ -142,13 +155,15 @@ sub deploy_oui { } sub deploy_mibs { + my $mibhome = dir(shift); + my $url = 'http://downloads.sourceforge.net/project/netdisco/netdisco-mibs/latest-snapshot/netdisco-mibs-snapshot.tar.gz'; my $file = file($home, 'netdisco-mibs-snapshot.tar.gz'); my $resp = HTTP::Tiny->new->mirror($url, $file); if ($resp->{success}) { my $ae = Archive::Extract->new(archive => $file, type => 'tgz'); - $ae->extract(to => $home); + $ae->extract(to => $mibhome->parent->stringify); unlink $file; } diff --git a/Netdisco/lib/App/Netdisco/DB/Result/Node.pm b/Netdisco/lib/App/Netdisco/DB/Result/Node.pm index bd91a6da..746e277e 100644 --- a/Netdisco/lib/App/Netdisco/DB/Result/Node.pm +++ b/Netdisco/lib/App/Netdisco/DB/Result/Node.pm @@ -7,6 +7,8 @@ package App::Netdisco::DB::Result::Node; use strict; use warnings; +use Net::MAC; + use base 'DBIx::Class::Core'; __PACKAGE__->table("node"); __PACKAGE__->add_columns( @@ -134,4 +136,12 @@ between the date stamp and time stamp. That is: sub time_last_stamp { return (shift)->get_column('time_last_stamp') } +=head2 net_mac + +Returns the C column instantiated into a L object. + +=cut + +sub net_mac { return Net::MAC->new(mac => (shift)->mac) } + 1; diff --git a/Netdisco/lib/App/Netdisco/DB/Result/NodeIp.pm b/Netdisco/lib/App/Netdisco/DB/Result/NodeIp.pm index 6711fbd9..2d451c63 100644 --- a/Netdisco/lib/App/Netdisco/DB/Result/NodeIp.pm +++ b/Netdisco/lib/App/Netdisco/DB/Result/NodeIp.pm @@ -7,6 +7,8 @@ package App::Netdisco::DB::Result::NodeIp; use strict; use warnings; +use Net::MAC; + use base 'DBIx::Class::Core'; __PACKAGE__->table("node_ip"); __PACKAGE__->add_columns( @@ -206,4 +208,12 @@ between the date stamp and time stamp. That is: sub time_last_stamp { return (shift)->get_column('time_last_stamp') } +=head2 net_mac + +Returns the C column instantiated into a L object. + +=cut + +sub net_mac { return Net::MAC->new(mac => (shift)->mac) } + 1; diff --git a/Netdisco/lib/App/Netdisco/Util/SNMP.pm b/Netdisco/lib/App/Netdisco/Util/SNMP.pm index 6e62c85a..ee294a65 100644 --- a/Netdisco/lib/App/Netdisco/Util/SNMP.pm +++ b/Netdisco/lib/App/Netdisco/Util/SNMP.pm @@ -147,7 +147,8 @@ sub _try_connect { } sub _build_mibdirs { - return map { dir(setting('mibhome'), $_) } + my $home = (setting('mibhome') || $ENV{NETDISCO_HOME} || $ENV{HOME}); + return map { dir($home, $_) } @{ setting('mibdirs') || [] }; } diff --git a/Netdisco/lib/App/Netdisco/Web/Device.pm b/Netdisco/lib/App/Netdisco/Web/Device.pm index 7155747b..7f2a5c66 100644 --- a/Netdisco/lib/App/Netdisco/Web/Device.pm +++ b/Netdisco/lib/App/Netdisco/Web/Device.pm @@ -51,6 +51,7 @@ hook 'before' => sub { if (not param('tab') or param('tab') ne 'ports') { params->{'age_num'} = 3; params->{'age_unit'} = 'months'; + params->{'mac_format'} = 'IEEE'; } }; @@ -62,8 +63,13 @@ hook 'before_template' => sub { tab => 'ports', age_num => 3, age_unit => 'months', + mac_format => 'IEEE', }); + # for Net::MAC method + $tokens->{mac_format_call} = 'as_'. params->{'mac_format'} + if params->{'mac_format'}; + foreach my $col (@{ var('port_columns') }) { next unless $col->{default} eq 'on'; $tokens->{device_ports}->query_param($col->{name}, 'checked'); diff --git a/Netdisco/lib/App/Netdisco/Web/Search.pm b/Netdisco/lib/App/Netdisco/Web/Search.pm index 4c09c038..939e071b 100644 --- a/Netdisco/lib/App/Netdisco/Web/Search.pm +++ b/Netdisco/lib/App/Netdisco/Web/Search.pm @@ -75,7 +75,7 @@ get '/search' => sub { params->{'tab'} = 'vlan'; } else { - my $nd = $s->resultset('Device')->search_aliases($q); + my $nd = $s->resultset('Device')->search_fuzzy($q); if ($nd and $nd->count) { if ($nd->count == 1) { diff --git a/Netdisco/share/config.yml b/Netdisco/share/config.yml index d0dd4f90..e8335960 100644 --- a/Netdisco/share/config.yml +++ b/Netdisco/share/config.yml @@ -3,7 +3,7 @@ # Web app env-related settings should go to environments/$env.yml -# Your application's name +# application's name appname: "Netdisco" # The default web layout to use for your application (located in @@ -33,7 +33,7 @@ engines: end_tag: '%]' PRE_CHOMP: 1 -# netdisco stuff (can be overidden in the environment .yml) +# Netdisco stuff (can be overidden in the environment .yml) web_plugins: - Inventory @@ -55,7 +55,12 @@ snmpver: 2 snmpretries: 2 snmptimeout: 1000000 -mibhome: /usr/share/netdisco/mibs +# If unset, Netdisco uses "NETDISCO_HOME/netdisco-mibs", assuming you're +# using the netdisco-deploy script to download MIBs there. Otherwise, set +# this, for example: +# +# mibhome: /usr/share/netdisco/mibs + mibdirs: - cisco - rfc diff --git a/Netdisco/share/environments/deployment.yml b/Netdisco/share/environments/deployment.yml index 4a86ea43..8015d90a 100644 --- a/Netdisco/share/environments/deployment.yml +++ b/Netdisco/share/environments/deployment.yml @@ -37,7 +37,6 @@ plugins: # local settings for Netdisco poller and port changes -mibhome: '/home/netdisco/netdisco-mibs' mibdirs: - cisco - rfc diff --git a/Netdisco/share/environments/development.yml b/Netdisco/share/environments/development.yml index 9bd1af97..9c08e46f 100644 --- a/Netdisco/share/environments/development.yml +++ b/Netdisco/share/environments/development.yml @@ -39,7 +39,6 @@ no_auth: 1 # local settings for Netdisco poller and port changes -mibhome: '/home/netdisco/netdisco-mibs' mibdirs: - cisco - rfc diff --git a/Netdisco/share/public/css/netdisco.css b/Netdisco/share/public/css/netdisco.css index 654ddf30..dd486147 100644 --- a/Netdisco/share/public/css/netdisco.css +++ b/Netdisco/share/public/css/netdisco.css @@ -252,6 +252,19 @@ td { width: 95px; } +/* set the MAC format drop-down width */ +#nd_mac_format { + margin-top: 4px; + width: 154px; +} + +/* set the MAC format drop-down width */ +#nd_node_mac_format { + margin-left: -2px; + margin-top: 4px; + width: 165px; +} + /* sidebar submit button width and spacing from Node Props */ .sidebar button { margin-top: 9px; @@ -266,13 +279,28 @@ td { /* little icon inside of search input fields */ .field_clear_icon, .field_copy_icon { position: absolute; - margin-left: 132px; + margin-left: 140px; + margin-top: 5px; z-index: 1; - padding: 7px; + padding: 0px; cursor: pointer; +} + +.field_copy_icon { color: #999; } +.field_clear_icon { + background-color: #A9DBA9; + color: #3A87AD; +} + + /* for the ports form, but the positioning is slightly different */ +#ports_form .field_clear_icon { + margin-left: 149px; + margin-top: 5px; +} + /* change highlighting for form fields which are being used in a search */ form .clearfix.success select { background-color: #A9DBA9; @@ -294,6 +322,11 @@ form .clearfix.success input { margin-bottom: 1px; } +.inputs-list i { + margin-right: 5px; + margin-left: 2px; +} + /* nudge content closer to the header labels in the sidebar */ .inputs-list li:first-child { padding-top: 3px !important; diff --git a/Netdisco/share/public/javascripts/netdisco.js b/Netdisco/share/public/javascripts/netdisco.js index 137996fd..865eb60e 100644 --- a/Netdisco/share/public/javascripts/netdisco.js +++ b/Netdisco/share/public/javascripts/netdisco.js @@ -135,7 +135,41 @@ if (window.History && window.History.enabled) { }); } +// if any field in Search Options has content, highlight in green +function device_form_state(e) { + if (e.prop('value') != "") { + e.parent(".clearfix").addClass('success'); + + if (e.parents('#device_form').length) { + $('#nq').css('text-decoration', 'line-through'); + + if (e.attr('type') == 'text') { + $('.field_copy_icon').hide(); + } + } + + var id = '#' + e.attr('name') + '_clear_btn'; + $(id).show(); + } + else { + e.parent(".clearfix").removeClass('success'); + var id = '#' + e.attr('name') + '_clear_btn'; + $(id).hide(); + + var num_empty = $.grep(form_inputs, + function(n,i) {return($(n).val() != "")}).length; + if (num_empty === 3) { + $('#nq').css('text-decoration', 'none'); + $('.field_copy_icon').show(); + } + } +} + $(document).ready(function() { + // sidebar form fields should change colour and have bin/copy icon + $('.field_copy_icon').hide(); + $('.field_clear_icon').hide(); + // activate typeahead on the main search box, for device names only $('#nq').typeahead({ source: function (query, process) { diff --git a/Netdisco/share/views/ajax/device/ports.tt b/Netdisco/share/views/ajax/device/ports.tt index c854ea72..7205e38f 100644 --- a/Netdisco/share/views/ajax/device/ports.tt +++ b/Netdisco/share/views/ajax/device/ports.tt @@ -196,7 +196,8 @@ [% FOREACH node IN row.$nodes %] [% '
' IF row.remote_ip OR NOT loop.first %] [% 'A  ' IF NOT node.active %] - [% node.mac | html_entity %] + + [% node.net_mac.$mac_format_call | html_entity %] [% ' (' _ node.time_last_age _ ')' IF params.n_age %] [% IF params.n_ip %] [% FOREACH ip IN node.ips %] diff --git a/Netdisco/share/views/ajax/search/node_by_ip.tt b/Netdisco/share/views/ajax/search/node_by_ip.tt index 896ab5a9..6a994705 100644 --- a/Netdisco/share/views/ajax/search/node_by_ip.tt +++ b/Netdisco/share/views/ajax/search/node_by_ip.tt @@ -17,7 +17,8 @@ [% WHILE (row = macs.next) %] [% row.mac | html_entity %] + href="[% search_node %]&q=[% row.net_mac.$mac_format_call | uri %]"> + [% row.net_mac.$mac_format_call | html_entity %] [% IF params.vendor %] [% row.oui.company | html_entity %] [% END %] diff --git a/Netdisco/share/views/ajax/search/node_by_mac.tt b/Netdisco/share/views/ajax/search/node_by_mac.tt index 63638d80..34e445b9 100644 --- a/Netdisco/share/views/ajax/search/node_by_mac.tt +++ b/Netdisco/share/views/ajax/search/node_by_mac.tt @@ -20,7 +20,8 @@ [% IF first_row %] [% row.mac | html_entity %] + href="[% search_node %]&q=[% row.net_mac.$mac_format_call | uri %]"> + [% row.net_mac.$mac_format_call | html_entity %] [% ELSE %]   [% END %] @@ -51,7 +52,8 @@ [% IF first_row %] [% node.mac | html_entity %] + href="[% search_node %]&q=[% node.net_mac.$mac_format_call | uri %]"> + [% node.net_mac.$mac_format_call | html_entity %] [% ELSE %]   [% END %] diff --git a/Netdisco/share/views/js/device.js b/Netdisco/share/views/js/device.js index 354a6d1f..fe1dd136 100644 --- a/Netdisco/share/views/js/device.js +++ b/Netdisco/share/views/js/device.js @@ -2,6 +2,10 @@ // ajax content is loaded var path = 'device'; + // fields in the Device Search Options form (Device tab) + var form_inputs = $("#ports_form .clearfix input").not('[type="checkbox"]') + .add("#ports_form .clearfix select"); + function inner_view_processing(tab) { // LT wanted the page title to reflect what's on the page :) document.title = $('#nd_device_name').text() @@ -95,6 +99,10 @@ } $(document).ready(function() { + // sidebar form fields should change colour and have bin/copy icon + form_inputs.each(function() {device_form_state($(this))}); + form_inputs.change(function() {device_form_state($(this))}); + // sidebar collapser events trigger change of up/down arrow $('.collapse').on('show', function() { $(this).siblings().find('.arrow-up-down') @@ -106,28 +114,12 @@ .toggleClass('icon-chevron-up icon-chevron-down'); }); - // show or hide sweeping brush icon when field has content - var sweep = $('#ports_form').find("input[name=f]"); - - if (sweep.val() === "") { - $('.field_clear_icon').hide(); - } else { - $('.field_clear_icon').show(); - } - - sweep.change(function() { - if ($(this).val() === "") { - $('.field_clear_icon').hide(); - } else { - $('.field_clear_icon').show(); - } - }); - - // handler for sweeping brush icon in port filter box + // handler for bin icon in port filter box + var portfilter = $('#ports_form').find("input[name=f]"); $('.field_clear_icon').click(function() { - sweep.val(''); - $('.field_clear_icon').hide(); + portfilter.val(''); $('#ports_form').trigger('submit'); + device_form_state(portfilter); // will hide copy icons }); // clickable device port names can simply resubmit AJAX rather than @@ -137,9 +129,10 @@ var port = $(this).text(); port = $.trim(port); - sweep.val(port); + portfilter.val(port); $('.field_clear_icon').show(); $('#ports_form').trigger('submit'); + device_form_state(portfilter); // will hide copy icons }); }); diff --git a/Netdisco/share/views/js/search.js b/Netdisco/share/views/js/search.js index e917e7cd..32193ce4 100644 --- a/Netdisco/share/views/js/search.js +++ b/Netdisco/share/views/js/search.js @@ -3,54 +3,20 @@ var path = 'search'; // fields in the Device Search Options form (Device tab) - var d_inputs = $("#device_form .clearfix input").not('[type="checkbox"]') + var form_inputs = $("#device_form .clearfix input").not('[type="checkbox"]') .add("#device_form .clearfix select"); - // if any field in Device Search Options has content, highlight in green - // and strikethrough the navbar search - function device_form_state(e) { - if (e.is('[value!=""]')) { - if (e.attr('type') == 'text') { - $('.field_copy_icon').hide(); - } - - e.parent(".clearfix").addClass('success'); - $('#nq').css('text-decoration', 'line-through'); - - var id = '#' + e.attr('name') + '_clear_btn'; - $(id).show(); - } - else { - e.parent(".clearfix").removeClass('success'); - var id = '#' + e.attr('name') + '_clear_btn'; - $(id).hide(); - - if (! d_inputs.is('[value!=""]') ) { - $('#nq').css('text-decoration', 'none'); - $('.field_copy_icon').show(); - } - } - } - // this is called by do_search to support local code // here, when tab changes need to strike/unstrike the navbar search function inner_view_processing(tab) { - if (tab == 'device') { - d_inputs.each(function() {device_form_state($(this))}); - } - else { - $('#nq').css('text-decoration', 'none'); - } } // on load, check initial Device Search Options form state, // and on each change to the form fields $(document).ready(function() { - $('.field_copy_icon').hide(); - $('.field_clear_icon').hide(); - - d_inputs.each(function() {device_form_state($(this))}); - d_inputs.change(function() {device_form_state($(this))}); + // sidebar form fields should change colour and have bin/copy icon + form_inputs.each(function() {device_form_state($(this))}); + form_inputs.change(function() {device_form_state($(this))}); // handler for copy icon in search option $('.field_copy_icon').click(function() { @@ -65,6 +31,6 @@ var name = $(this).data('btn-for'); var input = $('#device_form [name=' + name + ']'); input.val(''); - device_form_state(input); + device_form_state(input); // will hide copy icons }); }); diff --git a/Netdisco/share/views/layouts/main.tt b/Netdisco/share/views/layouts/main.tt index 187fb50b..f752a221 100644 --- a/Netdisco/share/views/layouts/main.tt +++ b/Netdisco/share/views/layouts/main.tt @@ -12,6 +12,7 @@ + diff --git a/Netdisco/share/views/sidebar/device/ports.tt b/Netdisco/share/views/sidebar/device/ports.tt index 5dba23ae..ec1521bb 100644 --- a/Netdisco/share/views/sidebar/device/ports.tt +++ b/Netdisco/share/views/sidebar/device/ports.tt @@ -1,9 +1,9 @@
- - + @@ -28,7 +28,7 @@ B  Blocking
  • - P  IP Phone +   IP Phone
  • N  Neighbor Inacessible @@ -76,15 +76,7 @@
    • - -
    • -
    • - + Mark as Free if Down for:
      -
      +
    • +
    • +
    @@ -107,6 +105,14 @@
      +
    • + MAC address format:
      + +
    • [% FOREACH item IN vars.connected_properties %]
    -
    +
    + MAC address format:
    + +
    diff --git a/Netdisco/share/views/sidebar/search/port.tt b/Netdisco/share/views/sidebar/search/port.tt index 53c667f0..fa17b3f1 100644 --- a/Netdisco/share/views/sidebar/search/port.tt +++ b/Netdisco/share/views/sidebar/search/port.tt @@ -3,10 +3,10 @@
    -
    diff --git a/TODO b/TODO index 68d09f01..25f14631 100644 --- a/TODO +++ b/TODO @@ -1,23 +1,27 @@ - -** in no particular order... ** -** names by tasks indicate who's "taken" them ** - FRONTEND ======== * UI for topo DB table editing - drop topo file support and use DB only -* Port/Name/VLAN box should be green when filled * Choice of MAC address formats -* Empty inventory should trigger request to discover +* No devices - trigger first discover splash page * (jeneric) device module tab DAEMON ====== +* macsuck/arpnip + CORE ==== * pseudo-device support * VRF support + +DOCS +==== + +* Scheduler +* Discover/Refresh jobs +* netdisco-do