allow device renumber to an alias IP
This commit is contained in:
@@ -3,10 +3,12 @@
|
|||||||
[ENHANCEMENTS]
|
[ENHANCEMENTS]
|
||||||
|
|
||||||
* THANK YOUs
|
* THANK YOUs
|
||||||
|
* Allow renumber of device to one of its alias IPs
|
||||||
|
|
||||||
[BUG FIXES]
|
[BUG FIXES]
|
||||||
|
|
||||||
* [#211] Additional check for undefined SNMP::Info instance
|
* [#211] Additional check for undefined SNMP::Info instance
|
||||||
|
* Re-set hostname on device after renumber
|
||||||
|
|
||||||
2.032002 - 2015-04-03
|
2.032002 - 2015-04-03
|
||||||
|
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ unless ($action) {
|
|||||||
use App::Netdisco::Util::SNMP ();
|
use App::Netdisco::Util::SNMP ();
|
||||||
use App::Netdisco::Util::Device
|
use App::Netdisco::Util::Device
|
||||||
qw/get_device delete_device renumber_device/;
|
qw/get_device delete_device renumber_device/;
|
||||||
|
use App::Netdisco::Util::DNS 'hostname_from_ip';
|
||||||
|
|
||||||
with 'App::Netdisco::Daemon::Worker::Poller::Device';
|
with 'App::Netdisco::Daemon::Worker::Poller::Device';
|
||||||
with 'App::Netdisco::Daemon::Worker::Poller::Arpnip';
|
with 'App::Netdisco::Daemon::Worker::Poller::Arpnip';
|
||||||
@@ -163,14 +164,17 @@ unless ($action) {
|
|||||||
unless ($new_ip and $new_ip->addr ne '0.0.0.0') {
|
unless ($new_ip and $new_ip->addr ne '0.0.0.0') {
|
||||||
return ('error', "Bad host or IP: ".($extra || '0.0.0.0'));
|
return ('error', "Bad host or IP: ".($extra || '0.0.0.0'));
|
||||||
}
|
}
|
||||||
|
|
||||||
my $new_dev = get_device($new_ip->addr);
|
my $new_dev = get_device($new_ip->addr);
|
||||||
unless ($new_dev and not $new_dev->in_storage) {
|
if ($new_dev and $new_dev->in_storage and ($new_dev->ip ne $device->ip)) {
|
||||||
return ('error', sprintf "Already know new device: %s.", $device->ip);
|
return ('error', sprintf "Already know new device as: %s.", $new_dev->ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
renumber_device($device, $new_dev->ip);
|
renumber_device($device, $new_dev->ip);
|
||||||
return ('done', sprintf 'Renumbered device %s from %s to %s.',
|
my $hostname = hostname_from_ip($device->ip);
|
||||||
$device->ip, $old_ip, $new_dev->ip);
|
$device->update({dns => $hostname});
|
||||||
|
return ('done', sprintf 'Renumbered device %s to %s (%s).',
|
||||||
|
$device->ip, $new_dev->ip, ($hostname || ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
sub psql {
|
sub psql {
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ __PACKAGE__->might_have(
|
|||||||
|
|
||||||
Will update this device and all related database records to use the new IP
|
Will update this device and all related database records to use the new IP
|
||||||
C<$new_ip>. Returns C<undef> if $new_ip seems invalid, otherwise returns the
|
C<$new_ip>. Returns C<undef> if $new_ip seems invalid, otherwise returns the
|
||||||
Device row object.
|
Device row object. Does NOT update the device C<dns> field.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user