fix verbose msgs in runcmd

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8773 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
nott 2011-01-30 17:00:54 +00:00
parent 0faaa9e0a5
commit 0b6c2347ca
2 changed files with 44 additions and 41 deletions

View File

@ -120,42 +120,39 @@ sub myxCATname
{
my ($junk, $name);
$name = hostname();
# make sure xcatd is running - & db is available
# this routine is called during initial install of xCAT
# this routine is also called during initial install of xCAT
my $rc = `lsxcatd -d`;
if ($rc) {
return $name;
}
if ($rc == 0) {
if (xCAT::Utils->isMN())
{
if (xCAT::Utils->isMN())
{
# read the site table, master attrib
my $hostname = xCAT::Utils->get_site_Master();
if (($hostname =~ /\d+\.\d+\.\d+\.\d+/) || ($hostname =~ /:/))
{
# read the site table, master attrib
my $hostname = xCAT::Utils->get_site_Master();
if (($hostname =~ /\d+\.\d+\.\d+\.\d+/) || ($hostname =~ /:/))
{
$name = xCAT::NetworkUtils->gethostname($hostname);
}
else
{
$name = $hostname;
}
}
else
{
$name = $hostname;
}
}
elsif (xCAT::Utils->isServiceNode())
{
}
elsif (xCAT::Utils->isServiceNode())
{
# the myxcatpost_<nodename> file should exist on all nodes!
my $catcmd = "cat /xcatpost/myxcatpost_* | grep '^NODE='";
# - can't use runcmd because this routine is called by runcmd
# the myxcatpost_<nodename> file should exist on all nodes!
my $catcmd = "cat /xcatpost/myxcatpost_* | grep '^NODE='";
# - can't use runcmd because this routine is called by runcmd
my $output = `$catcmd`;
if ($::RUNCMD_RC == 0)
{
($junk, $name) = split('=', $output);
}
my $output = `$catcmd`;
if ($::RUNCMD_RC == 0)
{
($junk, $name) = split('=', $output);
}
}
}
if (!$name) {
@ -1216,7 +1213,7 @@ sub dolitesetup
# also copy $instrootloc/.default contents
$ccmd = "/usr/bin/cp -p -r $instrootloc/.default $SRloc";
my $out = xCAT::Utils->runcmd("$ccmd", -1);
$out = xCAT::Utils->runcmd("$ccmd", -1);
if ($::RUNCMD_RC != 0)
{
my $rsp;

View File

@ -1035,19 +1035,25 @@ sub runcmd
# redirect stderr to stdout
if (!($cmd =~ /2>&1$/)) { $cmd .= ' 2>&1'; }
# get this systems name as known by xCAT management node
#my $Sname = xCAT::InstUtils->myxCATname();
if ($::VERBOSE)
{
# get this systems name as known by xCAT management node
my $Sname = xCAT::InstUtils->myxCATname();
my $msg;
if ($Sname) {
$msg = "Running command on $Sname: $cmd";
} else {
$msg="Running command: $cmd";
}
#if ($::VERBOSE)
#{
# if ($::CALLBACK){
# my $rsp = {};
# $rsp->{data}->[0] = "Running command on $Sname: $cmd\n";
# xCAT::MsgUtils->message("I", $rsp, $::CALLBACK);
# } else {
# xCAT::MsgUtils->message("I", "Running command on $Sname: $cmd\n");
# }
#}
if ($::CALLBACK){
my $rsp = {};
$rsp->{data}->[0] = "$msg\n";
xCAT::MsgUtils->message("I", $rsp, $::CALLBACK);
} else {
xCAT::MsgUtils->message("I", "$msg\n");
}
}
my $outref = [];
@$outref = `$cmd`;