[#216] Ability to enter IP prefix in "Discover" form in web
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
* THANK YOUs
|
* THANK YOUs
|
||||||
* Allow renumber of device to one of its alias IPs
|
* Allow renumber of device to one of its alias IPs
|
||||||
|
* [#216] Ability to enter IP prefix in "Discover" form in web
|
||||||
|
|
||||||
[BUG FIXES]
|
[BUG FIXES]
|
||||||
|
|
||||||
|
|||||||
@@ -5,24 +5,26 @@ use Dancer::Plugin::Ajax;
|
|||||||
use Dancer::Plugin::DBIC;
|
use Dancer::Plugin::DBIC;
|
||||||
use Dancer::Plugin::Auth::Extensible;
|
use Dancer::Plugin::Auth::Extensible;
|
||||||
|
|
||||||
|
use NetAddr::IP qw/:rfc3021 :lower/;
|
||||||
use App::Netdisco::JobQueue 'jq_insert';
|
use App::Netdisco::JobQueue 'jq_insert';
|
||||||
use App::Netdisco::Util::Device 'delete_device';
|
use App::Netdisco::Util::Device 'delete_device';
|
||||||
|
|
||||||
sub add_job {
|
sub add_job {
|
||||||
my ($action, $device, $subaction) = @_;
|
my ($action, $device, $subaction) = @_;
|
||||||
|
|
||||||
if ($device) {
|
my $net = NetAddr::IP->new($device);
|
||||||
$device = NetAddr::IP::Lite->new($device);
|
return if
|
||||||
return if ! $device or $device->addr eq '0.0.0.0';
|
($device and (!$net or $net->num == 0 or $net->addr eq '0.0.0.0'));
|
||||||
}
|
|
||||||
|
|
||||||
jq_insert({
|
my @hostlist = defined $device ? ($net->hostenum) : (undef);
|
||||||
($device ? (device => $device->addr) : ()),
|
|
||||||
action => $action,
|
jq_insert([map {{
|
||||||
($subaction ? (subaction => $subaction) : ()),
|
($_ ? (device => $_->addr) : ()),
|
||||||
username => session('logged_in_user'),
|
action => $action,
|
||||||
userip => request->remote_address,
|
($subaction ? (subaction => $subaction) : ()),
|
||||||
});
|
username => session('logged_in_user'),
|
||||||
|
userip => request->remote_address,
|
||||||
|
}} @hostlist]);
|
||||||
|
|
||||||
true;
|
true;
|
||||||
}
|
}
|
||||||
@@ -45,7 +47,7 @@ foreach my $action (@{ setting('job_prio')->{high} },
|
|||||||
ajax '/ajax/control/admin/delete' => require_role admin => sub {
|
ajax '/ajax/control/admin/delete' => require_role admin => sub {
|
||||||
send_error('Missing device', 400) unless param('device');
|
send_error('Missing device', 400) unless param('device');
|
||||||
|
|
||||||
my $device = NetAddr::IP::Lite->new(param('device'));
|
my $device = NetAddr::IP->new(param('device'));
|
||||||
send_error('Bad device', 400)
|
send_error('Bad device', 400)
|
||||||
if ! $device or $device->addr eq '0.0.0.0';
|
if ! $device or $device->addr eq '0.0.0.0';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user