xcat-core/xCAT-rmc/scripts/perl/configrmcnode
linggao b5869e05a4 more work on RMC monitoring
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@530 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
2008-02-20 02:02:11 +00:00

74 lines
1.7 KiB
Perl
Executable File

#!/usr/bin/env perl
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
use Getopt::Long;
#################################################################
# This script is used for RMC node configuration
##################################################################
sub usage
{
my %rsp;
print "Usage:
configrmcnode -a node_name ms_name ms_ip_addresses ms_node_id
configrmcnode -d node_name
";
}
print "configrmcnode get called\n";
if (!GetOptions(
'a' => \$::ADD,
'd' => \$::DELETE,)) {
&usage;
exit 1;
}
if ($::ADD) {
if (@ARGV < 4) {
&usage;
exit 1;
}
#check if rsct is installed and running
if (! -e "/usr/bin/lsrsrc") {
print "RSCT is not is not installed.\n";
exit 1;
}
my $result=`/usr/bin/lssrc -s ctrmc`;
if ($result !~ /active/) {
#restart rmc daemon
$result=`startsrc -s ctrmc 2>&1`;
if ($?) {
print "rmc deamon cannot be started:$result\n";
exit 1;
}
}
#enable remote client connection
`/usr/bin/rmcctrl -p; /usr/bin/refrsrc IBM.MCP`;
#define resource in IBM.MCP class on node
$result=`/usr/bin/mkrsrc-api IBM.MCP::MNName::"$ARGV[0]"::KeyToken::"$ARGV[1]"::IPAddresses::"$ARGV[2]"::NodeID::$ARGV[3] 2>&1`;
if ($?) { print "define resource in IBM.MCP class result=$result\n"; }
#TODO: create predefined sensors. How does the scipts get on the node? mount? come with image?
exit 0
}
if ($::DELETE) {
if (@ARGV < 1) {
&usage;
exit 1;
}
#remove resource in IBM.MCP class on the node
my $result= `/usr/bin/rmrsrc-api -s IBM.MCP::"MNName=\\\"\"$ARGV[0]\\\"\"" 2>&1`;
if ($?) { print "remove resource in IBM.MCP class result=$result\n"; }
#TODO: remove predefined sensors,
exit 0;
}