Added by_hostname config option support
This commit is contained in:
@@ -43,7 +43,7 @@ use Dancer::Plugin::DBIC 'schema';
|
|||||||
use App::Netdisco::Util::Permission ':all';
|
use App::Netdisco::Util::Permission ':all';
|
||||||
|
|
||||||
my $settings = setting( 'rancid' );
|
my $settings = setting( 'rancid' );
|
||||||
my $domain_suffix = setting( 'domain_suffix' );
|
my $domain_suffix = setting( 'domain_suffix' ) || '';
|
||||||
my $delimiter = $settings->{ 'delimiter' } || ':';
|
my $delimiter = $settings->{ 'delimiter' } || ':';
|
||||||
my $down_age = $settings->{ 'down_age' } || '1 day';
|
my $down_age = $settings->{ 'down_age' } || '1 day';
|
||||||
my $rancidhome = $settings->{ 'rancid_home' } || '/var/lib/rancid';
|
my $rancidhome = $settings->{ 'rancid_home' } || '/var/lib/rancid';
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
2.004000 - 2014-07-13
|
||||||
|
|
||||||
|
* Added by_hostname config option support
|
||||||
|
|
||||||
2.003002 - 2014-05-03
|
2.003002 - 2014-05-03
|
||||||
|
|
||||||
* POD fixups
|
* POD fixups
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package App::NetdiscoX::Web::Plugin::RANCID;
|
package App::NetdiscoX::Web::Plugin::RANCID;
|
||||||
|
|
||||||
our $VERSION = '2.003002';
|
our $VERSION = '2.004000';
|
||||||
|
|
||||||
use Dancer ':syntax';
|
use Dancer ':syntax';
|
||||||
|
|
||||||
@@ -25,6 +25,7 @@ hook 'before_template' => sub {
|
|||||||
my $config = config;
|
my $config = config;
|
||||||
my $tokens = shift;
|
my $tokens = shift;
|
||||||
my $device = $tokens->{d};
|
my $device = $tokens->{d};
|
||||||
|
my $domain_suffix = setting('domain_suffix') || '';
|
||||||
|
|
||||||
# defaults
|
# defaults
|
||||||
$tokens->{rancidgroup} = '';
|
$tokens->{rancidgroup} = '';
|
||||||
@@ -33,14 +34,17 @@ hook 'before_template' => sub {
|
|||||||
return unless exists $config->{rancid};
|
return unless exists $config->{rancid};
|
||||||
my $rancid = $config->{rancid};
|
my $rancid = $config->{rancid};
|
||||||
|
|
||||||
$rancid->{groups} ||= {};
|
$rancid->{groups} ||= {};
|
||||||
$rancid->{by_ip} ||= [];
|
$rancid->{by_ip} ||= [];
|
||||||
|
$rancid->{by_hostname} ||= [];
|
||||||
|
|
||||||
foreach my $g (keys %{ $rancid->{groups} }) {
|
foreach my $g (keys %{ $rancid->{groups} }) {
|
||||||
if (check_acl( get_device($device->{ip}), $rancid->{groups}->{$g} )) {
|
if (check_acl( get_device($device->{ip}), $rancid->{groups}->{$g} )) {
|
||||||
$tokens->{rancidgroup} = $g;
|
$tokens->{rancidgroup} = $g;
|
||||||
$tokens->{ranciddevice} = $device->{ip}
|
$tokens->{ranciddevice} = $device->{ip}
|
||||||
if 0 < scalar grep {$_ eq $g} @{ $rancid->{by_ip} };
|
if 0 < scalar grep {$_ eq $g} @{ $rancid->{by_ip} };
|
||||||
|
$tokens->{ranciddevice} =~ s/$domain_suffix$//
|
||||||
|
if 0 < scalar grep {$_ eq $g} @{ $rancid->{by_hostname} };
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,7 +93,8 @@ known to Netdisco. This uses the same configuration as for
|
|||||||
L<netdisco-rancid-export>, an example of which is below:
|
L<netdisco-rancid-export>, an example of which is below:
|
||||||
|
|
||||||
rancid:
|
rancid:
|
||||||
by_ip: [ other ]
|
by_ip: [ other ]
|
||||||
|
by_hostname: [ other2 ]
|
||||||
groups:
|
groups:
|
||||||
switch: [ 'name:.*[Ss][Ww].*' ]
|
switch: [ 'name:.*[Ss][Ww].*' ]
|
||||||
rtr: [ 'name:[rR]tr.*' ]
|
rtr: [ 'name:[rR]tr.*' ]
|
||||||
@@ -102,7 +107,8 @@ regular expression as in the above example.
|
|||||||
|
|
||||||
The device DNS name is used, or if missing the device SNMP sysName. Adding the
|
The device DNS name is used, or if missing the device SNMP sysName. Adding the
|
||||||
group to the list in C<by_ip> will make the link include the device IP
|
group to the list in C<by_ip> will make the link include the device IP
|
||||||
instead of the name.
|
instead of the name. Adding the group to the list in C<by_hostname> will
|
||||||
|
use the device FQDN minus the C<domain_suffix> config item (i.e. the hostname).
|
||||||
|
|
||||||
=head2 open_in_same_window
|
=head2 open_in_same_window
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user