Commit 11c3cf4d authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Add an option to initialize the control node ilo given its ip and

ilopswd.
parent f9d835aa
......@@ -17,11 +17,13 @@ use POSIX ":sys_wait_h";
sub usage()
{
print STDERR "Usage: initnodes.pl [-d] [-n] <datafile>\n";
print STDERR "Usage: initnodes.pl [-d] [-n] -i <ip> <ilopswd>\n";
exit(-1);
}
my $optlist = "dn";
my $optlist = "dni";
my $debug = 1;
my $impotent = 0;
my $ipmode = 0;
my %ilomap = ();
my %ctrlmap = ();
my $tempfile = "/tmp/$$.xml";
......@@ -44,6 +46,7 @@ my $WAP = "$TB/sbin/withadminprivs";
sub Fatal($);
sub ChangeBootOrder($);
sub SendXML($$);
sub SetupControlNode($$);
# un-taint path
$ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/site/bin';
......@@ -78,12 +81,9 @@ if (defined($options{"d"})) {
if (defined($options{"n"})) {
$impotent = 1;
}
if (@ARGV != 1) {
usage();
if (defined($options{"i"})) {
$ipmode = 1;
}
my $datafile = $ARGV[0];
Fatal("$datafile does not exist")
if (! -e $datafile);
Fatal("$ILOPSWD does not exist")
if (! -e $ILOPSWD);
......@@ -113,10 +113,22 @@ chomp($pubkey);
if ($pubkey =~ /^(ssh-dss\s+[^\ ]*)/) {
$pubkey = $1;
}
if ($ipmode) {
usage()
if (@ARGV != 2);
exit(SetupControlNode($ARGV[0], $ARGV[1]));
}
usage()
if (@ARGV != 1);
#
# Read in the datafile.
#
my $datafile = $ARGV[0];
Fatal("$datafile does not exist")
if (! -e $datafile);
open(DF, $datafile)
or Fatal("Could not open $datafile: $!");
while (<DF>) {
......@@ -399,6 +411,8 @@ sub SendXML($$)
my @lines = split('\n', $output);
while (@lines) {
my $line = shift(@lines);
print $line
if ($debug);
if ($line =~ /^\s*STATUS="(\w*)"/) {
my $status = hex($1);
if ($status != 0) {
......@@ -425,3 +439,20 @@ sub Fatal($)
die("*** $0:\n".
" $msg\n");
}
#
# Setup the control node.
#
sub SetupControlNode($$)
{
my ($ip, $ilopswd) = @_;
my $xmlgoo = sprintf($setupgoo, $ilopswd, $elabmanpswd, $pubkey);
if (SendXML($ip, $xmlgoo)) {
Fatal("Failed to send xmlgoo to $ip");
}
return 0;
}
......@@ -18,14 +18,6 @@
<IMPORT_SSH_KEY>
-----BEGIN SSH KEY-----
%s elabman
-----END SSH KEY-----
</IMPORT_SSH_KEY>
</RIB_INFO>
<RIB_INFO MODE="write">
<!-- This allows Utah Emulab to ssh in without a password -->
<IMPORT_SSH_KEY>
-----BEGIN SSH KEY-----
ssh-dss AAAAB3NzaC1kc3MAAACBALrHBPWOanqnIevWTrh1vdU+vrR4+Gc/rwld3InKxgU7XlJGc+hs6AV373Xqfga09guMl+Q9wY8XlH3mHNsYRXSX7/wVZFFM59UEHHT7i9Ny34Ua2z+oqr0dxkuj9YkHWpr1/2+uP6R4148V4UYdYqTKbvHb/pUgYc0m+RqwmotdAAAAFQDjsb8pOXOsBO/O3ENMPxIgZXveUwAAAIBeD/O8SxMga+mPw93yGJuuMQig/pZf8sbZpneuYMCclZpSrL2apUqOdqLs8RtOfRFopMawf3Cpr1Qvqkz9FHJbDQKAg+l9SCiQgbd8tv7khQgR42UdUGKqbS/KvXX2jt2E0Febc3I7lXPf9hL9Nn502S/Q2AzU06MMlRjcvN6QTAAAAIBla9o4rgwNXlJgI6ywi877zecgxt227+28Wpkp6Yiiy+dUtv3rRgxLd1VixEChxhLY0nQe6vBaCOKQ1CTY3iTA0FHaWpm4BtEBlU2JrgF5+10GV0M350wJDzQrCc6Ishz7fTNMBMXHUSzp7EZisH0lrzHe2gdECcdn9cdqsye3QA== Administrator
-----END SSH KEY-----
</IMPORT_SSH_KEY>
</RIB_INFO>
......@@ -40,5 +32,13 @@ ssh-dss AAAAB3NzaC1kc3MAAACBALrHBPWOanqnIevWTrh1vdU+vrR4+Gc/rwld3InKxgU7XlJGc+hs
<SESSION_TIMEOUT value="120"/>
</MOD_GLOBAL_SETTINGS>
</RIB_INFO>
<RIB_INFO MODE="write">
<!-- This allows Utah Emulab to ssh in without a password -->
<IMPORT_SSH_KEY>
-----BEGIN SSH KEY-----
ssh-dss AAAAB3NzaC1kc3MAAACBALrHBPWOanqnIevWTrh1vdU+vrR4+Gc/rwld3InKxgU7XlJGc+hs6AV373Xqfga09guMl+Q9wY8XlH3mHNsYRXSX7/wVZFFM59UEHHT7i9Ny34Ua2z+oqr0dxkuj9YkHWpr1/2+uP6R4148V4UYdYqTKbvHb/pUgYc0m+RqwmotdAAAAFQDjsb8pOXOsBO/O3ENMPxIgZXveUwAAAIBeD/O8SxMga+mPw93yGJuuMQig/pZf8sbZpneuYMCclZpSrL2apUqOdqLs8RtOfRFopMawf3Cpr1Qvqkz9FHJbDQKAg+l9SCiQgbd8tv7khQgR42UdUGKqbS/KvXX2jt2E0Febc3I7lXPf9hL9Nn502S/Q2AzU06MMlRjcvN6QTAAAAIBla9o4rgwNXlJgI6ywi877zecgxt227+28Wpkp6Yiiy+dUtv3rRgxLd1VixEChxhLY0nQe6vBaCOKQ1CTY3iTA0FHaWpm4BtEBlU2JrgF5+10GV0M350wJDzQrCc6Ishz7fTNMBMXHUSzp7EZisH0lrzHe2gdECcdn9cdqsye3QA== Administrator
-----END SSH KEY-----
</IMPORT_SSH_KEY>
</RIB_INFO>
</LOGIN>
</RIBCL>
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