Start a Conversation

This post is more than 5 years old

Solved!

Go to Solution

52540

November 9th, 2010 12:00

Dell UPS Management Software not working on Vmware VMA 4.1

The install logs for the Linux version of the software all say successful.  However, when I try and start ./monitor, I get the error

[vi-admin@vma ups]$ ./monitor
 Starting Manager:
Unable to locate the application's 'main' class. The class 'manager2.Manager2' must be public and have a 'public static void main(String[])' method. (LAX)
GUI-
 Done

Are you supposed to unzip the InstallerData zip files first?  When I did that and deleted the two zip files, I received an error.   

Thanks,

Michael

13 Posts

March 8th, 2011 09:00

I have finally finished the scripts and two pages of instructions to gracefully shutdown a Dell UPS with vMA 4.1.

Please see    http://communities.vmware.com/message/1712606#1712606

Good luck to all.

Michael Ceccanese

44 Posts

November 11th, 2010 08:00

Hi Michael,

 

./monitor is a command to be used in x-Windows mode only not in text-based mode.  For text-based mode use the command ./agent start which will start the s/w agent.  This command can be run in either x-Windows or text mode.

 

Hope this helps

Andy

44 Posts

November 11th, 2010 09:00

Rename the below information into a file called "ghettoHostShutdown41.pl"

 

 

#!/usr/bin/perl -w

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

# Author: William Lam

# 01/09/2010

# http://communities.vmware.com/docs/DOC-11902

# http://www.engineering.ucsb.edu/~duonglt/vmware/

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

use strict;

use warnings;

use POSIX qw(ceil floor);

use VMware::VmaTargetLib;

use Sys::Hostname;

use Net::SMTP;

use Pod::Usage;

use File::Temp qw(tempfile tempdir);

 

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

# List of ESX(i) hosts to exclude

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

 

my @exclude_hosts = (

"himalaya.primp-industries.com",

"superleggera.primp-industries.com",

"mauna-loa.primp-industries.com",

"etf-vmh1-3-sfm.ops.sfdc.net",

"etf-vmh1-4-sfm.ops.sfdc.net"

);

 

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

# EMAIL CONF

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

 

my $EMAIL_HOST = "emailserver";

my $EMAIL_DOMAIN = `hostname --fqdn`;

my $EMAIL_TO = 'William Lam ';

my $EMAIL_FROM = 'ghettoHostShutdown41 ';

 

my $vma_name = `hostname --short`;

chomp($vma_name);

my %opts = (

    host_operation => {

        type => "=s",

        help => "Host Operation to perform [shutdown|standby|autoquery|dryrun]",

        required => 0,

        default => "dryrun",

        },

    vm_operation => {

        type => "=s",

        help => "VM Operation to perform [suspend|shutdown|auto]",

        required => 0,

        default => "suspend",

        },

    logoutput => {

        type => "=s",

        help => "Log output of this script",

        required => 0,

        },

    loglevel => {

        type => "=s",

        help => "Log level [info|debug]",

        required => 0,

        default => "debug",

        },

    vma_name => {

        type => "=s",

        help => "Display name of the vMA VM running this shutdown script",

        required => 0,

        default => $vma_name,

        },

    timeout => {

        type => "=s",

        help => "Timeout value before shutting down all hosts (mintues)",

        required => 1,

        },

    hostfile => {

        type => "=s",

        help => "Manual list of the ESX(i) hosts in which to prioritize the shutdown process",

        required => 0,

        },

    sendmail => {

        type => "",

        help => "Email shutdown log",

        required => 0,

        default => 0,

        },

);

 

# validate options, and connect to the server

Opts::add_options(%opts);

Opts::parse();

Opts::set_option("passthroughauth", 1);

Opts::validate();

 

my $vm_operation = Opts::get_option('vm_operation');

my $host_operation = Opts::get_option('host_operation');

my $log_output = Opts::get_option('logoutput');

my $loglevel = Opts::get_option('loglevel');

my $timeout = Opts::get_option('timeout');

my $hostfile = Opts::get_option('hostfile');

my $sendmail = Opts::get_option('sendmail');

$vma_name = Opts::get_option('vma_name');

 

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

######## PLEASE DO NOT MODIFY PAST THIS LINE #########

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

 

# log level

my %log_level=(

    "debug"   => 1,

    "info"    => 2,

    "warn"    => 3,

    "error"   => 4,

    "fatal"   => 5,

);

 

my $LOGLEVEL = $log_level{$loglevel};

 

my $vma_login;

