[Linux-cluster] help reqd. - VMware ESX 3.5 fencing

MARY, Mathieu Mathieu.MARY at neufcegetel.fr
Wed Feb 20 15:37:56 UTC 2008


the script i sent to you was, or it should have been this one, apologies if I miscopied, as I tried lots of scripts when I was searching for the good one at the time. 

it uses the VMware::VIM2Runtime wich is the ESX 3.xx perl library

 

 

#!/usr/bin/perl

 

###############################################################################

###############################################################################

##

##  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.

##  Copyright (C) 2004 Red Hat, Inc.  All rights reserved.

##

##  This copyrighted material is made available to anyone wishing to use,

##  modify, copy, or redistribute it subject to the terms and conditions

##  of the GNU General Public License v.2.

##

###############################################################################

###############################################################################

 

use Getopt::Std;

use VMware::VIM2Runtime;

 

# 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

$FENCE_RELEASE_NAME="2.0.64";

$REDHAT_COPYRIGHT=("Copyright (C) Red Hat, Inc.  2004  All rights reserved.");

$BUILD_DATE="(built Thu Jun 28 07:25:05 EDT 2007)";

#END_VERSION_GENERATION

 

sub usage

{

    print "Usage:\n\n";

    print "$pname [options]\n\n";

    print "Options:\n";

    print "  -a <ip>          IP address or hostname of VirtualCenter server\n";

    print "  -h               Usage\n";

    print "  -n <name>        Virtual machine name to reset\n";

                print "  -l <string>      Login name for VirtualCenter server\n";

    print "  -p <string>      Password for login\n";

    print "  -V               version\n\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 $FENCE_RELEASE_NAME $BUILD_DATE\n";

  print "$REDHAT_COPYRIGHT\n" if ( $REDHAT_COPYRIGHT );

 

  exit 0;

}

 

if (@ARGV > 0) {

    getopts("a:hn:l:p:V") || fail_usage ;

 

    usage if defined $opt_h;

    version if defined $opt_V;

 

    fail_usage "Unknown parameter." if (@ARGV > 0);

 

    fail_usage "No '-a' flag specified." unless defined $opt_a;

                fail_usage "No '-l' flag specified." unless defined $opt_l;

    fail_usage "No '-p' flag specified." unless defined $opt_p;

    fail_usage "No '-n' flag specified." unless defined $opt_n;

 

} else {

    get_options_stdin();

 

    fail "failed: no IP/host address for the VirtualCenter." unless defined $opt_a;

                fail "failed: no login name provided." unless defined $opt_l;

    fail "failed: no password provided." unless defined $opt_p;

    fail "failed: no VM name specified." unless defined $opt_n;

}

 

#

# Set up and log in

#

 

Vim::login(service_url=>"https://$opt_a/sdk/vimService", user_name=>"$opt_l", password=>"$opt_p");

 

#

# Do the command

#

 

my $vm_view = Vim::find_entity_view(view_type => 'VirtualMachine', filter => {name => $opt_n});

 

if (!$vm_view)

{

        fail "Virtual Machine name not found.";

}

 

$vm_view->ResetVM();

 

Vim::logout();

 

print "success: VM: $opt_n reset.\n";

exit 0;

 

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("parse error: illegal name in option $line\n");

           exit 2;

        }

 

        # DO NOTHING -- this field is used by fenced

        elsif ($name eq "agent" ) { }

 

        elsif ($name eq "login" ) {

            $opt_l = $val;

        }

 

        elsif ($name eq "ipaddr" )

        {

            $opt_a = $val;

        }

 

        elsif ($name eq "name" ) { }

 

        elsif ($name eq "passwd" )

        {

            $opt_p = $val;

        }

 

        elsif ($name eq "port" )

        {

            $opt_n = $val;

        }

    }

}

 

 

 

 

Regards,

 

 

Mathieu

________________________________

De : linux-cluster-bounces at redhat.com [mailto:linux-cluster-bounces at redhat.com] De la part de Panigrahi, Santosh Kumar
Envoyé : mercredi 20 février 2008 14:01
À : linux clustering
Objet : RE: [Linux-cluster] help reqd. - VMware ESX 3.5 fencing

 

Hi,

 

I am facing some issues on trying to fence a node using "fence_vmware" Perl script. This script is attached in this mail.

 

I have a single standalone physical machine installed with VMware ESX 3.5. On top of this I have created 2 VMs with guest OS as Rhel5.1 AP. In both the VMs I have installed VMware Perl APIs. I have kept "fence_vmware" script at /sbin directory on both the VMs. My cluster.conf file is also attached in this mail. I have not configured any service becoz I want only to test VMware fencing agent here.

 

Through conga on trying to fence a node, I am getting following errors in my /var/log/messages.

 

Feb 18 21:12:24 p2pv6 fence_node[5723]: agent "fence_vmware" reports: Global symbol "$RELEASE_VERSION" requires explicit package name at /sbin/fence_vmware line 102. Global symbol "$BUILD_DATE" requires explicit package name at /sbin/fence_vmware line 102. Global symbol "$REDHAT_COPYRIGHT" requires explicit package name at

