-Have Table plugin read, if available, /etc/xcat/cfgloc automatically if not instructed by XCATCFG

-Add utility for zapping all open database connections
-Use aforementioned utility in ipmi and blade console methods to have cleaner database communication
-Remove the suboptimal /etc/sysconfig/xcat code from the console methods


git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@763 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
jbjohnso 2008-03-11 20:27:46 +00:00
parent 7cf0511bae
commit f51ca380b5
4 changed files with 22 additions and 25 deletions

View File

@ -172,6 +172,16 @@ sub new
$self->{dbpass}="";
my $xcatcfg = (defined $ENV{'XCATCFG'} ? $ENV{'XCATCFG'} : '');
unless ($xcatcfg) {
if (-r "/etc/xcat/cfgloc") {
my $cfgl;
open($cfgl,"<","/etc/xcat/cfgloc");
$xcatcfg = <$cfgl>;
close($cfgl);
chomp($xcatcfg);
$ENV{'XCATCFG'}=$xcatcfg; #Store it in env to avoid many file reads
}
}
if ($xcatcfg =~ /^$/)
{
if (-d "/opt/xcat/cfg")

View File

@ -127,6 +127,13 @@ sub xfork
return $rc;
}
sub close_all_dbhs {
foreach (values %{$::XCAT_DBHS})
{ #@{$drh->{ChildHandles}}) {
$_->disconnect;
undef $_;
}
}
#-------------------------------------------------------------------------------
=head3 isLinux

View File

@ -5,20 +5,9 @@ BEGIN
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
}
use lib "$::XCATROOT/lib/perl";
my $xcatcfg;
open($xcatcfg,"<","/etc/sysconfig/xcat");
while (<$xcatcfg>) {
if (/^\s*XCATCFG/) {
(my $jnk,$ENV{XCATCFG})=split /=/,$_,2;
chomp($ENV{XCATCFG});
$ENV{XCATCFG} =~ s/^'//;
$ENV{XCATCFG} =~ s/'$//;
last;
}
}
close($xcatcfg);
use xCAT::Table;
use xCAT::Utils;
use File::Basename;
my $scriptname = $0;
@ -55,7 +44,8 @@ if ($mpatab) {
if ($dba->{password}) { $password = $dba->{password}; }
}
}
sleep 5;
xCAT::Utils::close_all_dbhs;
sleep 5; #Slow start, I know, but with exec, can't return
exec "ssh -t $username"."@"."$mm console -o -T blade[$slot]";
#my $pathtochild= dirname($scriptname). "/";
#exec $pathtochild."blade.expect $mm $slot $username $password";

View File

@ -5,20 +5,9 @@ BEGIN
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
}
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
my $xcatcfg;
open($xcatcfg,"<","/etc/sysconfig/xcat");
while (<$xcatcfg>) {
if (/^\s*XCATCFG/) {
(my $jnk,$ENV{XCATCFG})=split /=/,$_,2;
chomp($ENV{XCATCFG});
$ENV{XCATCFG} =~ s/^'//;
$ENV{XCATCFG} =~ s/'$//;
last;
}
}
close($xcatcfg);
use lib "$::XCATROOT/lib/perl";
use xCAT::Table;
use xCAT::Util;
my $dba;
my $ipmitab = xCAT::Table->new('ipmi');
unless ($ipmitab) { sleep 5; die "Unable to open IPMI table"; }
@ -41,6 +30,7 @@ if ($dba) {
if ($dba->{username}) { $username = $dba->{username}; }
if ($dba->{password}) { $password = $dba->{password}; }
}
xCAT::Util::close_all_dbhs;
system "ipmitool -I lanplus -U $username -P $password -H $bmc sol deactivate"; #Stop any active session
exec "ipmitool -I lanplus -U $username -P $password -H $bmc sol activate";