From f942046a68cc66166dd92d583ac5b74f3291e0f4 Mon Sep 17 00:00:00 2001 From: lissav Date: Thu, 14 Feb 2013 15:07:21 +0000 Subject: [PATCH] xcatconfig -m add mn to the servicenode table defect 3308 git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@15174 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/sbin/xcatconfig | 64 +++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/xCAT-server/sbin/xcatconfig b/xCAT-server/sbin/xcatconfig index 5156d75a1..d87572c4e 100755 --- a/xCAT-server/sbin/xcatconfig +++ b/xCAT-server/sbin/xcatconfig @@ -2063,7 +2063,8 @@ sub cleanupPSTable =head3 setupMNinDB - Will add/replace the management node to the database with group=__mgmtnode + 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 =cut @@ -2075,15 +2076,17 @@ sub setupMNinDB chomp $mnname; $mnname && $mnname =~ s/\..*//; # strip off domain - # check to see if MN already defined in the database - my $cmds ="XCATBYPASS=Y $::XCATROOT/sbin/tabdump nodelist | grep __mgmtnode"; + # check to see if MN already defined in the nodelist + + my $defined = 0; + 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 { my $chtabcmds; my @mn = split(",", $output); $mn[0] =~ s/"//g; # remove the quotes - if ($mn[0] ne $mnname) { # remove the old, if not current + if ($mn[0] ne $mnname) { # does not match current host name,delete it $chtabcmds = "$::XCATROOT/sbin/chtab -d node=$mn[0] nodelist;"; my $outref = xCAT::Utils->runcmd("$chtabcmds", 0); if ($::RUNCMD_RC != 0) @@ -2091,23 +2094,50 @@ sub setupMNinDB xCAT::MsgUtils->message('E', "Could not run $chtabcmds."); return; } - - } else { # already defined correctly - return; + } else { # it is defined and good + xCAT::MsgUtils->message('I', "$mnname already defined in the nodelist table."); + $defined=1; } + } + # now add with the new name , if not already there + if ($defined ==0) { + my $chtabcmds = "$::XCATROOT/sbin/chtab node=$mnname nodelist.groups=__mgmtnode;"; + my $outref = xCAT::Utils->runcmd("$chtabcmds", 0); + if ($::RUNCMD_RC != 0) + { + xCAT::MsgUtils->message('E', "Could not add $mnname to the noderes table."); + } + else + { + verbose("Added $mnname to the noderes table."); + } + } - # 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) + # now add to the servicenode table with default settings + # check to see if MN already defined in the servicenode table + my $cmds="XCATBYPASS=Y $::XCATROOT/sbin/tabdump servicenode | grep __mgmtnode"; + my $output = xCAT::Utils->runcmd("$cmds", -1); + if ($::RUNCMD_RC != 0) # no management node defined { - xCAT::MsgUtils->message('E', "Could not add $mnname to the database."); + my $chtabcmds; + # add to the servicenode table + $chtabcmds = + "$::XCATROOT/sbin/chtab node=__mgmtnode servicenode.tftpserver=no;"; + my $outref = xCAT::Utils->runcmd("$chtabcmds", 0); + if ($::RUNCMD_RC != 0) + { + xCAT::MsgUtils->message('E', "Could not add $mnname to the servicenode table."); + } + else + { + verbose("Added $mnname to the servicenode table table."); + } + + } else { # it was already correct in the servicenode table + xCAT::MsgUtils->message('I', "$mnname was already defined in the servicenode table."); + } - else - { - verbose("Added $mnname to the database."); - } - return; + return; } #-----------------------------------------------------------------------------