Commit ec103b4c authored by Leigh Stoller's avatar Leigh Stoller

More little fixes for things that became apparent on the Moonshot

cluster.
parent 7f90bc5c
......@@ -40,6 +40,7 @@ my $BOSSNODE_IP = "@BOSSNODE_IP@";
use libosload_switch;
use base qw(libosload_switch);
use libdb;
use libEmulab;
use emutil;
use EmulabConstants;
......@@ -144,7 +145,7 @@ sub createExpectObject($$)
"Could not connect to switch: $error\n";
return -1;
}
$self->expectobj($exp);
$self->expectobj($nodeobject,$exp);
return 0;
}
......@@ -207,7 +208,7 @@ sub writeConfig($$@)
{
my ($self, $nodeobject, @config) = @_;
my $node_id = $nodeobject->node_id();
my $exp = $self->expectobj();
my $exp = $self->expectobj($nodeobject);
$self->dprint(0,"$self writeConfig($node_id): \n");
......@@ -280,7 +281,7 @@ sub DeviceReconfigure($$)
return -1;
}
if (!defined($experiment)) {
$self->expectobj()->soft_close();
$self->expectobj($nodeobject)->soft_close();
return 0;
}
my $user = $experiment->GetSwapper();
......@@ -296,12 +297,23 @@ sub DeviceReconfigure($$)
# to use that flash file for a user. Why can't it be simple like
# MLNX-OS, where you just send a bunch of strings over!
#
my @keys;
my @keys = ();
$user->GetSSHKeys(\@keys);
#
# ssh-rsa keys only, need to have at least one.
#
my @tmp = ();
foreach my $key (@keys) {
next
if ($key !~ /^ssh-rsa/);
push(@tmp, $key);
}
@keys = @tmp;
if (!@keys) {
print STDERR "No ssh keys for $uid\n";
return 0;
}
}
#
# Create a temporary file to write the keys to.
......@@ -313,8 +325,6 @@ sub DeviceReconfigure($$)
return -1;
}
foreach my $key (@keys) {
next
if ($key !~ /^ssh-rsa/);
print $fp $key . "\n";
}
close($fp);
......@@ -365,7 +375,7 @@ sub Reboot($$)
if ($self->createExpectObject($nodeobject)) {
goto reboot;
}
my $exp = $self->expectobj();
my $exp = $self->expectobj($nodeobject);
$exp->clear_accum(); # Clean the accumulated output, as a rule.
$exp->send("exit\n"); # Back into admin mode.
......
......@@ -60,12 +60,29 @@ sub New($$$)
my $self = $class->SUPER::New($parent, $type);
bless($self, $class);
# Need to store the expectobj someplace for the node.
$self->{'EXPECT'} = {};
# We always want debugging output for switches
if ($self->debug() == 0) {
$self->debug(1);
}
return $self;
}
sub expectobj($$;$)
{
my ($self,$nodeobject,$obj) = @_;
my $node_id = $nodeobject->node_id();
if (defined($obj)) {
$self->{'EXPECT'}->{$node_id} = $obj;
}
else {
return undef
if (!exists($self->{'EXPECT'}->{$node_id}));
}
return $self->{'EXPECT'}->{$node_id};
}
sub AddNode($$$$)
{
......@@ -527,28 +544,26 @@ sub Pingable($$)
}
#
# Is the switch running the NOS. Imperfect test of course.
# Is the switch running the NOS. Imperfect test of course, but we
# really want to avoid power cycle, so if the switch def_boot_osid is
# set to the node type default, try and log into the switch. Only our
# switches running our NOS images will have the right username and
# password, so if we can log in, it is running the NOS.
#
sub RunningNOS($$)
{
my ($self, $nodeobject) = @_;
my $node_id = $nodeobject->node_id();
#
# See if we think its running the NOS. Going to use the current
# op_mode for this, looking to see if its the same as the op_mode
# for the nodetype default image.
#
my $default_imageid = $nodeobject->default_imageid();
my $default_image = OSImage->Lookup($default_imageid);
if (!defined($default_image)) {
tberror("$self: RunningNOS($node_id) Could not get $default_image\n");
my $default_osid = $nodeobject->default_osid();
my $def_boot_osid = $nodeobject->def_boot_osid();
if ($def_boot_osid != $default_osid) {
return 0;
}
if ($default_image->op_mode() ne $nodeobject->op_mode()) {
$self->dprint(0, "$self RuningNOS($node_id): not running the NOS\n");
if ($self->createExpectObject($nodeobject)) {
return 0;
}
$self->expectobj($nodeobject)->soft_close();
$self->dprint(0, "$self RuningNOS($node_id): running the NOS\n");
return 1;
}
......
......@@ -40,6 +40,7 @@ use libossetup;
use libosload_new;
use libtblog_simple;
use Node;
use libreboot;
use English;
use Data::Dumper;
use overload ('""' => 'Stringify');
......
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