change device_identity to be list of mappings
This commit is contained in:
@@ -58,20 +58,25 @@ sub set_canonical_ip {
|
||||
$new_ip = $revofname;
|
||||
}
|
||||
|
||||
if (ref {} eq ref setting('device_identity')
|
||||
and scalar keys %{ setting('device_identity') }) {
|
||||
my $idmap = setting('device_identity');
|
||||
if (ref [] eq ref setting('device_identity')
|
||||
and scalar @{ setting('device_identity') }) {
|
||||
|
||||
my @idmaps = @{ setting('device_identity') };
|
||||
my $devips = $device->device_ips->order_by('alias');
|
||||
|
||||
ALIAS: while (my $alias = $devips->next) {
|
||||
next if $alias->alias eq $old_ip;
|
||||
|
||||
foreach my $key (keys %$idmap) {
|
||||
# lhs of device_identity matches device, rhs matches device_ip
|
||||
if (check_acl($device, $key)
|
||||
and check_acl($alias, $idmap->{$key})) {
|
||||
$new_ip = $alias->alias;
|
||||
last ALIAS;
|
||||
foreach my $map (@idmaps) {
|
||||
next unless ref {} eq ref $map;
|
||||
|
||||
foreach my $key (keys %$map) {
|
||||
# lhs matches device, rhs matches device_ip
|
||||
if (check_acl($device, $key)
|
||||
and check_acl($alias, $map->{$key})) {
|
||||
$new_ip = $alias->alias;
|
||||
last ALIAS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user