[#193] DBI Exception for Cisco ACE MacAddr format

Also standardise on IEEE MAC format now that NetAddr::MAC has that corrected.
This commit is contained in:
Oliver Gorwits
2015-01-08 11:07:25 +00:00
parent 7a7e4b81ce
commit b2d61b3d5f
6 changed files with 16 additions and 9 deletions

View File

@@ -7,6 +7,7 @@ use App::Netdisco::Util::Node 'check_mac';
use App::Netdisco::Util::DNS ':all';
use NetAddr::IP::Lite ':lower';
use Time::HiRes 'gettimeofday';
use NetAddr::MAC ();
use base 'Exporter';
our @EXPORT = ();
@@ -119,9 +120,11 @@ sub store_arp {
my ($hash_ref, $now) = @_;
$now ||= 'now()';
my $ip = $hash_ref->{'ip'};
my $mac = $hash_ref->{'node'};
my $mac = NetAddr::MAC->new($hash_ref->{'node'});
my $name = $hash_ref->{'dns'};
return if !defined $mac or $mac->errstr;
schema('netdisco')->txn_do(sub {
my $current = schema('netdisco')->resultset('NodeIp')
->search(
@@ -131,7 +134,7 @@ sub store_arp {
schema('netdisco')->resultset('NodeIp')
->update_or_create(
{
mac => $mac,
mac => $mac->as_ieee,
ip => $ip,
dns => $name,
active => \'true',

View File

@@ -756,7 +756,7 @@ sub store_neighbors {
if (!defined $neigh) {
my $mac = NetAddr::MAC->new(mac => $remote_id);
if ($mac and not $mac->errstr) {
$neigh = $devices->single({mac => $mac->as_microsoft()});
$neigh = $devices->single({mac => $mac->as_ieee});
}
}
@@ -770,8 +770,8 @@ sub store_neighbors {
if ($mac and not $mac->errstr) {
info sprintf
'[%s] neigh - found neighbor %s by MAC %s',
$device->ip, $remote_id, $mac->as_microsoft();
$neigh = $devices->single({mac => $mac->as_microsoft()});
$device->ip, $remote_id, $mac->as_ieee;
$neigh = $devices->single({mac => $mac->as_ieee});
}
}