App-Netdisco
view release on metacpan or search on metacpan
lib/App/Netdisco/Transport/SSH.pm view on Meta::CPAN
package App::Netdisco::Transport::SSH;
use Dancer qw/:syntax :script/;
use App::Netdisco::Util::Device 'get_device';
use Module::Load ();
use Net::OpenSSH;
use Try::Tiny;
use base 'Dancer::Object::Singleton';
=head1 NAME
App::Netdisco::Transport::SSH
=head1 DESCRIPTION
Returns an object which has an active SSH connection which can be used
for some actions such as arpnip.
my $cli = App::Netdisco::Transport::SSH->session_for( ... );
=cut
__PACKAGE__->attributes(qw/ sessions /);
sub init {
my ( $class, $self ) = @_;
$SIG{CHLD} = 'IGNORE';
$self->sessions( {} );
return $self;
}
=head1 session_for( $ip )
Given an IP address, returns an object instance configured for and connected
to that device.
Returns C<undef> if the connection fails.
=cut
{
package MySession;
use Moo;
has 'ssh' => ( is => 'rw' );
has 'auth' => ( is => 'rw' );
has 'host' => ( is => 'rw' );
has 'platform' => ( is => 'rw' );
sub arpnip {
my $self = shift;
$self->platform->arpnip(@_, $self->host, $self->ssh, $self->auth)
if $self->platform->can('arpnip');
}
sub macsuck {
my $self = shift;
$self->platform->macsuck(@_, $self->host, $self->ssh, $self->auth)
if $self->platform->can('macsuck');
}
sub subnets {
my $self = shift;
$self->platform->subnets(@_, $self->host, $self->ssh, $self->auth)
if $self->platform->can('subnets');
}
( run in 0.727 second using v1.01-cache-2.11-cpan-39bf76dae61 )