register_worker({
phase
=>
'check'
},
sub
{
return
Status->error(
'Missing device (-d).'
)
unless
defined
shift
->device;
return
Status->done(
'ExpireNodes is able to run'
);
});
register_worker({
phase
=>
'main'
},
sub
{
my
(
$job
,
$workerconf
) =
@_
;
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
Status->done(
'Expired nodes for '
.
$job
->device->ip);
});
true;