Merge branch 'master' of ssh://git.code.sf.net/p/netdisco/netdisco-ng into em-datatables-v1_10_0
This commit is contained in:
		| @@ -10,7 +10,7 @@ use NetAddr::IP::Lite ':lower'; | ||||
| use List::MoreUtils (); | ||||
| use Encode; | ||||
| use Try::Tiny; | ||||
| use NetAddr::MAC; | ||||
| use Net::MAC; | ||||
|  | ||||
| use base 'Exporter'; | ||||
| our @EXPORT = (); | ||||
| @@ -713,8 +713,8 @@ sub store_neighbors { | ||||
|                 $device->ip, $remote_ip, $port, $remote_id; | ||||
|  | ||||
|               if (!defined $neigh) { | ||||
|                   my $mac = NetAddr::MAC->new(mac => $remote_id); | ||||
|                   if (not $mac->errstr) { | ||||
|                   my $mac = Net::MAC->new(mac => $remote_id, 'die' => 0, verbose => 0); | ||||
|                   if (not $mac->get_error) { | ||||
|                       $neigh = $devices->single({mac => $remote_id}); | ||||
|                   } | ||||
|               } | ||||
|   | ||||
| @@ -7,7 +7,7 @@ package App::Netdisco::DB::Result::Node; | ||||
| use strict; | ||||
| use warnings; | ||||
|  | ||||
| use NetAddr::MAC; | ||||
| use Net::MAC; | ||||
|  | ||||
| use base 'DBIx::Class::Core'; | ||||
| __PACKAGE__->table("node"); | ||||
| @@ -175,10 +175,10 @@ sub time_last_stamp  { return (shift)->get_column('time_last_stamp')  } | ||||
|  | ||||
| =head2 net_mac | ||||
|  | ||||
| Returns the C<mac> column instantiated into a L<NetAddr::MAC> object. | ||||
| Returns the C<mac> column instantiated into a L<Net::MAC> object. | ||||
|  | ||||
| =cut | ||||
|  | ||||
| sub net_mac { return NetAddr::MAC->new(mac => (shift)->mac) } | ||||
| sub net_mac { return Net::MAC->new(mac => (shift)->mac) } | ||||
|  | ||||
| 1; | ||||
|   | ||||
| @@ -7,7 +7,7 @@ package App::Netdisco::DB::Result::NodeIp; | ||||
| use strict; | ||||
| use warnings; | ||||
|  | ||||
| use NetAddr::MAC; | ||||
| use Net::MAC; | ||||
|  | ||||
| use base 'DBIx::Class::Core'; | ||||
| __PACKAGE__->table("node_ip"); | ||||
| @@ -221,10 +221,10 @@ sub time_last_stamp  { return (shift)->get_column('time_last_stamp')  } | ||||
|  | ||||
| =head2 net_mac | ||||
|  | ||||
| Returns the C<mac> column instantiated into a L<NetAddr::MAC> object. | ||||
| Returns the C<mac> column instantiated into a L<Net::MAC> object. | ||||
|  | ||||
| =cut | ||||
|  | ||||
| sub net_mac { return NetAddr::MAC->new(mac => (shift)->mac) } | ||||
| sub net_mac { return Net::MAC->new(mac => (shift)->mac) } | ||||
|  | ||||
| 1; | ||||
|   | ||||
| @@ -7,8 +7,6 @@ package App::Netdisco::DB::Result::NodeNbt; | ||||
| use strict; | ||||
| use warnings; | ||||
|  | ||||
| use NetAddr::MAC; | ||||
|  | ||||
| use base 'DBIx::Class::Core'; | ||||
| __PACKAGE__->table("node_nbt"); | ||||
| __PACKAGE__->add_columns( | ||||
| @@ -178,10 +176,10 @@ sub time_last_stamp  { return (shift)->get_column('time_last_stamp')  } | ||||
|  | ||||
| =head2 net_mac | ||||
|  | ||||
| Returns the C<mac> column instantiated into a L<NetAddr::MAC> object. | ||||
| Returns the C<mac> column instantiated into a L<Net::MAC> object. | ||||
|  | ||||
| =cut | ||||
|  | ||||
| sub net_mac { return NetAddr::MAC->new(mac => (shift)->mac) } | ||||
| sub net_mac { return Net::MAC->new(mac => (shift)->mac) } | ||||
|  | ||||
| 1; | ||||
|   | ||||
| @@ -262,8 +262,8 @@ Compared to the current Netdisco, the handler routines are very small. This is | ||||
| because (a) they don't include any HTML - this is delegated to a template, and | ||||
| (b) they don't include an SQL - this is delegated to DBIx::Class. Small | ||||
| routines are more manageable, and easier to maintain. You'll also notice use | ||||
| of modules such as L<NetAddr::MAC> and L<NetAddr::IP::Lite> to simplify and | ||||
| make more robust the handling of data. | ||||
| of modules such as L<Net::MAC> and L<NetAddr::IP::Lite> to simplify and make | ||||
| more robust the handling of data. | ||||
|  | ||||
| In fact, many sections of the web application have been factored out into | ||||
| separate Plugin modules. For more information see the | ||||
|   | ||||
| @@ -3,7 +3,7 @@ package App::Netdisco::Util::Node; | ||||
| use Dancer qw/:syntax :script/; | ||||
| use Dancer::Plugin::DBIC 'schema'; | ||||
|  | ||||
| use NetAddr::MAC; | ||||
| use Net::MAC; | ||||
| use App::Netdisco::Util::Permission 'check_acl'; | ||||
|  | ||||
| use base 'Exporter'; | ||||
| @@ -66,18 +66,18 @@ MAC address does not belong to an interface on any known Device | ||||
|  | ||||
| sub check_mac { | ||||
|   my ($device, $node, $port_macs) = @_; | ||||
|   my $mac = NetAddr::MAC->new(mac => $node); | ||||
|   my $mac = Net::MAC->new(mac => $node, 'die' => 0, verbose => 0); | ||||
|   $port_macs ||= {}; | ||||
|  | ||||
|   # incomplete MAC addresses (BayRS frame relay DLCI, etc) | ||||
|   if ($mac->errstr) { | ||||
|   if ($mac->get_error) { | ||||
|       debug sprintf ' [%s] check_mac - mac [%s] malformed - skipping', | ||||
|         $device->ip, $node; | ||||
|       return 0; | ||||
|   } | ||||
|   else { | ||||
|       # lower case, hex, colon delimited, 8-bit groups | ||||
|       $node = lc $mac->as_microsoft; | ||||
|       $node = lc $mac->as_IEEE; | ||||
|   } | ||||
|  | ||||
|   # broadcast MAC addresses | ||||
|   | ||||
| @@ -55,11 +55,6 @@ hook 'before' => sub { | ||||
|     { name => 'n_archived', label => 'Archived Data', default => ''   }, | ||||
|   ]); | ||||
|  | ||||
|   # not stored in the cookie - global defaults | ||||
|   params->{'age_num'} ||= 3; | ||||
|   params->{'age_unit'} ||= 'months'; | ||||
|   params->{'mac_format'} ||= 'microsoft'; | ||||
|  | ||||
|   return unless (request->path eq uri_for('/device')->path | ||||
|     or index(request->path, uri_for('/ajax/content/device')->path) == 0); | ||||
|  | ||||
| @@ -106,10 +101,15 @@ hook 'before' => sub { | ||||
|             if $col->{default} eq 'on'; | ||||
|       } | ||||
|  | ||||
|       # not stored in the cookie | ||||
|       params->{'age_num'} ||= 3; | ||||
|       params->{'age_unit'} ||= 'months'; | ||||
|       params->{'mac_format'} ||= 'IEEE'; | ||||
|  | ||||
|       if (param('reset')) { | ||||
|           params->{'age_num'} = 3; | ||||
|           params->{'age_unit'} = 'months'; | ||||
|           params->{'mac_format'} = 'microsoft'; | ||||
|           params->{'mac_format'} = 'IEEE'; | ||||
|  | ||||
|           # nuke the port params cookie | ||||
|           cookie('nd_ports-form' => '', expires => '-1 day'); | ||||
| @@ -129,21 +129,7 @@ hook 'before_template' => sub { | ||||
|       $tokens->{device_ports}->query_param($key, params->{$key}); | ||||
|   } | ||||
|  | ||||
|   # for NetAddr::MAC method | ||||
|   $tokens->{mac_formats} = { | ||||
|     basic => 'Basic', | ||||
|   #  bpr => 'BPR', | ||||
|     cisco => 'Cisco', | ||||
|     ieee => 'IEEE', | ||||
|   #  ipv6 => 'IPv6 Suffix', | ||||
|     microsoft => 'Microsoft', | ||||
|     singledash => 'Single Dash', | ||||
|     sun => 'Sun', | ||||
|     tokenring => 'Token Ring', | ||||
|   #  eui48 => 'EUI48', | ||||
|   #  eui64 => 'EUI64', | ||||
|   }; | ||||
|  | ||||
|   # for Net::MAC method | ||||
|   $tokens->{mac_format_call} = 'as_'. params->{'mac_format'} | ||||
|     if params->{'mac_format'}; | ||||
|  | ||||
|   | ||||
| @@ -6,7 +6,7 @@ use Dancer::Plugin::DBIC; | ||||
| use Dancer::Plugin::Auth::Extensible; | ||||
|  | ||||
| use NetAddr::IP::Lite ':lower'; | ||||
| use NetAddr::MAC (); | ||||
| use Net::MAC (); | ||||
|  | ||||
| use App::Netdisco::Web::Plugin; | ||||
| use App::Netdisco::Util::Web 'sql_match'; | ||||
| @@ -22,7 +22,7 @@ ajax '/ajax/content/search/node' => require_login sub { | ||||
|     my $agenot = param('age_invert') || '0'; | ||||
|     my ( $start, $end ) = param('daterange') =~ /(\d+-\d+-\d+)/gmx; | ||||
|  | ||||
|     my $mac = NetAddr::MAC->new(mac => $node); | ||||
|     my $mac = Net::MAC->new(mac => $node, 'die' => 0, verbose => 0); | ||||
|     my @active = (param('archived') ? () : (-bool => 'active')); | ||||
|  | ||||
|     my @times = (); | ||||
| @@ -48,7 +48,7 @@ ajax '/ajax/content/search/node' => require_login sub { | ||||
|  | ||||
|     my @where_mac = | ||||
|       ($using_wildcards ? \['me.mac::text ILIKE ?', $likeval] | ||||
|                         : ($mac->errstr ? \'0=1' : ('me.mac' => $mac->as_microsoft)) ); | ||||
|                         : ($mac->get_error ? \'0=1' : ('me.mac' => $mac->as_IEEE)) ); | ||||
|  | ||||
|     my $sightings = schema('netdisco')->resultset('Node') | ||||
|       ->search({-and => [@where_mac, @active, @times]}, { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user