Feb 18 21:12:24 p2pv6 fence_node[5723]: agent "fence_vmware" reports: /sbin/fence_vmware line 103. Global symbol "$REDHAT_COPYRIGHT" requires explicit package name at /sbin/fence_vmware line 103. Global symbol "$opt_ZZv" requires explicit package name at /sbin/fence_vmware line 267. Global symbol "$pwd_script_out" requires

Feb 18 21:12:24 p2pv6 fence_node[5723]: agent "fence_vmware" reports: explicit package name at /sbin/fence_vmware line 300. Global symbol "$pwd_script_out" requires explicit package name at /sbin/fence_vmware line 301. Global symbol "$pwd_script_out" requires explicit package name at /sbin/fence_vmware line 302. Global symb

Feb 18 21:12:24 p2pv6 fence_node[5723]: agent "fence_vmware" reports: ol "$pwd_script_out" requires explicit package name at /sbin/fence_vmware line 303. Global symbol "$pwd_script_out" requires explicit package name at /sbin/fence_vmware line 322. Global symbol "$pwd_script_out" requires explicit package name at /sbin/fenc

Feb 18 21:12:24 p2pv6 fence_node[5723]: agent "fence_vmware" reports: e_vmware line 323. Global symbol "$pwd_script_out" requires explicit package name at /sbin/fence_vmware line 324. Global symbol "$pwd_script_out" requires explicit package name at /sbin/fence_vmware line 325. Bareword "version" not allowed while "strict s

Feb 18 21:12:24 p2pv6 fence_node[5723]: agent "fence_vmware" reports: ubs" in use at /sbin/fence_vmware line 291. Execution of /sbin/fence_vmware aborted due to compilation errors.

Feb 18 21:12:24 p2pv6 fence_node[5723]: Fence of "p2pv5.tr.unisys.com" was unsuccessful

 

My initial guess is this fencing agent script can only be run with old VMware Perl APIs. Please correct me. Is there any way to run this script in my current environment?

 

If anyone is having a working script for VMware ESX 3.5 server, please pass it.

 

Thanks,

Santosh

 

________________________________

From: linux-cluster-bounces at redhat.com [mailto:linux-cluster-bounces at redhat.com] On Behalf Of MARY, Mathieu
Sent: Thursday, February 14, 2008 6:39 PM
To: linux clustering
Subject: RE: [Linux-cluster] help reqd. - VMware ESX 3.5 fencing

 

VC is the virtual center server, i understood from your mail that you're using virtual infrastructure, but you question points out the fact that you maybe are using standalone ESX server ?

in our configuration we use an ESX farm of 4 servers managed by the VC server where we connect with the VI client

 

 

<fencedevice name="your_fence_method" agent="fence_vi3" ipaddr="yourserver_ip" port="your_vm_name" login="xxx" passwd="yyyyy"/>

 

though I don't know if it works on standalone server, maybe you would have ton install the VMI perlmodules described inside the script to you ESX 3.5 server

 

________________________________

De : linux-cluster-bounces at redhat.com [mailto:linux-cluster-bounces at redhat.com] De la part de Panigrahi, Santosh Kumar
Envoyé : jeudi 14 février 2008 13:50
À : linux clustering
Objet : RE: [Linux-cluster] help reqd. - VMware ESX 3.5 fencing

 

Thanks Marry for the script. I will test and let you know. By the way what's this VC server? Is it the system where I am running my VI client?

Can you please elaborate little more on this configuration like where I will keep this script, what will I mention in my cluster.conf file and etc.

 

Thanks,

Santosh  

________________________________

From: linux-cluster-bounces at redhat.com [mailto:linux-cluster-bounces at redhat.com] On Behalf Of MARY, Mathieu
Sent: Thursday, February 14, 2008 5:59 PM
To: linux clustering
Subject: RE: [Linux-cluster] help reqd. - VMware ESX 3.5 fencing

 

hello,

 

i'm using this script for VI 3 and  ESX3.02 i guess it would work for you too, cannot remember where I found it though :-)

note that you have to send the restart request to your VC server and not to the ESX server

 

________________________________

De : linux-cluster-bounces at redhat.com [mailto:linux-cluster-bounces at redhat.com] De la part de Panigrahi, Santosh Kumar
Envoyé : jeudi 14 février 2008 12:37
À : linux-cluster at redhat.com
Objet : [Linux-cluster] help reqd. - VMware ESX 3.5 fencing

 

Hi,

 

Does anybody have configured fencing in VMware ESX 3.5 environment? I appreciate any help.

 

I have got some info from http://www.tournament.org.il/run/index.php?/archives/140-VMware-Fencing-in-RedHat-Cluster-5-RHCS5.html .

This script given here is for VMware server. Any idea whether it will work for ESX 3.5 server or not?

 

My system configurations are as follows.

 

Host machine    : Unisys ES7000-one with host OS as VMware ESX 3.5

Guest Machines: Guest OS as Rhel5.1 AP

 

I am connecting to host machine using VMware VI 3.0.

 

Thanks,

Santosh

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/linux-cluster/attachments/20080220/31fee571/attachment.htm>


More information about the Linux-cluster mailing list