Support for Device Details plugins; Web-Plugin-RANCID

This commit is contained in:
Oliver Gorwits
2013-12-09 21:21:05 +00:00
parent 38fe6b8e1a
commit 913a7511a9
20 changed files with 2417 additions and 0 deletions

View File

@@ -1,5 +1,9 @@
2.020002 -
[NEW FEATURES]
* Support for Device Details plugins (see X::RANCID)
[BUG FIXES]
* Respect macsuck_bleed on broken topology detection

View File

@@ -248,6 +248,32 @@ be called "C<device_port_column.tt>" on disk and live in the directory:
For a good example of this, see the L<App::NetdiscoX::Web::Plugin::Observium>
distribution.
=head1 Device Details
You can add items to the Device Details tab as well. A good example of this is
to add a link to the RANCID backup of the device in a WebSVN app somewhere.
Like Device Port Columns plugins, the plugin is a regular Template::Toolkit
snippet so can be any HTML output.
The details plugin has a name (used internally to locate files on disk) and
label (the heading for the row in the table).
To register the column call the following helper routine:
register_device_details({
name => 'mydevicedetailsplugin',
label => 'My Device Details Heading',
});
App::Netdisco searches for one Template::Toolkit file in the regular template
include paths (see also C<register_template_path>, below). The template must
be called "C<device_details.tt>" on disk and live in the directory:
plugin/mydevicedetailsplugin/device_details.tt
For a good example of this, see the L<App::NetdiscoX::Web::Plugin::RANCID>
distribution.
=head1 User Authorization
All Dancer route handlers must have proper authorization configured. This is

View File

@@ -9,6 +9,7 @@ set(
'_additional_css' => [],
'_additional_javascript' => [],
'_extra_device_port_cols' => [],
'_extra_device_details' => [],
'_navbar_items' => [],
'_search_tabs' => [],
'_device_tabs' => [],
@@ -76,6 +77,23 @@ register 'register_device_port_column' => sub {
push @{ setting('_extra_device_port_cols') }, $config;
};
register 'register_device_details' => sub {
my ($self, $config) = plugin_args(@_);
if (!$config->{name} or !$config->{label}) {
return error "bad config to register_device_details";
}
foreach my $item (@{ setting('_extra_device_details') }) {
if ($item->{name} eq $config->{name}) {
$item = $config;
return;
}
}
push @{ setting('_extra_device_details') }, $config;
};
register 'register_navbar_item' => sub {
my ($self, $config) = plugin_args(@_);
@@ -197,6 +215,10 @@ Additional Device Port Columns
=item *
Additional Device Details
=item *
Admin Menu function (job control, manual topology, pseudo devices)
=back

View File

@@ -64,6 +64,22 @@
<td>Description</td>
<td>[% d.description | html_entity | html_line_break %]</td>
</tr>
[% IF settings._extra_device_details.size %]
<tr>
[% FOREACH config IN settings._extra_device_details %]
<td>
[% config.label %]
</td>
<td>
[% TRY %]
[% INCLUDE "plugin/${config.name}/device_details.tt" %]
[% CATCH %]
<!-- dummy content required by Template Toolkit TRY -->
[% END %]
</td>
[% END %]
</tr>
[% END %]
<tr>
<td>Uptime</td>
<td>[% d.uptime_age | html_entity %]</td>