various fixes and now tested
This commit is contained in:
@@ -4,6 +4,8 @@ use Dancer qw/:syntax :script/;
|
|||||||
|
|
||||||
use App::Netdisco::Util::Device 'get_device';
|
use App::Netdisco::Util::Device 'get_device';
|
||||||
use Module::Load ();
|
use Module::Load ();
|
||||||
|
use Net::OpenSSH;
|
||||||
|
use Try::Tiny;
|
||||||
|
|
||||||
use base 'Dancer::Object::Singleton';
|
use base 'Dancer::Object::Singleton';
|
||||||
|
|
||||||
@@ -43,11 +45,12 @@ Returns C<undef> if the connection fails.
|
|||||||
|
|
||||||
has 'ssh' => ( is => 'rw' );
|
has 'ssh' => ( is => 'rw' );
|
||||||
has 'auth' => ( is => 'rw' );
|
has 'auth' => ( is => 'rw' );
|
||||||
|
has 'host' => ( is => 'rw' );
|
||||||
has 'platform' => ( is => 'rw' );
|
has 'platform' => ( is => 'rw' );
|
||||||
|
|
||||||
sub arpnip {
|
sub arpnip {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->platform->arpnip(@_, $self->ssh, $self->auth);
|
$self->platform->arpnip(@_, $self->host, $self->ssh, $self->auth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +74,7 @@ sub session_for {
|
|||||||
push(@master_opts, @{$auth->{ssh_master_opts}})
|
push(@master_opts, @{$auth->{ssh_master_opts}})
|
||||||
if $auth->{ssh_master_opts};
|
if $auth->{ssh_master_opts};
|
||||||
|
|
||||||
$Net::OpenSSH::debug = ~0 if setting('log') eq 'debug';
|
$Net::OpenSSH::debug = $ENV{SSH_TRACE};
|
||||||
my $ssh = Net::OpenSSH->new(
|
my $ssh = Net::OpenSSH->new(
|
||||||
$device->ip,
|
$device->ip,
|
||||||
user => $auth->{username},
|
user => $auth->{username},
|
||||||
@@ -102,6 +105,7 @@ sub session_for {
|
|||||||
my $sess = MySession->new(
|
my $sess = MySession->new(
|
||||||
ssh => $ssh,
|
ssh => $ssh,
|
||||||
auth => $auth,
|
auth => $auth,
|
||||||
|
host => $device->ip,
|
||||||
platform => $platform->new(),
|
platform => $platform->new(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ register_worker({ phase => 'main', driver => 'cli' }, sub {
|
|||||||
or return Status->defer("arpnip failed: could not SSH connect to $device");
|
or return Status->defer("arpnip failed: could not SSH connect to $device");
|
||||||
|
|
||||||
# should be both v4 and v6
|
# should be both v4 and v6
|
||||||
my $arps = get_arps_cli($device, $cli->arpnip);
|
my $arps = get_arps_cli($device, [$cli->arpnip]);
|
||||||
|
|
||||||
# update node_ip with ARP and Neighbor Cache entries
|
# update node_ip with ARP and Neighbor Cache entries
|
||||||
my $now = 'to_timestamp('. (join '.', gettimeofday) .')';
|
my $now = 'to_timestamp('. (join '.', gettimeofday) .')';
|
||||||
@@ -89,7 +89,7 @@ sub get_arps_cli {
|
|||||||
$entries ||= [];
|
$entries ||= [];
|
||||||
|
|
||||||
foreach my $entry (@$entries) {
|
foreach my $entry (@$entries) {
|
||||||
next unless check_mac( $entry->{mac} );
|
next unless check_mac($entry->{mac}, $device);
|
||||||
push @arps, {
|
push @arps, {
|
||||||
node => $entry->{mac},
|
node => $entry->{mac},
|
||||||
ip => $entry->{ip},
|
ip => $entry->{ip},
|
||||||
|
|||||||
Reference in New Issue
Block a user