Commit 8dfd5adf authored by Leigh Stoller's avatar Leigh Stoller

Add -mng option; ssh to the management (ilo) interface instead of the

node. There auth method has to be ssh-key in the DB, since I did not
feel like dealing with password auth and the required tty stuff.
parent be0c285a
...@@ -12,13 +12,12 @@ use English; ...@@ -12,13 +12,12 @@ use English;
# An ssh frontend to determine if the node is local or remote, and to # An ssh frontend to determine if the node is local or remote, and to
# add in special options. # add in special options.
# #
# NOTE THE DIFFERENT SYNTAX!
#
sub usage() sub usage()
{ {
print STDOUT print STDERR
"Usage: sshtb [ssh args] -host <hostname> [command and args ...]\n"; "Usage: sshtb [ssh args] [-mng] -host <hostname> [command and args]\n";
print STDERR
" Use -mng option to talk to ilo/drac interface\n";
exit(-1); exit(-1);
} }
...@@ -40,6 +39,7 @@ my $hostname; ...@@ -40,6 +39,7 @@ my $hostname;
my $chpid = 0; my $chpid = 0;
# Run command on the local machine. # Run command on the local machine.
my $runlocal = 0; my $runlocal = 0;
my $domng = 0;
# #
# Testbed Support libraries # Testbed Support libraries
...@@ -49,6 +49,7 @@ use libdb; ...@@ -49,6 +49,7 @@ use libdb;
use libtestbed; use libtestbed;
use Node; use Node;
use Interface; use Interface;
use EmulabConstants;
# #
# Turn off line buffering on output # Turn off line buffering on output
...@@ -69,6 +70,10 @@ if (@ARGV < 2) { ...@@ -69,6 +70,10 @@ if (@ARGV < 2) {
# Find everything before the -host. # Find everything before the -host.
while (@ARGV) { while (@ARGV) {
my $arg = shift(@ARGV); my $arg = shift(@ARGV);
if ($arg eq "-mng") {
$domng = 1;
next;
}
if ($arg eq "-host") { if ($arg eq "-host") {
$hostname = shift(@ARGV); $hostname = shift(@ARGV);
last; last;
...@@ -95,6 +100,7 @@ if ($hostname eq $FSNODE && $FSNODE eq $BOSSNODE) { ...@@ -95,6 +100,7 @@ if ($hostname eq $FSNODE && $FSNODE eq $BOSSNODE) {
else { else {
my $user; my $user;
my $node = Node->Lookup($hostname); my $node = Node->Lookup($hostname);
my $key;
if (defined($node)) { if (defined($node)) {
if ($node->isvirtnode()) { if ($node->isvirtnode()) {
...@@ -117,6 +123,30 @@ else { ...@@ -117,6 +123,30 @@ else {
} }
} }
} }
elsif ($domng) {
#
# We want to log into the management port.
#
my $interface = Interface->LookupManagement($node);
if (! defined($interface)) {
print STDERR "No management interface for $node\n";
exit(1);
}
$hostname = $interface->IP();
#
# Also need info from the outlets authorization table.
#
($user,$key) = $node->GetOutletAuthInfo("ssh-key");
if (!defined($user)) {
print STDERR "No authinfo user defined for $node\n";
exit(1);
}
if (! -e $key) {
print STDERR "Key $key does not exist\n";
exit(1);
}
}
elsif ($node->isremotenode() && !$node->isdedicatedremote()) { elsif ($node->isremotenode() && !$node->isdedicatedremote()) {
$user = "emulabman"; $user = "emulabman";
} }
...@@ -151,6 +181,7 @@ else { ...@@ -151,6 +181,7 @@ else {
@cmdargs = (@sshargs, @args, @cmdargs = (@sshargs, @args,
(defined($user) ? ("-l", "$user") : ()), (defined($user) ? ("-l", "$user") : ()),
(defined($key) ? ("-i", "$key") : ()),
$hostname, @ARGV); $hostname, @ARGV);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment