From 1c3e0f260c366cd33873f820bb0ac0b432f3c048 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Fri, 8 Aug 2014 22:26:44 +0100 Subject: [PATCH] Push a row into Device Modules for the chassis even if no module info --- Netdisco/Changes | 1 + Netdisco/lib/App/Netdisco/Core/Discover.pm | 29 ++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Netdisco/Changes b/Netdisco/Changes index 7dc8d6b9..63297289 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -19,6 +19,7 @@ * Log at debug the vlan reindexing in macsuck * Add docs note about database backups * Always set DBIC_TRACE_PROFILE=console in environment + * Push a row into Device Modules for the chassis even if no module info [BUG FIXES] diff --git a/Netdisco/lib/App/Netdisco/Core/Discover.pm b/Netdisco/lib/App/Netdisco/Core/Discover.pm index a760d2a1..f4def41d 100644 --- a/Netdisco/lib/App/Netdisco/Core/Discover.pm +++ b/Netdisco/lib/App/Netdisco/Core/Discover.pm @@ -578,10 +578,35 @@ not yet stored to the database. sub store_modules { my ($device, $snmp) = @_; - my $e_index = $snmp->e_index; + my $e_index = $snmp->e_index; if (!defined $e_index) { - debug sprintf ' [%s] modules - 0 chassis components', $device->ip; + schema('netdisco')->txn_do(sub { + my $gone = $device->modules->delete; + debug sprintf ' [%s] modules - removed %d chassis modules', + $device->ip, $gone; + + $device->modules->update_or_create({ + ip => $device->ip, + index => 1, + parent => 0, + name => 'chassis', + class => 'chassis', + pos => -1, + # too verbose and link doesn't work anyway + # description => $device->description, + sw_ver => $device->os_ver, + serial => $device->serial, + model => $device->model, + fru => \'false', + last_discover => \'now()', + }); + }); + + debug + sprintf ' [%s] modules - 0 chassis components (added one pseudo for chassis)', + $device->ip; + return; }