Download VMware Perl API

Transcript
Using Sample Perl Scripts
Sample Perl Scripts
This section contains sample Perl scripts written and tested by VMware. You can download them
from the VMware ESX Server Web site. The links are listed with each script below.
The sample scripts illustrate:
•
Listing the Virtual Machines on VMware ESX Server
•
Checking a Virtual Machine’s Power Status
•
Starting, Stopping and Suspending a Virtual Machine
•
Monitoring a Virtual Machine’s Heartbeat
•
Answering Questions Posed by a Virtual Machine
•
Monitoring a Virtual Machine’s Usage of the Host CPU
•
Suspending a Virtual Machine
•
Setting a Virtual Machine’s IP Address
•
Adding a Redo Log to a Virtual Disk
•
Committing a Redo Log to a Virtual Disk without Freezing the Virtual Machine
•
Committing the Topmost Redo Log
Feel free to download and use these scripts as they are, or modify them to suit the needs of your
organization. Please be aware that the scripts on the VMware Web site are saved with a .TXT
extension for online viewing. If you download them for use, please remove the .TXT extension.
Note: If you plan on using the VMware Perl API remotely on a Windows machine, you must copy your
scripts into the same directory in which you installed the VMware Perl API.
Listing the Virtual Machines on VMware ESX Server
You can use a script like the following to generate a list of all the registered virtual machines on
VMware ESX Server. You need to know the name of the host machine and you must provide a valid
user name and password to connect to the server.
This script (enumerate.pl) can be found on the VMware Web site at
www.vmware.com/support/developer/perl-API/doc/enumerate.pl.txt.
#!/usr/bin/perl -w
#
# Copyright (C) 1999-2002 VMware, Inc.
# All Rights Reserved
#
34
www.vmware.com