Andy Baugh hace 3 años
padre
commit
aed2df9117
Se han modificado 4 ficheros con 68 adiciones y 0 borrados
  1. 2 0
      Makefile
  2. 7 0
      README.md
  3. 24 0
      bin/rprove
  4. 35 0
      lib/App/Prove/Remote/Connector.pm

+ 2 - 0
Makefile

@@ -0,0 +1,2 @@
+all:
+	sudo cpanm -i -n Net::OpenSSH Net::SFTP::Foreign Getopt::Long

+ 7 - 0
README.md

@@ -1,2 +1,9 @@
 # perl-App-Prove-Remote
 Prove wrapper designed for executing tests from your local host on remote hosts
+
+TROUBLESHOOTING
+---------------
+
+Help! I can't connect!
+Please check your OpenSSH client config, as this is used by default.
+If it is setup correctly for the host you wish to connect to, everything will "just work".

+ 24 - 0
bin/rprove

@@ -0,0 +1,24 @@
+#!/usr/bin/env perl
+package App::Prove::Remote::rprove;
+
+use strict;
+use warnings;
+
+use experimental 'signatures';
+
+use App::Prove::Remote::Connector ();
+use Getopt::Long                  ();
+
+exit run() unless caller();
+
+sub run {
+    my ( $host, $verbosity, @tests ) = ('', '');
+    Getopt::Long::GetOptions(
+        'host|h'    => \$host,
+        'verbosity' => \$verbosity,
+    );
+    my $conn = App::Prove::Remote::Connector->new($host, $verbosity);
+    return 0;
+}
+
+1;

+ 35 - 0
lib/App/Prove/Remote/Connector.pm

@@ -0,0 +1,35 @@
+use strict;
+use warnings;
+
+use Net::OpenSSH ();
+use Net::SFTP::Foreign ();
+
+use experimental 'signatures';
+
+# Cache the connections/objects internally
+my ( $ssh, $sftp );
+sub new ( $class,  $host='127.0.0.1', $verbosity ) {
+    my $obj = bless {
+        'ppid'      => $$, # May not need this ultimately
+        'host'      => $host,
+        'verbosity' => $verbosity
+    }, $class;
+    return $obj;
+}
+
+# Plenty o code duplication here, can probably golf down?
+sub ssh ($self) {
+    return $ssh if $ssh;
+    print "# Connecting to $self->{'host'} via Net::OpenSSH" if $self->{'verbosity'} >= 1;
+    $ssh = Net::OpenSSH->new($self->{'host'});
+    return $ssh;
+}
+
+sub sftp ($self) {
+    return $sftp if $sftp;
+    print "# Connecting to $self->{'host'} via Net::SFTP::Foreign" if $self->{'verbosity'} >= 1;
+    $sftp = Net::SFTP::Foreign->new($self->{'host'});
+    return $sftp;
+}
+
+1;