support for device identity steering via device_identity
This commit is contained in:
@@ -50,15 +50,31 @@ the IP and hostname in the device object for the canonical IP.
|
||||
sub set_canonical_ip {
|
||||
my ($device, $snmp) = @_;
|
||||
|
||||
my $old_ip = $device->ip;
|
||||
my $new_ip = $old_ip;
|
||||
my $revname = ipv4_from_hostname($snmp->name);
|
||||
my $old_ip = $device->ip;
|
||||
my $new_ip = $old_ip;
|
||||
my $revofname = ipv4_from_hostname($snmp->name);
|
||||
|
||||
if (setting('reverse_sysname') and $revname) {
|
||||
$new_ip = $revname;
|
||||
if (setting('reverse_sysname') and $revofname) {
|
||||
$new_ip = $revofname;
|
||||
}
|
||||
|
||||
if (setting('device_identity')) {
|
||||
if (ref {} eq ref setting('device_identity')) {
|
||||
my $idmap = setting('device_identity') || {};
|
||||
my $devips = $device->device_ips->order_by('alias');
|
||||
|
||||
ALIAS: while (my $alias = $devips->next) {
|
||||
foreach my $this (keys %$idmap) {
|
||||
$anded_this = [(ref $this ? @$this : $this), 'op:and'];
|
||||
|
||||
if (check_acl($device, $anded_this)
|
||||
and check_acl($alias, $idmap->{$this})
|
||||
and $alias->alias ne $old_ip) {
|
||||
|
||||
$new_ip = $alias->alias;
|
||||
last ALIAS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return if $new_ip eq $old_ip;
|
||||
|
||||
@@ -95,16 +95,6 @@ you can often influence this through device configuration (LLDP advertise...).
|
||||
|
||||
=cut
|
||||
|
||||
# Via configuration there are two further settings. C<reverse_sysname> tells
|
||||
# Netdisco to take the SNMP System Name and do a reverse DNS lookup for the
|
||||
# canonical IP. The new configuration setting C<device_identity> allows you to
|
||||
# set rules for picking the canonical interface from a device based on any of
|
||||
# its properties (model, vendor, OS, OS version, etc).
|
||||
#
|
||||
# Typical use would be either to leave Netdisco to use the discovered IP, or use
|
||||
# C<device_identity> to control the canonical IP/name for classes of device
|
||||
# based on model/vendor, etc.
|
||||
|
||||
=head1 2.032000
|
||||
|
||||
=head2 General Notices
|
||||
|
||||
@@ -116,6 +116,7 @@ login_logo: ""
|
||||
# mibhome is discovered from environment
|
||||
# mibdirs defaults to contents of mibhome
|
||||
host_groups: {}
|
||||
device_identity: {}
|
||||
community: ['public']
|
||||
community_rw: ['private']
|
||||
snmp_auth: []
|
||||
|
||||
Reference in New Issue
Block a user