my $host_login;

my @hosts = ();

my %validhosts = ();

my $vma_host_name;

my $recommended_timeout = 0;

 

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

#process and get hosts managed by vMA

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

if (!$log_output) {

    if ($sendmail) {

        $log_output = "/tmp/".tempfile();

    } else {

        $log_output = "&STDOUT";

    }

}

 

if($hostfile) {

    &processFile($hostfile);

} else {

    @hosts = VmaTargetLib::enumerate_targets();

}

 

summaryStart();

getHostsAndVms();

verifyAndShutdownHosts();

summaryEnd();

 

Util::disconnect();

 

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

#

#                  HELPER FUNCTIONS

#

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

 

sub sendMail {

    my $smtp = Net::SMTP->new($EMAIL_HOST ,Hello => $EMAIL_DOMAIN,Timeout => 30,);

 

    unless($smtp) {

       die "Error: Unable to setup connection with email server: \"" . $EMAIL_HOST . "\"!\n";

    }

 

    open(DATA, $log_output) || die("Cannot open $log_output: $?");

    my @report = ;

    close(DATA);

 

    my $boundary = 'frontier';

 

    $smtp->mail($EMAIL_FROM);

    $smtp->to($EMAIL_TO);

    $smtp->data();

    $smtp->datasend('From: '.$EMAIL_FROM."\n");

    $smtp->datasend('To: '.$EMAIL_TO."\n");

    $smtp->datasend('Subject: ghettoHostShutdown41.pl Completed '.giveMeDate('MDYHMS')."\n");

    $smtp->datasend("MIME-Version: 1.0\n");

    $smtp->datasend("Content-type: multipart/mixed;\n\tboundary=\"$boundary\"\n");

    $smtp->datasend("\n");

    $smtp->datasend("--$boundary\n");

    $smtp->datasend("Content-type: text/plain\n");

    $smtp->datasend("Content-Disposition: quoted-printable\n");

    $smtp->datasend("\nReport $log_output is attached!\n");

    $smtp->datasend("--$boundary\n");

    $smtp->datasend("Content-Type: application/text; name=\"$log_output\"\n");

    $smtp->datasend("Content-Disposition: attachment; filename=\"$log_output\"\n");

    $smtp->datasend("\n");

    $smtp->datasend("@report\n");

    $smtp->datasend("--$boundary--\n");

    $smtp->dataend();

    $smtp->quit;

 

    `/bin/rm -f $log_output`;

}

 

sub verifyAndShutdownHosts {

    if($host_operation ne 'autoquery') {

        &log("info","Verifying all VMs are either suspended or powered of - TIMEOUT set to: $timeout min\n");

        my $count = 1;

 

        while($count <= $timeout) {

            my $no_powered_on_vms = 1;

            for my $hostname (keys %validhosts) {

                if($validhosts{$hostname} eq "yes") {

                    eval {

                        &log("debug", "Login by vi-fastpass to: " . $hostname);

                        $host_login=VmaTargetLib::query_target($hostname);

                        $host_login->login();

                        my $host_view = Vim::find_entity_view(view_type => 'HostSystem');

                        my $vms = Vim::get_views(mo_ref_array => $host_view->vm, properties => ['name','runtime.powerState']);

                        my $totalVMs = 0;

                        my $numOfVMsOn = 0;

                        foreach(@$vms) {

                            $totalVMs += 1;

                           if($_->{'runtime.powerState'}->val eq 'poweredOn' && $_->{'name'} ne $vma_name) {

                                $numOfVMsOn += 1;

                            }

                        }

 

                        #remove hosts that have no more powered on VMs so

                        #they're not checked again

                        if($numOfVMsOn eq 0) {

                            $validhosts{$hostname} = "no";

                            &log("info","Host: $hostname has $numOfVMsOn/$totalVMs VMs powered on and is ready!\n");

                        } else {

                            &log("info","Host: $hostname has $numOfVMsOn/$totalVMs VMs still powered on!\n");

}

                        Util::disconnect();

 

                        #use this variable to check if all hosts are ready,

                        #if so, don't wait for the entire timeout

                        if($numOfVMsOn > 0 ) {

                            $no_powered_on_vms = 0;

                        }

                    };

                    if($@) {

                        &log("info","Error: Unable to login to host: ". "\"$hostname\"! Ensure host is being managed by vMA!");

                    }

                }

            }

 

            last if($no_powered_on_vms eq 1);

            last if($host_operation eq 'dryrun');

 

            if($host_operation ne 'dryrun') {

                &log("info","Count: $count - Sleeping for 60secs...");

                sleep 60;

                $no_powered_on_vms = 0;

            }

            $count += 1;

        }

        &log("info","Verification stage completed!\n");

 

        &log("info","Putting hosts into \"$host_operation mode\"");

        die("Host of $vma_name not known!\n") if (!defined $vma_host_name);

        foreach my $hostname (keys %validhosts) {

            if ($hostname ne $vma_host_name) {

                $host_login=VmaTargetLib::query_target($hostname);

                $host_login->login();

                my $host_view=Vim::find_entity_view(view_type => 'HostSystem');

                &shutdownOrStandbyHost($hostname,$host_view);

                Util::disconnect();

            }

        }

 

        &log("info","Finally putting UPS Monitoring VM host into \"$host_operation mode\"");

 

        if($sendmail) {

            &log("info","Emailing results before taking down $vma_host_name");

            &sendMail();

        }

 

        $vma_login=VmaTargetLib::query_target($vma_host_name);

        $vma_login->login();

        my $host_view = Vim::find_entity_view(view_type => 'HostSystem');

        &shutdownOrStandbyHost($vma_host_name,$host_view);

        Util::disconnect();

}

}

 

