delete hook (#1032)

* make log_message optional in delete_device

* add hooks support to delete job

* make delete job high prio

* web delete now queues job instead of inline delete

* move web logging into web package and remove userlog from device delete helper

* submit delete job for expire device instead of inline delete

* fixes to get web submit form for delete device to work

* enable delete hook functionality
This commit is contained in:
Oliver Gorwits
2023-04-30 22:58:42 +01:00
committed by GitHub
parent d338c2d15a
commit 949aeb9eea
9 changed files with 84 additions and 40 deletions

View File

@@ -14,11 +14,21 @@ register_worker({ phase => 'check' }, sub {
register_worker({ phase => 'main' }, sub {
my ($job, $workerconf) = @_;
my ($device, $port, $extra) = map {$job->$_} qw/device port extra/;
my ($device, $port) = map {$job->$_} qw/device port/;
# support for Hooks
vars->{'hook_data'} = { $device->get_columns };
delete vars->{'hook_data'}->{'snmp_comm'}; # for privacy
$port = ($port ? 1 : 0);
delete_device($device, $port, $extra);
return Status->done("Deleted device: $device");
my $happy = delete_device($device, $port);
if ($happy) {
return Status->done("Deleted device: $device")
}
else {
return Status->error("Failed to delete device: $device")
}
});
true;