diff --git a/.gitignore b/.gitignore index 0c19556b..a711b3a9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,85 +1,86 @@ *.swp Makefile.in aclocal.m4 autoconf autoheader autom4te.cache automake autoscan.log compile configure configure.scan config.guess config.log config.sub config.status Makefile depcomp install-sh libtoolize ltmain.sh libtool make/stamp-h1 m4 make/clusterautoconfig.h* missing *.pc .deps .libs *.o *.la *.lo fence/agents/alom/fence_alom fence/agents/apc/fence_apc fence/agents/apc_snmp/fence_apc_snmp fence/agents/baytech/fence_baytech fence/agents/bladecenter/fence_bladecenter fence/agents/brocade/fence_brocade fence/agents/bullpap/fence_bullpap fence/agents/cisco_mds/fence_cisco_mds fence/agents/cisco_ucs/fence_cisco_ucs fence/agents/cpint/fence_cpint fence/agents/drac/fence_drac fence/agents/drac5/fence_drac5 fence/agents/eaton_snmp/fence_eaton_snmp fence/agents/egenera/fence_egenera fence/agents/eps/fence_eps fence/agents/ibmblade/fence_ibmblade fence/agents/ifmib/fence_ifmib fence/agents/ilo/fence_ilo fence/agents/ilo_mp/fence_ilo_mp fence/agents/intelmodular/fence_intelmodular fence/agents/ipdu/fence_ipdu fence/agents/ipmilan/fence_ipmilan fence/agents/ldom/fence_ldom fence/agents/lib/fencing.py fence/agents/lib/fencing_snmp.py fence/agents/lib/fencing.pyc fence/agents/lib/fencing_snmp.pyc fence/agents/lpar/fence_lpar fence/agents/manual/fence_ack_manual fence/agents/mcdata/fence_mcdata fence/agents/netio/fence_netio fence/agents/node_assassin/fence_na fence/agents/node_assassin/fence_na.conf fence/agents/node_assassin/fence_na.lib fence/agents/node_assassin/fence_na.pod fence/agents/nss_wrapper/fence_nss_wrapper fence/agents/rackswitch/fence_rackswitch fence/agents/rhevm/fence_rhevm fence/agents/rsa/fence_rsa fence/agents/rsb/fence_rsb fence/agents/sanbox2/fence_sanbox2 fence/agents/scsi/fence_scsi fence/agents/scsi/fence_scsi_test fence/agents/virsh/fence_virsh fence/agents/vixel/fence_vixel fence/agents/vmware/fence_vmware fence/agents/vmware/fence_vmware_helper fence/agents/wti/fence_wti fence/agents/xcat/fence_xcat fence/agents/zvm/fence_zvm +fence/agents/zvm/fence_zvmip .fence*.tmp fence-agents* .version tests/devices.d/* diff --git a/fence/agents/zvm/Makefile.am b/fence/agents/zvm/Makefile.am index 61bc6287..2dc0005d 100644 --- a/fence/agents/zvm/Makefile.am +++ b/fence/agents/zvm/Makefile.am @@ -1,13 +1,13 @@ MAINTAINERCLEANFILES = Makefile.in sbin_PROGRAMS = fence_zvm fence_zvmip noinst_HEADERS = fence_zvm.h fence_zvm_SOURCES = fence_zvm.c fence_zvm_CFLAGS = -D_GNU_SOURCE fence_zvmip_SOURCES = fence_zvmip.c fence_zvmip_CFLAGS = -D_GNU_SOURCE -man_MANS = fence_zvm.8 fence_zvmip.8 +dist_man_MANS = fence_zvm.8 fence_zvmip.8 diff --git a/fence/agents/zvm/fence_zvm.pl b/fence/agents/zvm/fence_zvm.pl deleted file mode 100644 index ca3d6002..00000000 --- a/fence/agents/zvm/fence_zvm.pl +++ /dev/null @@ -1,411 +0,0 @@ -#!/usr/bin/perl - -use Getopt::Std; -use IPC::Open2; - -my $ME = $0; - -END { - defined fileno STDOUT or return; - close STDOUT and return; - warn "$ME: failed to close standard output: $!\n"; - $? ||= 1; -} - -# Get the program name from $0 and strip directory names -$_=$0; -s/.*\///; -my $pname = $_; - -# 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 - - -$comm_program = s3270; -$debug = 0; -$max_loops = 10; - -sub usage -{ - print "Usage:\n"; - print "\n"; - print "$pname [options]\n"; - print "\n"; - print "Options:\n"; - print " -a IP address or hostname of the physical s390\n"; - print " -h usage\n"; - print " -o metadata print XML metadata for fence agent\n"; - print " -u userid of the virtual machine to fence\n"; - print " -p Password\n"; - print " -S Script to run to retrieve login password\n"; - print " -q quiet mode\n"; - print " -r ipl device \n"; - print " -V Version\n"; - - exit 0; -} - -sub fail -{ - ($msg)=@_; - print "failed: " . $msg . "\n" unless defined $opt_q; - 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 ' - - -fence_zvm is an I/O Fencing agent used on a GFS virtual machine in a s390 or zSeries VM cluster. It uses the s3270 program to log the specified virtual machine out of VM. For fence_zvm to execute correctly, you must have s3270 in your PATH. - -http://www.ibm.com - - - - - IP Address or Hostname - - - - - Userid of the virtual machine to fence - - - - - Login password or passphrase - - - - - Script to retrieve password - - - - - Display help and exit - - - - - - -'; -} - - -sub do_read -{ - my($line); - - $line = ; - - if ($debug) - { - my($l) = ($line); - $l =~ s/\n//; - print "read: $l\n"; - } - - return $line; -} - -sub do_write -{ - my($line) = @_; - - if ($debug) - { - my($l) = ($line); - $l =~ s/\n//; - print "write: $l\n"; - } - - print WRITE_H $line; -} - - -sub look_for -{ - my ($text, $found); - $found = 0; - ($text) = @_; - &do_write("ascii\n"); - while(1){ - $_ = &do_read; - last unless (/^data:/); - $found = 1 if (/$text/); - } - $_ = &do_read; - fail "error while looking for string '$text'." unless (/ok/); - return $found; -} - -sub in_cp_read_state -{ - my ($prev); - $_ = ""; - &do_write("ascii\n"); - while (1){ - $prev = $_; - $_ = &do_read; - last unless (/^data:/); - } - $_ = &do_read; - fail "error while looking for machine state." unless (/ok/); - return 1 if ($prev =~ /CP READ/i); - return 0; -} - -sub send_wait -{ - &do_write("wait\n"); - $_ = &do_read; - $_ = &do_read; - if (/ok/){ - return 1; - } - return 0; -} - -sub send_string -{ - my ($cmd); - ($cmd) = @_; - &do_write('string "' . $cmd . '\n"' . "\n"); - $_ = &do_read; - $_ = &do_read; - if (/ok/){ - return send_wait; - } - return 0; -} - -sub send_cmd -{ - my ($cmd); - ($cmd) = @_; - &do_write($cmd . "\n"); - $_ = &do_read; - $_ = &do_read; - if (/ok/){ - return send_wait; - } - return 0; -} - -sub wait_for_response -{ - my ($pass, $failure, $msg, $found, $loops); - $loops = 0; - $found = 0; - ($pass, $failure, $msg) = @_; - while (1){ - $loops = $loops + 1; - fail "timed out waiting for '$pass'" if ($loops > $max_loops); - &do_write("ascii\n"); - while(1){ - $_ = &do_read; - chomp; - last unless (/^data:/); - $found = 1 if (/$pass/); - if ($failure){ - fail("$msg '$_'") if (/$failure/); - } - } - $_ = &do_read; - fail "wait for response failed '$_'" unless (/ok/); - last if $found; - sleep 1; - } - return 0; -} - -sub check_response -{ - ($action) = @_; - $_ = &do_read; - $_ = &do_read; - fail "$action failed." unless (/ok/); -} - -sub get_options_stdin -{ - my $opt; - my $line = 0; - while( defined($in = <>) ) - { - $_ = $in; - chomp; - - # strip leading and trailing whitespace - s/^\s*//; - s/\s*$//; - - # skip comments - next if /^#/; - - $line+=1; - $opt=$_; - next unless $opt; - - ($name,$val)=split /\s*=\s*/, $opt; - - if ( $name eq "" ) - { - print stderr "parse error: illegal name in option $line\n"; - exit 2; - } - - # DO NOTHING -- this field is used by fenced or stomithd - elsif ($name eq "agent" ) { } - - # FIXME -- depricated. use "userid" and "password" instead. - elsif ($name eq "fm" ) - { - (my $dummy,$opt_u,$opt_p) = split /\s+/,$val; - print STDERR "Depricated \"fm\" entry detected. refer to man page.\n"; - } - - elsif ($name eq "ipaddr" ) - { - $opt_a = $val; - } - - elsif ($name eq "ipl" ) - { - $opt_r = $val; - } - - elsif ($name eq "action") - { - $opt_o = $val; - } - - # FIXME -- depreicated residue of old fencing system - elsif ($name eq "name" ) { } - - elsif ($name eq "passwd" ) - { - $opt_p = $val; - } - elsif ($name eq "passwd_script" ) - { - $opt_S = $val; - } - elsif ($name eq "userid" ) - { - $opt_u = $val; - } - - else - { - print stderr "parse error: unknown option \"$opt\"\n"; - #> exit 2; - } - } -} - -if (@ARGV > 0){ - getopts("a:hp:S:qr:u:Vo:") || fail_usage; - usage if defined $opt_h; - version if defined $opt_V; - - fail_usage "Unkown parameter." if (@ARGV > 0); - - if ((defined $opt_o) && ($opt_o =~ /metadata/i)) { - print_metadata(); - exit 0; - } - - fail_usage "No '-a' flag specified." unless defined $opt_a; - - if (defined $opt_S) { - $pwd_script_out = `$opt_S`; - chomp($pwd_script_out); - if ($pwd_script_out) { - $opt_p = $pwd_script_out; - } - } - - fail_usage "No '-p' or '-S' flag specified." unless defined $opt_p; - fail_usage "No '-u' flag specified." unless defined $opt_u; - -} else { - get_options_stdin(); - - if ((defined $opt_o) && ($opt_o =~ /metadata/i)) { - print_metadata(); - exit 0; - } - - fail "no IP address" unless defined $opt_a; - fail "no userid" unless defined $opt_u; - - if (defined $opt_S) { - $pwd_script_out = `$opt_S`; - chomp($pwd_script_out); - if ($pwd_script_out) { - $opt_p = $pwd_script_out; - } - } - - fail "no password" unless defined $opt_p; -} - -$pid = open2(READ_H, WRITE_H, "$comm_program 2>&1"); -&do_write("connect $opt_a\n"); -$_ = &do_read; -unless (/^U U U/){ - chomp; - fail "communication program failed with '$_'."; -} -$_ = &do_read; -fail "couldn't connect to $opt_a." unless(/ok/); -send_wait or fail "couldn't start 3270 session on $opt_a."; -send_cmd "enter" or fail "couldn't reach logon prompt."; -look_for "Enter one of the following commands:" or fail "doesn't look like a login prompt\n"; -send_string "logon $opt_u $opt_p norun here" or fail "couldn't login"; -send_cmd "clear" or fail "couldn't send the clear command."; -send_string "#cp query userid"; -wait_for_response(uc($opt_u),"Enter one of the following commands:", "logon failed"); -fail "machine not in CP READ state" unless in_cp_read_state; -if (defined $opt_r){ - send_string "ipl $opt_r" or fail "couldn't send reboot command"; -} else { - send_string "stop" or fail "couldn't send stop command\n"; -} -fail "command failed" if look_for "Unknown CP command"; -if (defined $opt_r && !in_cp_read_state){ - send_string "#cp disc"; -} else { - &do_write("disconnect\n"); -} -&do_write("quit\n"); - -print "success: booted userid $opt_u\n" unless defined $opt_q; - -exit 0;