sub shutdownOrStandbyHost {

    my ($hostname,$host_view) = @_;

 

    if($host_operation eq 'standby' && $host_view->capability->standbySupported eq 'true') {

        if($host_operation ne 'dryrun' && $host_operation ne 'autoquery') {

            eval {

                $host_view->PowerDownHostToStandBy_Task(timeoutSec => 300) };

                if($@) {

                    &log("info","ERROR: $@")

                }

            }

        &log("info","$hostname is going into standby mode!");

    } else {

        if($host_operation ne 'dryrun' && $host_operation ne 'autoquery') {

            eval {

                $host_view->ShutdownHost(force => 1);

            };

            if($@) {

                &log("info","ERROR: $@")

            }

        }

        &log("info","$hostname is now shutting down!");

    }

}

 

sub getHostsAndVms {

    foreach my $host (@hosts) {

        my $hostname = $host->name();

        if (! grep( /^$hostname/,@exclude_hosts ) ) {

            &log("info","Found host: \"". $hostname . "\"");

            &log("debug", "Main: Login by vi-fastpass to: " . $hostname);

 

            my $host_type;

            eval {

                $host->login();

                #validate ESX/ESXi host

                my $content = Vim::get_service_content();

                $host_type = $content->about->apiType;

            };

            if($@) {

                &log("info","Error: Unable to login to host: \"" . $hostname . "\"! Ensure host is being managed by vMA!\n");

            } else {

                if($host_type eq 'HostAgent') {

                    $validhosts{$hostname} = "yes";

                    my $host_view = Vim::find_entity_view(view_type => 'HostSystem');

                    if($host_operation eq 'autoquery') {

                        &autoquery($host_view);

                    } else {

                        my $vms=Vim::get_views(mo_ref_array => $host_view->vm);

                        &log("info","Begin $vm_operation operation on VMs ...");

                        if($vm_operation eq 'auto') {

                            &autoShutdownVMs($host_view);

                        } else {

                            &shutdownVMs($vms);

                        }

                        &log("info","$vm_operation operation complete!");

                    }

                } else {

                    &log("info","Host: \"" . $hostname . "\" is not an ESX(i) host and will be ignored");

                }

                &log("debug", "Main: Disconnect from: ". $hostname . "\n");

                Util::disconnect();

            }

        }

    }

 

    if($host_operation eq 'autoquery' && $vm_operation eq 'auto') {

        &log("info","RECOMMENDED_TIMEOUT_VALUE = > " . ceil(($recommended_timeout/60)) . " minutes\n");

    }

}

 

