Commit e268f181 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Add lookup by UUID() for protogeni.

Add SelectOS() method to encapsulate the os_select goo.
parent 056dfa36
......@@ -18,6 +18,7 @@ my $TB = "@prefix@";
my $BOSSNODE = "@BOSSNODE@";
my $EVENTSYS = @EVENTSYS@;
my $WOL = "$TB/sbin/whol";
my $OSSELECT = "$TB/bin/os_select";
# XXX stinky hack detection
my $ISUTAH = @TBMAINSITE@;
......@@ -70,15 +71,29 @@ sub mysystem($)
#
sub Lookup($$)
{
my ($class, $nodeid) = @_;
my ($class, $token) = @_;
my $nodeid;
if ($token =~ /^\w+\-\w+\-\w+\-\w+\-\w+$/) {
my $query_result =
DBQueryWarn("select node_id from nodes ".
"where uuid='$token'");
return undef
if (! $query_result || !$query_result->numrows);
($nodeid) = $query_result->fetchrow_array();
}
elsif ($token =~ /^[-\w]+$/) {
$nodeid = $token;
}
else {
return undef;
}
# Look in cache first
return $nodes{$nodeid}
if (exists($nodes{$nodeid}));
return undef
if (! ($nodeid =~ /^[-\w]+$/));
my $query_result =
DBQueryWarn("select * from nodes as n ".
"where n.node_id='$nodeid'");
......@@ -1086,10 +1101,9 @@ sub SetEventState($$)
}
#
# Create new vnodes. This routine obviously cannot be called on a specific
# instance since it does not exist! The argument is still a reference; to a
# a hash of options to be used when creating the new node(s). A list of the
# node names is returned.
# Create new vnodes. The argument is a reference; to a a hash of options to
# be used when creating the new node(s). A list of the node names is
# returned.
#
sub CreateVnodes($$)
{
......@@ -1557,6 +1571,26 @@ sub NewRootPasswd($)
return 0;
}
#
# Invoke OS selection. Currently we use this to reset to default boot,
# but might change later to take an argument.
#
sub SelectOS($)
{
my ($self) = @_;
# Must be a real reference.
return -1
if (! ref($self));
my $node_id = $self->node_id();
system("$OSSELECT -b $node_id");
return -1
if ($?);
return 0;
}
# _Always_ make sure that this 1 is at the end of the file...
1;
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