Information Technology Reference
In-Depth Information
You can do the same management tasks as before, just using the extra -h switch when execut-
ing each one. For example, you can set advanced options and kernel module options on multiple
hosts by running the following:
vi-admin@vma01:~> vifptarget -s vCenter01
vi-admin@vma01:~[vCenter01.vSphere.local]> for server in ″vSphere01 ←
vSphere02 vSphere03 vSphere04 vSphere05″; do
echo ″$server is being configured...″
> # see http://kb.vmware.com/kb/1268 f or more info on this setting
> vicfg-advcfg -h $server -s 64 Disk.SchedNumReqOutstanding
> # see http://kb.vmware.com/kb/1267 f or more info on this setting
> vicfg-module -h $server -s ql2xmaxqdepth=128 qla2xxx
> done
vi-admin@vma01:~[vCenter01.vSphere.local]> vifptarget -c
There are lots of ways this script could be improved; for example, there's no error checking to
ensure that a matching port group and VMkernel interface are actually found by the i rst com-
mand. Readers already familiar with bash scripting should i nd utilizing the vCLI and vMA
quite comfortable for automating vSphere environments. Make sure you check the vCLI con-
cepts and examples guide from VMware for more examples and instructions on how to utilize
vCLI and vMA in your environment.
Leveraging the Perl Toolkit with vSphere Management
Assistant
vMA's fastpass with vCenter and the Perl SDK are a powerful combination. With a handful of
helper scripts, you can administer a large number of hosts using the vCLI through vCenter.
Listing 14.6 is a Perl script that simply returns the hostnames in a cluster. This can be useful
for coni guring a cluster of ESXi hosts for a new datastore, a new vSwitch, or other items that
you would want to match across all members of the cluster.
Listing 14.6:
Get all hosts in a cluster by using the Perl SDK
#!/usr/bin/perl
#
# Script Name: ~/bin/getClusterHosts.pl
# Usage: getClusterHosts.pl --server vCenter.your.domain clusterName
# Result: a newline delimited list of ESXihosts in the cluster
#
use strict;
use warnings;
# include the standard VMware perl SDK modules
use VMware::VIRuntime;
# some additional helper functions
use VMware::VIExt;
 
Search WWH ::




Custom Search