add macwalk and arpnip buttons to device details

This commit is contained in:
Oliver Gorwits
2013-05-30 05:59:53 +01:00
parent 3d688c7d83
commit fdac8f6c33
2 changed files with 21 additions and 8 deletions

View File

@@ -4,6 +4,8 @@ use Dancer ':syntax';
use Dancer::Plugin::Ajax; use Dancer::Plugin::Ajax;
use Dancer::Plugin::DBIC; use Dancer::Plugin::DBIC;
use Try::Tiny;
sub add_job { sub add_job {
my ($jobtype, $device) = @_; my ($jobtype, $device) = @_;
@@ -13,6 +15,8 @@ sub add_job {
and $device->addr ne '0.0.0.0'; and $device->addr ne '0.0.0.0';
} }
try {
# job might already be in the queue, so this could die
schema('netdisco')->resultset('Admin')->create({ schema('netdisco')->resultset('Admin')->create({
($device ? (device => $device->addr) : ()), ($device ? (device => $device->addr) : ()),
action => $jobtype, action => $jobtype,
@@ -20,6 +24,7 @@ sub add_job {
username => session('user'), username => session('user'),
userip => request->remote_address, userip => request->remote_address,
}); });
}
} }
# we have a separate list for jobs needing a device to avoid queueing # we have a separate list for jobs needing a device to avoid queueing

View File

@@ -99,7 +99,15 @@
<td> <td>
<form method="post" class="nd_inline-form" action="[% uri_for('/admin/discover') %]"> <form method="post" class="nd_inline-form" action="[% uri_for('/admin/discover') %]">
<input type="hidden" value="[% d.ip %]" name="device" type="text"/> <input type="hidden" value="[% d.ip %]" name="device" type="text"/>
<button type="submit" class="btn btn-info btn-small">Rediscover</button> <button type="submit" class="btn btn-info btn-small">Discover</button>
</form>
<form method="post" class="nd_inline-form" action="[% uri_for('/admin/arpnip') %]">
<input type="hidden" value="[% d.ip %]" name="device" type="text"/>
<button type="submit" class="btn btn-info btn-small">Arpnip</button>
</form>
<form method="post" class="nd_inline-form" action="[% uri_for('/admin/macsuck') %]">
<input type="hidden" value="[% d.ip %]" name="device" type="text"/>
<button type="submit" class="btn btn-info btn-small">Macsuck</button>
</form> </form>
</td> </td>
</tr> </tr>