From 331dc24373a8019237adb9ba9fa3bbb4779645ed Mon Sep 17 00:00:00 2001 From: nott Date: Tue, 3 Jul 2012 18:01:49 +0000 Subject: [PATCH] add check for myxcatpost file name git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@13234 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/InstUtils.pm | 61 +++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/perl-xCAT/xCAT/InstUtils.pm b/perl-xCAT/xCAT/InstUtils.pm index f0ca93af8..c77189d47 100644 --- a/perl-xCAT/xCAT/InstUtils.pm +++ b/perl-xCAT/xCAT/InstUtils.pm @@ -121,43 +121,52 @@ sub myxCATname # make sure xcatd is running - & db is available # this routine is called during initial install of xCAT - my $cmd="lsxcatd -d > /dev/null 2>&1"; - my $outref = []; - @$outref = `$cmd`; - my $rc = $? >> 8; - - if ($rc == 0) - { - - if (xCAT::Utils->isMN()) - { - + my $cmd="lsxcatd -d > /dev/null 2>&1"; + my $outref = []; + @$outref = `$cmd`; + my $rc = $? >> 8; + if ($rc == 0) + { + if (xCAT::Utils->isMN()) + { # 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); + $name = xCAT::NetworkUtils->gethostname($hostname); } else { $name = $hostname; } - - } - elsif (xCAT::Utils->isServiceNode()) - { - - # the myxcatpost_ 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) + } + elsif (xCAT::Utils->isServiceNode()) + { + my $filename; + # get any files with the format myxcatpost_* + my $lscmd = qq~/bin/ls /xcatpost/myxcatpost_* 2>/dev/null~; + my $output = `$lscmd`; + my $rc = $? >> 8; + if ($rc == 0) { - ($junk, $name) = split('=', $output); + foreach my $line ( split(/\n/, $output)) { + my ($junk, $hostname) = split('myxcatpost_', $line); + if (xCAT::InstUtils->is_me($hostname)) { + $filename="/xcatpost/myxcatpost_$hostname"; + last; + } + } + + if ( -e $filename ) { + my $catcmd = qq~/bin/cat $filename | grep '^NODE=' 2>/dev/null~; + my $string = `$catcmd`; + if ($rc == 0) { + ($junk, $name) = split('=', $string); + } + } } - } - } + } + } if (!$name) { $name = hostname();