Fix previous commit
* revert unwanted commit of bogus Web/Plugin/Device/Modules.pm * commit actual fix for #710
This commit is contained in:
@@ -17,22 +17,9 @@ ajax '/ajax/content/device/modules' => require_login sub {
|
||||
->search_for_device($q) or send_error('Bad device', 400);
|
||||
my @set = $device->modules->search({}, {order_by => { -asc => [qw/parent class pos index/] }});
|
||||
|
||||
|
||||
# sort modules (empty set would be a 'no records' msg)
|
||||
my $results = &App::Netdisco::Util::Web::sort_modules( \@set );
|
||||
return unless scalar %$results;
|
||||
use Data::Dumper;
|
||||
#print STDERR "-----------\n"; print STDERR Dumper($results);
|
||||
|
||||
print STDERR "-----------\n";
|
||||
print STDERR Dumper($results->{root}) ."\n";
|
||||
print STDERR "-----------\n";
|
||||
my $id = 1;
|
||||
print STDERR Dumper($results->{$id}{module}->name) ."\n";
|
||||
print STDERR Dumper($results->{$id}{module}->index) ."\n";
|
||||
print STDERR Dumper($results->{$id}{module}->parent) ."\n";
|
||||
print STDERR Dumper($results->{$id}->{children}) ."\n";
|
||||
print STDERR "-----------\n";
|
||||
|
||||
content_type('text/html');
|
||||
template 'ajax/device/modules.tt', {
|
||||
|
||||
@@ -91,6 +91,18 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
|
||||
};
|
||||
}
|
||||
|
||||
foreach my $m (@modules){
|
||||
unless ($seen_idx{$m->{parent}} || !$m->{parent}){
|
||||
# Some combined devices like Nexus with FEX or ASR with Satellites can return invalid
|
||||
# EntityMIB trees. This workaround relocates entitites with invalid parents to the root
|
||||
# of the tree, so they are at least visible in the Modules tab (see #710)
|
||||
|
||||
info sprintf ' [%s] Entity %s (%s) has invalid parent %s - attaching as root entity instead',
|
||||
$device->ip, $m->{index}, $m->{name}, $m->{parent};
|
||||
$m->{parent} = undef;
|
||||
}
|
||||
}
|
||||
|
||||
schema('netdisco')->txn_do(sub {
|
||||
my $gone = $device->modules->delete;
|
||||
debug sprintf ' [%s] modules - removed %d chassis modules',
|
||||
|
||||
Reference in New Issue
Block a user