efficient device delete which does not walk nodes
This commit is contained in:
@@ -59,6 +59,22 @@ foreach my $jobtype (keys %jobs_all, keys %jobs) {
|
||||
};
|
||||
}
|
||||
|
||||
ajax '/ajax/control/admin/delete' => require_role admin => sub {
|
||||
send_error('Missing device', 400) unless param('device');
|
||||
|
||||
my $device = NetAddr::IP::Lite->new(param('device'));
|
||||
send_error('Bad device', 400)
|
||||
if ! $device or $device->addr eq '0.0.0.0';
|
||||
|
||||
schema('netdisco')->txn_do(sub {
|
||||
my $device = schema('netdisco')->resultset('Device')
|
||||
->search({ip => param('device')});
|
||||
|
||||
# will delete everything related too...
|
||||
$device->delete;
|
||||
});
|
||||
};
|
||||
|
||||
get '/admin/*' => require_role admin => sub {
|
||||
my ($tag) = splat;
|
||||
|
||||
|
||||
@@ -56,15 +56,7 @@ ajax '/ajax/control/admin/pseudodevice/add' => require_role admin => sub {
|
||||
|
||||
ajax '/ajax/control/admin/pseudodevice/del' => require_role admin => sub {
|
||||
send_error('Bad Request', 400) unless _sanity_ok();
|
||||
|
||||
schema('netdisco')->txn_do(sub {
|
||||
my $device = schema('netdisco')->resultset('Device')
|
||||
->find({ip => param('ip')});
|
||||
|
||||
$device->ports->delete;
|
||||
$device->device_ips->delete;
|
||||
$device->delete;
|
||||
});
|
||||
forward '/ajax/control/admin/delete', { device => param('ip') };
|
||||
};
|
||||
|
||||
ajax '/ajax/control/admin/pseudodevice/update' => require_role admin => sub {
|
||||
|
||||
Reference in New Issue
Block a user