From ef560fb59aebf4f7cf64487931d41b6f5aa83d92 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 2 Mar 2019 22:41:40 +0000 Subject: [PATCH] #506 relax device renumber so it works for an alias --- lib/App/Netdisco/DB/Result/Device.pm | 2 ++ lib/App/Netdisco/Worker/Plugin.pm | 6 +++--- lib/App/Netdisco/Worker/Plugin/Renumber.pm | 8 ++++---- lib/App/Netdisco/Worker/Runner.pm | 6 +++--- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/App/Netdisco/DB/Result/Device.pm b/lib/App/Netdisco/DB/Result/Device.pm index e7d431a7..412ecdaa 100644 --- a/lib/App/Netdisco/DB/Result/Device.pm +++ b/lib/App/Netdisco/DB/Result/Device.pm @@ -277,6 +277,8 @@ sub renumber { ->update({ip => $new_ip}); } + $schema->resultset('DeviceSkip') + ->search({device => $new_ip})->delete; $schema->resultset('DeviceSkip') ->search({device => $old_ip}) ->update({device => $new_ip}); diff --git a/lib/App/Netdisco/Worker/Plugin.pm b/lib/App/Netdisco/Worker/Plugin.pm index 8f05a7c4..44999403 100644 --- a/lib/App/Netdisco/Worker/Plugin.pm +++ b/lib/App/Netdisco/Worker/Plugin.pm @@ -74,9 +74,9 @@ register 'register_worker' => sub { push @newuserconf, dclone $stanza; } - # per-device action but no device creds available - return $job->add_status( Status->info('skip: driver or action not applicable') ) - if 0 == scalar @newuserconf; + # # per-device action but no device creds available + # return $job->add_status( Status->info('skip: driver or action not applicable') ) + # if 0 == scalar @newuserconf; } # back up and restore device_auth diff --git a/lib/App/Netdisco/Worker/Plugin/Renumber.pm b/lib/App/Netdisco/Worker/Plugin/Renumber.pm index c3b815ba..e768002e 100644 --- a/lib/App/Netdisco/Worker/Plugin/Renumber.pm +++ b/lib/App/Netdisco/Worker/Plugin/Renumber.pm @@ -28,10 +28,10 @@ register_worker({ phase => 'main' }, sub { my $old_ip = $device->ip; my $new_ip = NetAddr::IP->new($extra); - my $new_dev = get_device($new_ip->addr); - if ($new_dev and $new_dev->in_storage and ($new_dev->ip ne $device->ip)) { - return Status->error(sprintf "Already know new device as: %s.", $new_dev->ip); - } + #my $new_dev = get_device($new_ip->addr); + #if ($new_dev and $new_dev->in_storage and ($new_dev->ip ne $device->ip)) { + # return Status->error(sprintf "Already know new device as: %s.", $new_dev->ip); + #} renumber_device($device, $new_ip); return Status->done(sprintf 'Renumbered device %s to %s (%s).', diff --git a/lib/App/Netdisco/Worker/Runner.pm b/lib/App/Netdisco/Worker/Runner.pm index 193281ca..4cdbf041 100644 --- a/lib/App/Netdisco/Worker/Runner.pm +++ b/lib/App/Netdisco/Worker/Runner.pm @@ -49,9 +49,9 @@ sub run { push @newuserconf, dclone $stanza; } - # per-device action but no device creds available - return $job->add_status( Status->defer('deferred job with no device creds') ) - if 0 == scalar @newuserconf; + # # per-device action but no device creds available + # return $job->add_status( Status->defer('deferred job with no device creds') ) + # if 0 == scalar @newuserconf; } # back up and restore device_auth