From 39e72aec0beaedcedf1b6b3f754a28b736612882 Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 30 Oct 2012 14:55:03 +0000 Subject: [PATCH] if MN already in the database, xcatconfig -m will replace it, if the name has changed git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14164 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/sbin/xcatconfig | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/xCAT-server/sbin/xcatconfig b/xCAT-server/sbin/xcatconfig index 26ecca1ba..37340ecbb 100755 --- a/xCAT-server/sbin/xcatconfig +++ b/xCAT-server/sbin/xcatconfig @@ -2045,7 +2045,7 @@ sub cleanupPSTable =head3 setupMNinDB - Will add the management node to the database with group=__mgmtnode + Will add/replace the management node to the database with group=__mgmtnode =cut @@ -2056,6 +2056,29 @@ sub setupMNinDB my $mnname = `hostname`; chomp $mnname; $mnname && $mnname =~ s/\..*//; # strip off domain + + # check to see if MN already defined in the database + my $cmds = "XCATBYPASS=Y $::XCATROOT/bin/nodels __mgmtnode"; + my $mn = xCAT::Utils->runcmd("$cmds", 0); + if ($::RUNCMD_RC != 0) + { + xCAT::MsgUtils->message('E', "Could run $cmds."); + return; + } + my $chtabcmds; + if (($mn) && ($mn ne $mnname)) { # remove the old one + $chtabcmds = "$::XCATROOT/sbin/chtab -d node=$mn nodelist;"; + my $outref = xCAT::Utils->runcmd("$chtabcmds", 0); + if ($::RUNCMD_RC != 0) + { + xCAT::MsgUtils->message('E', "Could not run $chtabcmds."); + return; + } + + } else { # already defined correctly + return; + } + # now add a new one my $chtabcmds = "$::XCATROOT/sbin/chtab node=$mnname nodelist.groups=__mgmtnode;"; my $outref = xCAT::Utils->runcmd("$chtabcmds", 0); if ($::RUNCMD_RC != 0)