diff --git a/perl-xCAT-2.0/xCAT/Table.pm b/perl-xCAT-2.0/xCAT/Table.pm index e9c94119d..2a9c9cfea 100644 --- a/perl-xCAT-2.0/xCAT/Table.pm +++ b/perl-xCAT-2.0/xCAT/Table.pm @@ -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") diff --git a/perl-xCAT-2.0/xCAT/Utils.pm b/perl-xCAT-2.0/xCAT/Utils.pm index 474ba5976..d8793b289 100644 --- a/perl-xCAT-2.0/xCAT/Utils.pm +++ b/perl-xCAT-2.0/xCAT/Utils.pm @@ -127,6 +127,13 @@ sub xfork return $rc; } +sub close_all_dbhs { + foreach (values %{$::XCAT_DBHS}) + { #@{$drh->{ChildHandles}}) { + $_->disconnect; + undef $_; + } +} #------------------------------------------------------------------------------- =head3 isLinux diff --git a/xCAT-server-2.0/share/xcat/cons/blade b/xCAT-server-2.0/share/xcat/cons/blade index dfb7cbbaa..ca9b330d9 100755 --- a/xCAT-server-2.0/share/xcat/cons/blade +++ b/xCAT-server-2.0/share/xcat/cons/blade @@ -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"; diff --git a/xCAT-server-2.0/share/xcat/cons/ipmi b/xCAT-server-2.0/share/xcat/cons/ipmi index 84e2181ec..649a0e340 100755 --- a/xCAT-server-2.0/share/xcat/cons/ipmi +++ b/xCAT-server-2.0/share/xcat/cons/ipmi @@ -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";