Commit 4b63217d authored by Leigh B Stoller's avatar Leigh B Stoller

Add node_licensekeys table to store licenses keys. What else? Added

an option to initilo to gather the keys via the ILO's web XML
interface, and stick the result into the DB. Doing this, just in case
a node loses its keys (which actually happened at BBN).
parent aa6a8a16
......@@ -638,6 +638,7 @@ sub TBDB_PHYSICAL_NODE_TABLES() {
'plab_mapping' => [ 'node_id' ],
'node_utilization' => [ 'node_id' ],
'subbosses' => [ 'node_id' ],
'node_licensekeys' => [ 'node_id' ],
);
}
......
......@@ -24,6 +24,8 @@
use English;
use Getopt::Std;
use Socket;
use XML::Simple;
use Data::Dumper;
use IO::Handle; # thousands of lines just for autoflush :-(
use POSIX ":sys_wait_h";
......@@ -36,14 +38,16 @@ sub usage()
print STDERR "Usage: initilo.pl [-d] [-n] <ilopswd> <nodeid>\n";
print STDERR "Usage: initilo.pl [-d] [-n] -b <nodeid>\n";
print STDERR "Usage: initilo.pl [-d] [-n] -o <nodeid>\n";
print STDERR "Usage: initilo.pl [-d] [-n] -k <nodeid> ...\n";
print STDERR "Usage: initilo.pl [-d] [-n] -c <ip> <ilopswd>\n";
exit(-1);
}
my $optlist = "dncobs";
my $optlist = "dncobsk";
my $debug = 0;
my $impotent = 0;
my $control = 0;
my $dooutlet = 0;
my $doilokey = 0;
my $bootorder = 0;
my $tempfile = "/tmp/$$.xml";
......@@ -65,6 +69,7 @@ sub ChangeBootOrder($);
sub SendXML($$);
sub SetupControlNode($$);
sub DoOutlet($);
sub DoIloKey($);
# un-taint path
$ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/site/bin';
......@@ -102,6 +107,9 @@ if (defined($options{"n"})) {
if (defined($options{"c"})) {
$control = 1;
}
if (defined($options{"k"})) {
$doilokey = 1;
}
if (defined($options{"b"})) {
$bootorder = 1;
}
......@@ -151,6 +159,15 @@ if ($dooutlet) {
exit(DoOutlet($ARGV[0]));
}
if ($doilokey) {
usage()
if (!@ARGV);
foreach my $node (@ARGV) {
DoIloKey($node);
}
exit(0);
}
if ($bootorder) {
usage()
if (@ARGV != 1);
......@@ -199,13 +216,6 @@ if (SendXML($iloIP, $xmlgoo)) {
Fatal("Failed to send xmlgoo to $iloIP");
}
#
# The boot order cannot be changed via ribcl. What a pain.
#
if (0 && ChangeBootOrder($iloIP)) {
Fatal("Failed to change the boot order on $iloIP")
}
#
# This changes the Administrator password. We do this cause it is
# an 8 digit number, and the login is well known. So eventually it
......@@ -223,7 +233,14 @@ $xmlgoo = sprintf($sshkeygoo, $elabmanpswd, $pubkey, $pubkey);
if (SendXML($iloIP, $xmlgoo)) {
Fatal("Failed to send addsshkey xml to $iloIP");
}
#
# The boot order cannot be changed via ribcl. What a pain.
#
if (ChangeBootOrder($iloIP)) {
Fatal("Failed to change the boot order on $iloIP")
}
#
# This resets the ilo.
#
......@@ -445,3 +462,40 @@ sub DoOutlet($)
return 0;
}
sub DoIloKey($)
{
my ($node_id) = @_;
my $node = Node->Lookup($node_id);
if (!defined($node)) {
Fatal("No such node");
}
# This has to be in the interfaces table already.
my $management_interface = Interface->LookupManagement($node);
if (!defined($management_interface)) {
Fatal("No management interface for $node");
}
my $iloIP = $management_interface->IP();
my $cmd = "wget -q -O - --no-check-certificate ".
"https://$iloIP/xmldata?item=CpqKey";
my $ilostuff = `$cmd`;
Fatal("wget failed")
if ($?);
my $xmlparse = eval { XMLin($ilostuff,
ContentKey => '-content',
SuppressEmpty => undef); };
Fatal($@)
if ($@);
if (!exists($xmlparse->{'KEY'})) {
Fatal("No KEY in:\n$ilostuff")
}
my $ilokey = $xmlparse->{'KEY'};
my $safe_ilokey = DBQuoteSpecial($ilokey);
DBQueryFatal("replace into node_licensekeys set ".
" node_id='$node_id', keytype='ilo', keydata=$safe_ilokey");
return 0;
}
......@@ -2601,6 +2601,18 @@ CREATE TABLE `node_idlestats` (
PRIMARY KEY (`node_id`,`tstamp`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table `node_licensekeys`
--
DROP TABLE IF EXISTS `node_licensekeys`;
CREATE TABLE `node_licensekeys` (
`node_id` varchar(32) NOT NULL default '',
`keytype` varchar(16) default NULL,
`keydata` mediumtext,
PRIMARY KEY (`node_id`,`keytype`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table `node_reservations`
--
......
#
# Add a tabke to hold license keys.
#
use strict;
use libdb;
use libinstall;
use installvars;
use OSinfo;
use Image;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
if(!DBTableExists("node_licensekeys")) {
DBQueryFatal("CREATE TABLE `node_licensekeys` ( ".
" `node_id` varchar(32) NOT NULL default '', ".
" `keytype` varchar(16) default NULL, ".
" `keydata` mediumtext, ".
" PRIMARY KEY (`node_id`,`keytype`) ".
") ENGINE=MyISAM DEFAULT CHARSET=latin1");
}
return 0;
}
# Local Variables:
# mode:perl
# End:
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