/usr/share/netdisco/html/device_module.html is in netdisco-frontend 1.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | <h1 class="pagehead">Device Module View</h1>
<p>Note: this is a development view and is for debug purposes only.
If has been incorporated into device.html already.</p>
<ul class="mktree" id="modules">
% foreach my $item (@{$modules{root}}) {
<& SELF:dump_module, id=>$item &>
% }
</ul><hr></ul>
% foreach my $key (sort { $a <=> $b } keys %modules) {
% if (!$printed{$key}) {
<& SELF:dump_module, id=>$key &>
% }
% }
</ul>
<hr>
<pre>
% print Dumper(\%modules);
</pre>
<%args>
$ip => '' # Can be IP or hostname
</%args>
<%shared>
my %modules = {};
my %printed = {};
my $device;
</%shared>
<%init>
#XXX
use Data::Dumper;
if ($ip) {
# Save Search Term
my $match = $ip;
# Resolve input
my $hostname = &hostname($ip);
my $ip = &getip($ip);
# Check if we're an alias of another device
my $devip = &root_device($ip);
# redirect to search if no match
$m->redirect("device_search.html?text=$match") unless $devip;
# Grab Device INFO
$device = sql_hash('device',
['ip','extract(epoch from creation) as creation','dns',
'description','uptime','contact','name','location','layers',
'ports','mac','serial','model','ps1_type','ps2_type','ps1_status',
'ps2_status','fan','slots','vendor','log','os_ver','os','vtp_domain',
'extract(epoch from last_discover) as last_discover',
'extract(epoch from last_macsuck) as last_macsuck',
'extract(epoch from last_arpnip) as last_arpnip' ],
{'ip'=>$devip});
my $modules = sql_rows('device_module',['*'],{'ip'=>$devip},0,'order by parent,pos,index') || [];
foreach my $module (@$modules) {
$modules{$module->{index}}{module} = $module;
if ($module->{parent}) {
# this is wrong. a given parent can
# have multiple items at a single pos value.
# (HP may have gotten this wrong, but that's
# reality...)
#
# Next wrong: some things have weird pos'
# index | description | type | parent | class | pos
#-------+----------------------------------------+---------------------+--------+---------+-----
# 1 | Cisco Aironet 1200 Series Access Point | cevChassisAIRAP1210 | 0 | chassis | -1
# 3 | PowerPC405GP Ethernet | cevPortFEIP | 1 | port | -1
# 2 | 802.11G Radio | cevPortUnknown | 1 | port | 0
$module->{pos} = 0 if ($module->{pos} < 0);
#$m->out(%$module."<BR>\n");
if ($module->{pos}) {
${$modules{$module->{parent}}{children}{$module->{class}}}[$module->{pos}] = $module->{index};
} else {
push(@{$modules{$module->{parent}}{children}{$module->{class}}}, $module->{index});
}
} else {
push(@{$modules{root}}, $module->{index});
}
}
} else {
$m->redirect("device_search.html");
}
</%init>
<%method dump_module>
<%args>
$id
</%args>
<li>
<%perl>
return if ($id eq 'root');
if (!defined($modules{$id})) {
print "can't get module $id\n";
print Dumper($id);
return;
}
$printed{$id}++;
my $mod = $modules{$id}{module};
</%perl>
<% $mod->{description} %> (<% $mod->{name} %>)
% if ($mod->{port}) {
(<% $mod->{port} %>)
% }
% for my $f qw(fw hw sw) {
% if ($mod->{"${f}_ver"}) {
[<%$f%>: <%$mod->{"${f}_ver"}%>]
% }
% }
% if ($mod->{serial}) {
[serial: <%$mod->{serial}%>]
% }
/ <% $mod->{type} %> / <% $mod->{vendor} %> <% $mod->{model} %>
% if ($mod->{fru}) {
<b>[FRU]</b>
% }
// <i><% $mod->{class} %></i>
<!-- parent <% $mod->{parent} %> pos <% $mod->{pos} %> -->
% #print join(" | ", keys %$mod);
% if ($modules{$id}{children}) {
<ul>
% my @kidtypes = keys %{$modules{$id}{children}};
% foreach my $kidtype (@kidtypes) {
%#% if (@kidtypes > 1) {
%# <li><% $kidtype %>s
%# <ul>
%#% }
% foreach my $kid (@{$modules{$id}{children}{$kidtype}}) {
% if (defined($kid)) {
<& SELF:dump_module, id=>$kid &>
% }
% }
%#% if (@kidtypes > 1) {
%# </ul></li>
%#% }
% }
</ul>
% }
</li>
</%method>
%# $Id: device_module.html,v 1.4 2009/03/09 05:28:41 maxbaker Exp $
%# vim:syntax=mason
|