sub autoquery {

    my ($host) = @_;

 

    if($vm_operation eq 'auto') {

        my $autoStartMgr = Vim::get_view(mo_ref => $host->configManager->autoStartManager);

 

        &log("info","AUTOSTART MANAGER INFO");

        &log("info","--------------------------------------");

        &log("info","AUTOSTART_ENABLED = " . ($autoStartMgr->config->defaults->enabled ? "YES" : "NO"));

        &log("info","DEFAULT_STOP_ACTION = " . $autoStartMgr->config->defaults->stopAction);

        my $default_delay = $autoStartMgr->config->defaults->stopDelay;

        &log("info","DEFAULT_STOP_DELAY = " . ceil(($default_delay/60)) . " minute");

 

        my $totalTimeInSecs = 0;

        my $powerInfo = $autoStartMgr->config->powerInfo;

 

        if($powerInfo) {

            foreach( sort {$a->startOrder cmp $b->startOrder} @$powerInfo) {

                my $sd = $_->stopDelay;

                my $vmname = Vim::get_view(mo_ref => $_->key, properties => ['name']);

                my $order = $_->startOrder;

                if($sd eq -1) {

                    $sd = $default_delay;

                }

                &log("info","VM=".$vmname->{'name'}."\tORDER=".$order."\tDELAY=".ceil(($sd/60))." minute");

                $totalTimeInSecs = $totalTimeInSecs + $sd;

            }

            &log("info","TOTAL_STOP_DELAY = " . ceil(($totalTimeInSecs/60)) . " minute");

            &log("info","--------------------------------------");

        }

 

        $recommended_timeout = $recommended_timeout + $totalTimeInSecs;

    }

}

 

sub autoShutdownVMs {

    my ($host) = @_;

 

    my $autoStartMgr = Vim::get_view(mo_ref => $host->configManager->autoStartManager);

 

    my $vms = Vim::get_views(mo_ref_array => $host->vm);

    foreach my $vm (@$vms) {

        if($vm->name eq $vma_name) {

            &log("debug","Found UPS Monitoring VM: " . $vm->name);

       my $vma_host_view = Vim::get_view(mo_ref => $vm->runtime->host);

            $vma_host_name = $vma_host_view->name;

        }

    }

 

    if($autoStartMgr->config->defaults->enabled) {

   &log("info","Issuing AutoStartPowerOff() ...");

        if($host_operation ne 'dryrun' && $host_operation ne 'autoquery') {

            $autoStartMgr->AutoStartPowerOff();

   } else {

            my $powerInfo = $autoStartMgr->config->powerInfo;

            foreach( sort {$a->startOrder cmp $b->startOrder} @$powerInfo) {

                my $vmname = Vim::get_view(mo_ref => $_->key, properties => ['name']);

                my $action;

                if($_->stopAction eq 'SystemDefault') {

                    $action = $autoStartMgr->config->defaults->stopAction;

                } else {

                    $action = $_->stopAction;

                }

                &log("info","Performing " . $action . " operation on " . $vmname->{'name'});

            }

        }

    } else {

        &log("info","Auto start/stop manager is not enabled, VMs will not be powering down!");

    }

}

 

sub shutdownVMs {

    my ($vms) = @_;

    foreach my $vm (@$vms) {

        my $vmname = $vm->name;

        if($vmname ne $vma_name) {

            if($vm->runtime->powerState->val eq 'poweredOn') {

                if($vm_operation eq 'suspend') {

                    eval {

                        &log("info","Suspending $vmname ...");

                        if($host_operation ne 'dryrun' && $host_operation ne 'autoquery') {

                            $vm->SuspendVM();

                        }

                    };

                    if($@) {

                        &log("info","Unable to suspend $vmname!");

                    }

                } else {

                    if(defined($vm->guest) && ($vm->guest->toolsStatus->val eq 'toolsOld' || $vm->guest->toolsStatus->val eq 'toolsOk') ) {

                        eval {

                            &log("info","Shutting down $vmname via VMware Tools...");

                            if($host_operation ne 'dryrun' && $host_operation ne 'autoquery') {

                                $vm->ShutdownGuest();

                            }

                        };

                        if($@) {

                            &log("info","Unable to shutdown $vmname!");

                        }

                    } else {

                        eval {

                            &log("info","Hard Powering off $vmname, no VMware Tools found ...");

                            if($host_operation ne 'dryrun' && $host_operation ne 'autoquery') {

                                $vm->PowerOffVM();

                            }

                        };

                        if($@) {

                            &log("info","Unable to hard power off $vmname!");

                        }

                    }

                }

            }

        } else {

            &log("info","Found UPS Monitoring VM: $vmname");

            my $vma_host_view = Vim::get_view(mo_ref => $vm->runtime->host);

            $vma_host_name = $vma_host_view->name;

        }

    }

}

 

