From 44f0302da7c8eecf5729ed91d8f423205e426f82 Mon Sep 17 00:00:00 2001 From: jjhua Date: Wed, 5 May 2010 09:00:15 +0000 Subject: [PATCH] move setupAIXconserver() from xcatconfig.pm and AAsn.pm to Utils.pm git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@5971 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Utils.pm | 124 +++++++++++++++++++++++++++ xCAT-server/lib/xcat/plugins/AAsn.pm | 87 +------------------ xCAT-server/sbin/xcatconfig | 2 +- 3 files changed, 126 insertions(+), 87 deletions(-) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 231e089e8..6d5367042 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -5592,6 +5592,130 @@ sub isStateful return 0; } +#----------------------------------------------------------------------------- + +=head3 setupAIXconserver + + Set AIX conserver + +=cut + +#------------------------------------------------------------------------------- + +=head3 setupAIXconserver + Description: + Set AIX conserver + Arguments: + $verbose: + Returns: + Return result of the operation + Globals: + none + Error: + none + Example: + my $res = xCAT::Utils::setupAIXconserver($verbose); + Comments: + +=cut + +#----------------------------------------------------------------------------- + +sub setupAIXconserver +{ + my ($class, $verbose) = @_; + my $cmd; + my $outref; + my $msg; + my $rc = 0; + + if (!-f "/usr/sbin/conserver") + { + $cmd = "ln -sf /opt/freeware/sbin/conserver /usr/sbin/conserver"; + $outref = xCAT::Utils->runcmd("$cmd", 0); + if ($::RUNCMD_RC != 0) + { + xCAT::MsgUtils->message( + 'E', + "Could not ln -sf /opt/freeware/sbin/conserver /usr/sbin/conserver." + ); + } + else + { + $msg = "ln -sf /opt/freeware/sbin/conserver /usr/sbin/conserver."; + if( $verbose == 1) { + xCAT::MsgUtils->message("I", $msg); + } + } + } + if (!-f "/usr/bin/console") + { + $cmd = "ln -sf /opt/freeware/bin/console /usr/bin/console"; + $outref = xCAT::Utils->runcmd("$cmd", 0); + if ($::RUNCMD_RC != 0) + { + xCAT::MsgUtils->message( + 'E', + "Could not ln -sf /opt/freeware/bin/console /usr/bin/console." + ); + } + else + { + + $msg = "ln -sf /opt/freeware/bin/console /usr/sbin/console."; + if( $verbose == 1) { + xCAT::MsgUtils->message("I", $msg); + } + } + } + + $cmd = "lssrc -a | grep conserver >/dev/null 2>&1"; + $outref = xCAT::Utils->runcmd("$cmd", -1); + if ($::RUNCMD_RC != 0) + { + $cmd = + "mkssys -p /opt/freeware/sbin/conserver -s conserver -u 0 -S -n 15 -f 15 -a \"-o -O1 -C /etc/conserver.cf\""; + $outref = xCAT::Utils->runcmd("$cmd", 0); + if ($::RUNCMD_RC != 0) + { + xCAT::MsgUtils->message('E', "Could not add subsystem conserver."); + } + else + { + xCAT::MsgUtils->message('I', "Added subsystem conserver."); + + # Remove old setting + my $rmitab_cmd = 'rmitab conserver > /dev/null 2>&1'; + $rc = system($rmitab_cmd); + + # add to the /etc/inittab file + my $mkitab_cmd = + 'mkitab "conserver:2:once:/usr/bin/startsrc -s conserver > /dev/console 2>&1" > /dev/null 2>&1'; + $rc = system($mkitab_cmd); # may already be there no error check + } + } + else + { # conserver already a service + # Remove old setting + my $rmitab_cmd = 'rmitab conserver > /dev/null 2>&1'; + $rc = system($rmitab_cmd); + + # make sure it is registered in /etc/inittab file + my $mkitab_cmd = + 'mkitab "conserver:2:once:/usr/bin/startsrc -s conserver > /dev/console 2>&1" > /dev/null 2>&1'; + $rc = system($mkitab_cmd); # may already be there no error check + } + + # now make sure conserver is started + $rc = xCAT::Utils->startService("conserver"); + return $rc; +} + + + + + + 1; diff --git a/xCAT-server/lib/xcat/plugins/AAsn.pm b/xCAT-server/lib/xcat/plugins/AAsn.pm index 3c062ae4e..67cbeb66c 100644 --- a/xCAT-server/lib/xcat/plugins/AAsn.pm +++ b/xCAT-server/lib/xcat/plugins/AAsn.pm @@ -175,7 +175,7 @@ sub init_plugin else { #AIX - $rc = &setupAIXconserver(); + $rc = xCAT::Utils->setupAIXconserver(); } # @@ -531,91 +531,6 @@ sub setupInstallloc } -#----------------------------------------------------------------------------- - -=head3 setupAIXconserver - - Set AIX conserver - -=cut - -#----------------------------------------------------------------------------- - -sub setupAIXconserver -{ - my $cmd; - my $outref; - my $rc = 0; - - if (!-f "/usr/sbin/conserver") - { - $cmd = "ln -sf /opt/freeware/sbin/conserver /usr/sbin/conserver"; - $outref = xCAT::Utils->runcmd("$cmd", 0); - if ($::RUNCMD_RC != 0) - { - xCAT::MsgUtils->message( - 'E', - "Could not ln -sf /opt/freeware/sbin/conserver /usr/sbin/conserver." - ); - } - } - if (!-f "/usr/bin/console") - { - $cmd = "ln -sf /opt/freeware/bin/console /usr/bin/console"; - $outref = xCAT::Utils->runcmd("$cmd", 0); - if ($::RUNCMD_RC != 0) - { - xCAT::MsgUtils->message( - 'E', - "Could not ln -sf /opt/freeware/bin/console /usr/bin/console." - ); - } - } - - $cmd = "lssrc -a | grep conserver >/dev/null 2>&1"; - $outref = xCAT::Utils->runcmd("$cmd", -1); - if ($::RUNCMD_RC != 0) - { - $cmd = - "mkssys -p /opt/freeware/sbin/conserver -s conserver -u 0 -S -n 15 -f 15 -a \"-o -O1 -C /etc/conserver.cf\""; - $outref = xCAT::Utils->runcmd("$cmd", 0); - if ($::RUNCMD_RC != 0) - { - xCAT::MsgUtils->message('E', "Could not add subsystem conserver."); - } - else - { - xCAT::MsgUtils->message('I', "Added subsystem conserver."); - - # Remove old setting - my $rmitab_cmd = 'rmitab conserver > /dev/null 2>&1'; - $rc = system($rmitab_cmd); - - # add to the /etc/inittab file - my $mkitab_cmd = - 'mkitab "conserver:2:once:/usr/bin/startsrc -s conserver > /dev/console 2>&1" > /dev/null 2>&1'; - $rc = system($mkitab_cmd); # may already be there no error check - } - } - else - { # conserver already a service - # Remove old setting - my $rmitab_cmd = 'rmitab conserver > /dev/null 2>&1'; - $rc = system($rmitab_cmd); - - # make sure it is registered in /etc/inittab file - my $mkitab_cmd = - 'mkitab "conserver:2:once:/usr/bin/startsrc -s conserver > /dev/console 2>&1" > /dev/null 2>&1'; - $rc = system($mkitab_cmd); # may already be there no error check - } - - # now make sure conserver is started - $rc = xCAT::Utils->startService("conserver"); - return $rc; -} - - - #----------------------------------------------------------------------------- =head3 setup_CONS diff --git a/xCAT-server/sbin/xcatconfig b/xCAT-server/sbin/xcatconfig index 603fa4bd3..6a9192c96 100644 --- a/xCAT-server/sbin/xcatconfig +++ b/xCAT-server/sbin/xcatconfig @@ -269,7 +269,7 @@ if ($::INITIALINSTALL || $::FORCE || $::UPDATEINSTALL) if ($::osname eq 'AIX') { - &setupAIXconserver; + xCAT::Utils->setupAIXconserver($::VERBOSE); &setupAIXIPMITool;