change device_identity to be list of mappings

This commit is contained in:
Oliver Gorwits
2017-05-28 09:14:08 +01:00
parent eb56364d98
commit 5f58cfbbe5
4 changed files with 43 additions and 31 deletions

View File

@@ -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;
}
}
}
}