sub summaryStart {

    if($host_operation eq 'dryrun' || $host_operation eq 'autoquery') {

        &log("info","=============== DRYRUN MODE ENABLED ===============");

    } else {

        &log("info","======== STARTING ghettoHostShutdown41.pl ========");

    }

 

    #log vma name

    &log("info","VMA_NAME: $vma_name");

 

    #vm operation

    &log("info","VM_OPERATION: $vm_operation");

 

    #host operation

    &log("info","HOST_OPERATION: $host_operation");

 

    #host selection

    if($hostfile) {

        &log("info","HOST_LIST: MANUAL");

    } else {

        &log("info","HOST_LIST: AUTOMATIC");

    }

    &log("info","===================================================\n");

 

sub summaryEnd {

    &log("info","");

    if($host_operation eq 'dryrun' || $host_operation eq 'autoquery') {

        &log("info","============== DRYRUN MODE COMPLETED ==============\n");

    } else {

        &log("info","======= COMPLETED ghettoHostShutdown41.pl ========\n");

    }

}

 

sub timeStamp {

    my ($date_format) = @_;

    my %dttime = ();

    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

    my $my_time;

    my $time_string;

 

    ### begin_: initialize DateTime number formats

    $dttime{year } = sprintf "%04d",($year + 1900); ## 4 digits to specify year

    $dttime{mon  } = sprintf "%02d",($mon + 1);     ## 0pad months

    $dttime{mday } = sprintf "%02d",$mday;          ## 0pad day of the month

    $dttime{wday } = sprintf "%02d",$wday + 1;      ## 0pad day of week; sunday=1;

    $dttime{yday } = sprintf "%02d",$yday;          ## 0pad nth day of year

    $dttime{hour } = sprintf "%02d",$hour;          ## 0pad hour

    $dttime{min  } = sprintf "%02d",$min;           ## 0pad minutes

    $dttime{sec  } = sprintf "%02d",$sec;           ## 0pad seconds

    $dttime{isdst} = $isdst;

 

    if($date_format eq 'MDYHMS') {

        $my_time = "$dttime{mon}-$dttime{mday}-$dttime{year} $dttime{hour}:$dttime{min}:$dttime{sec}";

        $time_string = $my_time." -- ";

    } elsif ($date_format eq 'YMD') {

        $my_time = "$dttime{year}-$dttime{mon}-$dttime{mday}";

        $time_string = $my_time;

    }

 

    return $time_string;

}

 

# Subroutine to process the input file

sub processFile {

    my ($vmlist) =  @_;

    my $HANDLE;

    open (HANDLE, $vmlist) or die(timeStamp('MDYHMS'), "ERROR: Can not locate \"$vmlist\" input file!\n");

    my @lines = ;

    my @errorArray;

    my $line_no = 0;

 

    close(HANDLE);

    foreach my $line (@lines) {

        $line_no++;

        &trim($line);

 

        if($line) {

            if($line =~ /^\s*:|:\s*$/){

                print "Error in Parsing File at line: $line_no\n";

                print "Continuing to the next line\n";

                next;

            }

            my $hostname = $line;

            &trim($hostname);

            my $host;

            eval {

                $host = VmaTargetLib::query_target($hostname);

            };

            if($@) {

                &log("info","Error: Unable to login to host: \"" . $hostname . "\"! Ensure host is being managed by vMA!\n");

            } else {

                push @hosts,$host;

            }

        }

    }

}

 

# ask

#-1 - freeform

# 0 - question type, 0,1 are y/n, 2+ is multiple choice

# 1 - numeric response

# 2 - question or choice description

# 3+ - options if multiple choice

# if a value is specified, it is returned if just ENTER is pressed.

sub ask {

    my $ans;

    my $qtype = $_[0];

    my $val   = $_[1];

    my $quest = $_[2];

    if ($qtype == -1) {                      # Freeform

        do {

            print "    $quest ";

            print "[$val] " if ($val);

            $ans = ;

            chomp $ans;

        } while (!$ans && !$val);

        $val = lc($ans) if $ans;

    }

    elsif ($qtype == 0) {                    # YES/NO

        do {

            print "    $quest [" . ($val)?"y":"n" . "]? ";

            $ans = ;

            chomp $ans;

        } while ($ans && !($ans =~ /^[YN]/i));

        $val = ($ans =~ /^Y/i)?1:0;

    }

    elsif ($qtype == 1) {                    # Any number

        do {

            print "    $quest [$val] ";

            $ans = ;

            chomp $ans;

        } while ($ans && !($ans =~ /^\d+$/));

        $val = $ans if $ans;

    }

    else {                                   # Options

        do {

            print "    $quest\n";

            for (my $i = 0, my $arg = 3; $i < $qtype; $i++, $arg++) {

                print "        $i - $_[$arg]\n";

            }

            print "    Choose [$val] ";

            $ans = ;

            chomp $ans;

        } while ($ans && (($ans < 0) || ($ans >= $qtype)));

        $val = $ans if $ans;

    }

    return $val;

}

 

# Perl trim function to remove whitespace from the start and end of the string

sub trim($)

{

    my $string = shift;

    $string =~ s/^\s+|\s+$//g;

    return $string;

}

# Left trim function to remove leading whitespace

sub ltrim($)

{

    my $string = shift;

    $string =~ s/^\s+//;

    return $string;

}

# Right trim function to remove trailing whitespace

sub rtrim($)

{

    my $string = shift;

    $string =~ s/\s+$//;

    return $string;

}

 

# Print message to log output with time stamp if appropriate to log level

sub log {

    my($logLevel, $message) = @_;

 

    open(MYLOG,">>$log_output") || die("Cannot open $log_output: $?");

    if ($LOGLEVEL <= $log_level{$logLevel}) {

        print MYLOG timeStamp('MDYHMS'), $logLevel, ": ", $message, "\n";

    }

    close(MYLOG);

}

 

__END__

 

=head1 NAME

 

ghettoHostShutdown41.pl - Shutdown VMware hosts and guests

 

=head1 SYNOPSIS

 

ghettoHostShutdown41 [--host_operation shutdown/standby/autoquery/B ] [--vm_operation B /shutdown/auto] [--logoutput file] [--loglevel info/B ] [--vma_name display_name] [--hostfile file] [--sendmail] --timeout mins

 

=head1 OPTIONS

 

=over 8

 

=item B<--host_operation>

 

Host Operation to perform [shutdown/standby/autoquery/dryrun]. The default is

"dryrun".

 

=item B<--vm_operation>

 

VM Operation to perform [suspend/shutdown/auto]. The default is "suspend".

 

=item B<--logoutput>

 

Send the output of this script to the specified file. The default is to output

to STDOUT.

 

=item B<--loglevel>

 

Log level [info/debug]. The default is "debug".

 

=item B<--vma_name>

 

Display name of the vMA VM running this shutdown script. The default is the

unqualified hostname of this server, that is the name of this server without

the domain name.

 

=item B<--hostfile>

 

Manual list of the ESX(i) hosts in which to prioritize the shutdown process.

 

=item B<--sendmail>

 

If specified, the log file will be emailed. If no log file is specified, a

temporary file will be created.

 

=item B<--timeout>

 

Timeout value before shutting down all hosts (in mintues). This is a required

field.

 

=back

 

=head1 DESCRIPTION

 

This script is an update to B which worked with ESX(i)

3.5 and 4.0 hosts. The script is updated to support the recent library changes

in vMA 4.1. It may work with earlier version, but they have not been tested.

 

Defaults have been chosen for all of the previously required options, except the

B option. That option remains required. The B option is

defaulted to "B " to avoid accidental shutdowns. The B

option uses the recommended "B " for quicker shutdowns. The B

was changed to B to emphasize that it is the display name of the vMA

server. The short hostname of this server is used as its default. Although not

originally required, B was changed to default to STDOUT. The

B option was changed to a boolean and if it is specified without a

permanent B file, a temporary one will be created.

 

Besides these default changes, all of the previous robust capablities and

features are available when shutting down your VMware environment in a 

time-critical situation, such as a power failure.

 

Users have the option of specifying various shutdown operations for both the

hosts ( shutdown/standby ) and VMs ( shutdown/suspend ) which also includes

an option to utilize the auto startup/shutdown manager to prioritize the

shutdown order of each VM on a given host. In addition, users can also specify a

hostlist which will allow them to define the order in which hosts will initiate

the power down sequence. 

 

A "dryrun" mode is available to ensure you've configured your shutdown process

correctly without actually shutting down your systems. Hosts and VMs are

processed asynchronously, blocking based on a configurable timeout value. A

report of this script's activities can also be emailed.

 

This script can be invoked by any UPS monitoring utility that runs on vMA such

as the open source B and the script will automatically figure out which

host the vMA VM is running on and ensure that all VMs are down prior to taking

down the final host which runs the vMA VM. Though not recommended, this script

could also be invoked from another VM or physical server, provided the vMA VM is

properly configured.

 

B Please follow the documentation and best practices from your UPS

vendor. You will need to invoke this script as part of the UPS execution

process to ensure your VMware environment will be shutdown.

 

=head1 REQUIREMENTS

 

=over 8

 

=item * ESX/ESXi hosts being managed by vMA 4.1

 

=over 8 

 

=item Supports ESXi 3.5, 4.0 and 4.1 (licensed version only)

 

=item Supports ESX 3.5, 4.0 and 4.1

 

=back 8

 

=item * VMware vMA 4.1

 

=back

 

=head1 FILES

 

=over 24

 

=item

 

Manual list of the ESX(i) hosts in which to prioritize the shutdown process.

 

=item /tmp/ghettoHostShutdown41-nnnn.log

 

Temporary log output of this script used for email if no permanent log file is

specified.

 

=back

 

=head1 SEE ALSO

 

VmaTargetLib

 

=head1 AUTHOR

 

William Lam, created 01/09/2010

http://communities.vmware.com/docs/DOC-11902

http://www.engineering.ucsb.edu/~duonglt/vmware/

 

Paul Knight, refitted for ESX(i) 4.1 10/20/2010

paul.knight@state.de.us

 

=head1 TODO

 

=over 8

 

=item - Combine management and filtering of host list into one function.

 

=item - Update bug list.

 

=back

 

=head1 BUGS

 

None known at this time.

 

=cut

13 Posts

November 11th, 2010 09:00

Thank you.  That was not in the instructions.

How do you get x-windows to work in VMA 4.1 please?

13 Posts

November 11th, 2010 09:00

All I could find was written in November 2009.  Do you have a link?  Also, if I still need x-windows, how do I get it to start.  Have been looking for instructions to no avail.  Also, thank you very much.  I know this has been an issue for others as well.

44 Posts

November 11th, 2010 09:00

Rename the following to: "shutdownESXi41.sh"

 

perl ghettoHostShutdown41.pl --host_operation shutdown --vm_operation shutdown --timeout 2 --vma_name vMA

44 Posts

November 11th, 2010 09:00

Here are the installation instructions.  Please remember this is BETA!!!  Unfortunately it didn't copy/paste very well.

 

Prerequisites

VMware ESXi server machine

VIMA 1.0 or vMA 4.0 installed as guest

VMware Infrastructure client installed on a different machine for VMware ESXi Server

configuration

Secure Copy Protocol (SCP) client like WinSCP to upload packages to the VMware ESXi server

Dell UPS Management Software installed on the vMA

VMware ESXi should be pay version only

Dell UPS Management Software Installation

To install the software:

1 Start the vMA 4.1 guest operating system.

2 Download the software from the Dell Web site (support.dell.com) or from the CD (F618R A04 or higher) provided with the UPS.

3 Upload the software from Windows to vMA 4.1 using WinSCP tools.

4 Copy the Linux and InstallerData files from the CD to vMA.

5 Enter the following commands to access the Linux and InstallerData files:

sudo chmod -R 777 Linux

sudo chmod -R 777 InstallerData

6 Enter the Linux path and then enter the following command to install the software:

cd Linux

sudo ./setup_console.bin

7 Edit the shutdown script “shutdownESXi41.sh”. Modify the parameters value of timeout and vma_name.

One required variable is timeout which is in minutes that specifies how long the system will wait for all VMs to shutdown before initiating the host shutdown operation. Each guest operating system requires a minimum of 30 seconds to shutdown.

Note: if you are not sure the accurate time, you can use --host_operation autoquery in conjunction with --vm_operation auto to view what is the current amount of time that's been configured and help you select a timeout value.

For Example:

perl ghettoHostShutdown41.pl --host_operation autoquery --vm_operation auto --timeout 2 --vma_name vMA

After running the script of “shutdownESXi41.sh”, The required timeout will be list as blow:

07-29-2010 19:00:02 -- info: RECOMMENDED_TIMEOUT_VALUE = > 2 minutes.

 

Another required variable is --vma_name which is the name of VMA.

For Example:

The parameter value of vma_name is VMA4.1 as blow tree structure:

 

The other variables are list as following table:

Host:

Parameter Description

shutdown Shutdown the host after all VMs have powered off or after timeout value

standby Put host into stanby mode if supported and BMC/IPMI is configured, else operation defaults to shutdown

dryrun Will provide detail log output of execution without performing any actions to host or VMs

autoquery Provides summary of the current configured auto startup/power down priority list if configured. This mode also aides in user selecting an appropriate timeout value to set

 

VM:

Parameter Description

shutdown Shutdown the guest if VMware Tools is running, else it's a hard power off

suspend Suspends the guest ( Recommended action, quicker than shutdown )

auto Use the configured auto power down configuration

 

8 Start the Agent. From the installation path, enter the command:

sudo ./agent start

 

 

Shutdown Parameter Setting for Network Management Card

The following procedure is an example of entering the settings through the network management card for a graceful shutdown of selected devices.

NOTE: See Table 4 on page 133 for a complete list of Dell Command User Interface (CUI) commands.

1 Go to the installation path.

2 Enter ./CuiManager to start the CuiManager (see Figure 123).

3 Search for a single device by entering search4 and the device network IP address, or search for multiple devices within a range.

For example:

search4 –ip 172.18.127.1 –ip 172.18.127.254 –c public

All devices in the network IP address from 172.18.127.1 to 172.18.127.254 are added.

4 Enter the shutdown commands (see Figure 124).

Example:

shutsys -ip 172.18.127.47 -e true

shutbackup -ip 172.18.127.47 -e true -m 1:00

shutfile -e true -f /opt/ups/shutdownESXi41.sh -m 2

listshut -ip 172.18.127.47

NOTE: See ”Dell CUI Commands” on page 133 for a description of all Dell CUI commands.

NOTE: The timer of -m option in the shutfile command should be in conjunction with the timeout value in the shutdownESXi41.sh

44 Posts

November 11th, 2010 09:00

Just a thought, are you using the beta script to support 4.1 or a previous (standard) version of the Dell UPS s/w?  The latest version on support.dell.com (A05) supports up to and including 4.0  In 4.1 they changed the scripting a little so there is a beta script you would need and this comes with additional installation instructions.

44 Posts

November 11th, 2010 09:00

Hi Michael,

Here's the link, let me know how you get on:

http://support.us.dell.com/support/downloads/download.aspx?c=us&l=en&s=gen&releaseid=R276438&formatcnt=0&libid=0&typeid=-1&dateid=-1&formatid=-1&source=-1&fileid=408115

Andy

44 Posts

November 11th, 2010 09:00

Hiya, the best way to get the latest s/w and f/w upgrades is to go to www.dellups.com and then the download link.  This links you directly to the content on support.dell.com but in a way that you can find the info easily.  Download the A05 CD and use this as a base.  I will post up some more information in a following post with the script information and instructions.  Unfortunately I can't find a way to post attachments here...

13 Posts

November 11th, 2010 09:00

Unable to find the A05 CD file.  I am constantly restricted by a previously entered tag.  Attempted searches as well.  Can you find the link for me please?  Additionally, I could bring the BETA version to live within a few days if I had a resource for questions.  Then you wouldn't have to worry about what level of experience someone has to make this work.  I would help make a "For Dummies" installation instructions.  I am available immediately.  This would cut a lot of calls to VMware and Dell.  I have already spend almost two weeks on this project.  Please provide link and give me your opinion about a joint venture.

Best Regards,

Michael

November 12th, 2010 10:00

I was having this problem myself and think I finally got to the bottom of it.  From another forum I posted this on:

"I think I found the solution.  Although I am not a programmer by trade, I hacked the Perl script a bit to see what was going on.  When the suspend was attempted, an error would be logged if $@ was true.  $@ appears to be a return code, so I added it to the log line and out popped the real cause of my problem:

SOAP Fault:

----------

Fault string: fault.RestrictedVersion.summary

Fault detail: RestrictedVersionFault

From what I've already read, this is the error you get when using the free version of ESXi 4.1.  The rub here is that I'm running a licensed copy.  A few months ago we purchased the VMware Essentials pack, and I'm starting to suspect that this bundle does not have the required API support, but I don't have confirmation that this is an actual VMware policy."

159 Posts

November 12th, 2010 11:00

KOMNetworks, does it work fine for you now after th small changes you did for it?

November 12th, 2010 11:00

No, it doesn't.  IN fact, the situation has gotten stranger.  The only edit I made was to display the return code for the SuspendVM() function.  When I saw that it was failing the function with a RestrictedVersion error, I thought that my license (VMware Essentials) did not provide API access and that was why the script was failing to suspend or shutdown.  However, I just got off the phone with VMware and they claim the VMware Essentials bundle DOES include API access so it should work fine.  Meanwhile, I'm sitting here with a licensed copy of ESXi and a RestrictedVersion error.

13 Posts

November 15th, 2010 13:00

So far your help has been great.

Is the apcupsd supposed to be downloaded to the VMA virtual system or the ESX host?

Do I need to download USB drivers if on the VMA?  I cannot find any on the Dell site so that it will be compatible with a T610.  Every command I try and run ie dmesg does not show that it can see the UPS through the USB or any USB.

Thanks, Michael

No Events found!

Top