diff --git a/perl-xCAT/xCAT/DSHCLI.pm b/perl-xCAT/xCAT/DSHCLI.pm index 73d1a9232..9b09140c5 100644 --- a/perl-xCAT/xCAT/DSHCLI.pm +++ b/perl-xCAT/xCAT/DSHCLI.pm @@ -3240,11 +3240,14 @@ sub bld_resolve_nodes_hash # find out the names for the Management Node my @MNnodeinfo = xCAT::NetworkUtils->determinehostname; my $mname = pop @MNnodeinfo; # hostname - #my $rsp = {}; - #$rsp->{info}->[0] = - # "Management node name is $mname."; - # xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); - + my $cmd="hostname"; + my $localhostname = xCAT::Utils->runcmd($cmd,0); + if ($::RUNCMD_RC != 0) + { + my $rsp = {}; + $rsp->{info}->[0] = "Command: $cmd failed. Continuing..."; + xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); + } foreach my $target (@target_list) { @@ -3253,11 +3256,9 @@ sub bld_resolve_nodes_hash my $localhost; my $user; my $context = "XCAT"; - # check to see if this node is the Management Node - if ($mname) { - if ($mname eq $target) { + # check to see if this node is the Management Node we are on, can run local commands (sh,cp) + if (($mname eq $target) || ($localhostname eq $target)){ $localhost=$target; - } } my %properties = ( 'hostname' => $hostname, diff --git a/xCAT-server/sbin/xcatconfig b/xCAT-server/sbin/xcatconfig index f9d0b428a..3106f2b90 100755 --- a/xCAT-server/sbin/xcatconfig +++ b/xCAT-server/sbin/xcatconfig @@ -2107,8 +2107,8 @@ sub cleanupPSTable =head3 setupMNinDB - Will add/replace the management node to the noderes table with group=__mgmtnode - Will add/replace the management node to the servicenode tble with group=__mgmtnode + Will add the management node to the noderes table with group=__mgmtnode + Will add the management node to the servicenode tble with group=__mgmtnode =cut @@ -2126,25 +2126,18 @@ sub setupMNinDB my $cmds="XCATBYPASS=Y $::XCATROOT/sbin/tabdump nodelist | grep __mgmtnode"; my @output = xCAT::Utils->runcmd("$cmds", -1); - if ($::RUNCMD_RC == 0) # found a management node defined + if ($::RUNCMD_RC == 0) # found nodes in __mgmtnode { my $chtabcmds; - my @mn = split(",", $output[0]); - $mn[0] =~ s/"//g; # remove the quotes - if ($mn[0] ne $mnname) { # does not match current host name,delete it - my $size=@output; # if more than one management node defined, do not remove any - if ($size == 1) { - $chtabcmds = "$::XCATROOT/sbin/chtab -d node=$mn[0] nodelist;"; - my $outref = xCAT::Utils->runcmd("$chtabcmds", 0); - if ($::RUNCMD_RC != 0) - { - xCAT::MsgUtils->message('E', "Could not run $chtabcmds."); - return; - } - } - } else { # it is defined and good - xCAT::MsgUtils->message('I', "$mnname already defined in the nodelist table."); + # Look through the MN list and see if this MN is defined + foreach my $line (@output) { + my @mn = split(",", $line); + $mn[0]=~ s/"//g; # remove the quotes + if ($mn[0] eq $mnname) { # already in the database + verbose("$mnname already defined in the the nodelist table."); $defined=1; + last; + } } } # now add with the new name , if not already there @@ -2199,9 +2192,10 @@ sub setupMNinDB } } else { # it was already defined in the servicenode table - xCAT::MsgUtils->message('I', "$mnname was already defined in the servicenode table."); + verbose("$mnname already defined in the the servicenode table."); } + xCAT::MsgUtils->message('I', "Management Node defined in the database."); return; } #-----------------------------------------------------------------------------