warn "$ME: failed to close standard output: $!\n";
$? ||= 1;
}
# Get the program name from $0 and strip directory names
$_=$0;
s/.*\///;
my $pname = $_;
$opt_o = 'disable'; # Default fence action
# WARNING!! Do not add code bewteen "#BEGIN_VERSION_GENERATION" and
# "#END_VERSION_GENERATION" It is generated by the Makefile
#BEGIN_VERSION_GENERATION
$RELEASE_VERSION="";
$REDHAT_COPYRIGHT="";
$BUILD_DATE="";
#END_VERSION_GENERATION
sub usage
{
print "Usage:\n";
print "\n";
print "$pname [options]\n";
print "\n";
print "Options:\n";
print " -a <ip> IP address or hostname of switch\n";
print " -h usage\n";
print " -l <name> Login name\n";
print " -n <num> Port number to disable\n";
print " -o <string> Action: disable (default), enable or metadata\n";
print " -p <string> Password for login\n";
print " -S <path> Script to run to retrieve login password\n";
print " -q quiet mode\n";
print " -V version\n";
exit 0;
}
sub fail
{
($msg) = @_;
print $msg."\n" unless defined $opt_q;
$t->close if defined $t;
exit 1;
}
sub fail_usage
{
($msg)=@_;
print STDERR $msg."\n" if $msg;
print STDERR "Please use '-h' for usage.\n";
exit 1;
}
sub version
{
print "$pname $RELEASE_VERSION $BUILD_DATE\n";
print "$REDHAT_COPYRIGHT\n" if ( $REDHAT_COPYRIGHT );
exit 0;
}
sub print_metadata
{
print '<?xml version="1.0" ?>
<resource-agent name="fence_mcdata" shortdesc="I/O Fencing agent for McData FC switches" >
<longdesc>
fence_mcdata is an I/O Fencing agent which can be used with McData FC switches. It logs into a McData switch via telnet and disables a specified port. Disabling the port which a machine is connected to effectively fences that machine. Lengthy telnet connections to the switch should be avoided while a GFS cluster is running because the connection will block any necessary fencing actions.
After a fence operation has taken place the fenced machine can no longer connect to the McData FC switch. When the fenced machine is ready to be brought back into the GFS cluster (after reboot) the port on the McData FC switch needs to be enabled. This can be done by running fence_mcdata and specifying the enable action.
</longdesc>
<vendor-url>http://www.brocade.com</vendor-url>
<parameters>
<parameter name="action" unique="1" required="1">
<getopt mixed="-o [action]" />
<content type="string" default="disable" />
<shortdesc lang="en">Fencing Action</shortdesc>
</parameter>
<parameter name="ipaddr" unique="1" required="1">
<getopt mixed="-a [ip]" />
<content type="string" />
<shortdesc lang="en">IP Address or Hostname</shortdesc>
</parameter>
<parameter name="login" unique="1" required="1">
<getopt mixed="-l [name]" />
<content type="string" />
<shortdesc lang="en">Login Name</shortdesc>
</parameter>
<parameter name="passwd" unique="1" required="0">
<getopt mixed="-p [password]" />
<content type="string" />
<shortdesc lang="en">Login password or passphrase</shortdesc>