diff --git a/Netdisco/Changes b/Netdisco/Changes index af398cf7..02035be7 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -1,10 +1,11 @@ -2.032000_001 - 2015-03-07 +2.032001 - 2015-03-24 [NEW FEATURES] * macsuck_unsupported setting to allow node gathering on delinquent switches * netdisco-do -d accepts IP prefixes (subnet in CIDR format) * [#110] rules for IP Phone and Wireless AP identification now configurable + * [#119] netdisco-do expirenodes (ND1 expirenodes & expire-nodes-subnet) [ENHANCEMENTS] diff --git a/Netdisco/bin/netdisco-do b/Netdisco/bin/netdisco-do index 21168f43..a53064d2 100755 --- a/Netdisco/bin/netdisco-do +++ b/Netdisco/bin/netdisco-do @@ -312,7 +312,8 @@ Run an arpnip for all known devices. Delete a device (specified with C<-d>). Pass a log message for the action in the C<-e> parameter. Optionally request for associated nodes to be archived -(rather than deleted) by setting the C<-p> parameter to "C". +(rather than deleted) by setting the C<-p> parameter to "C" (mnemonic: +U

reserve). ~netdisco/bin/netdisco-do delete -d 192.0.2.1 ~netdisco/bin/netdisco-do delete -d 192.0.2.1 -e 'older than the sun' @@ -343,6 +344,15 @@ Run an nbtstat for all known nodes. Run Device and Node expiry actions according to configuration. +=head2 expirenodes + +Archive nodes on the specified device. If you want to delete nodes, set the +C<-e> parameter to "C" (mnemonic: Uxpire). If you want to perform the +action on a specific port, set the C<-p> parameter. + + ~netdisco/bin/netdisco-do expirenodes -d 192.0.2.1 + ~netdisco/bin/netdisco-do expirenodes -d 192.0.2.1 -p FastEthernet0/1 -e no + =head2 graph Generate GrapgViz graphs for the largest cluster of devices. diff --git a/Netdisco/lib/App/Netdisco/Daemon/Worker/Poller/Expiry.pm b/Netdisco/lib/App/Netdisco/Daemon/Worker/Poller/Expiry.pm index 01d82d4a..c154f356 100644 --- a/Netdisco/lib/App/Netdisco/Daemon/Worker/Poller/Expiry.pm +++ b/Netdisco/lib/App/Netdisco/Daemon/Worker/Poller/Expiry.pm @@ -52,4 +52,22 @@ sub expire { return job_done("Checked expiry for all Devices and Nodes"); } +# expire nodes for a specific device +sub expirenodes { + my ($self, $job) = @_; + + return job_error('Missing device') unless $job->device; + + schema('netdisco')->txn_do(sub { + schema('netdisco')->resultset('Node')->search({ + switch => $job->device->ip, + ($job->port ? (port => $job->port) : ()), + })->delete( + ($job->extra ? () : ({ archive_nodes => 1 })) + ); + }); + + return job_done("Expired nodes for ". $job->device->ip); +} + 1;