2008-02-08 17:59:49 +00:00
|
|
|
#!/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
|
2008-02-20 02:02:11 +00:00
|
|
|
$result=`startsrc -s ctrmc 2>&1`;
|
2008-02-08 17:59:49 +00:00
|
|
|
if ($?) {
|
2008-02-20 02:02:11 +00:00
|
|
|
print "rmc deamon cannot be started:$result\n";
|
2008-02-08 17:59:49 +00:00
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#enable remote client connection
|
|
|
|
`/usr/bin/rmcctrl -p; /usr/bin/refrsrc IBM.MCP`;
|
|
|
|
|
|
|
|
#define resource in IBM.MCP class on node
|
2008-02-20 02:02:11 +00:00
|
|
|
$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?
|
2008-02-08 17:59:49 +00:00
|
|
|
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($::DELETE) {
|
|
|
|
if (@ARGV < 1) {
|
|
|
|
&usage;
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#remove resource in IBM.MCP class on the node
|
2008-02-20 02:02:11 +00:00
|
|
|
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,
|
2008-02-08 17:59:49 +00:00
|
|
|
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|