Find VMware snapshots via SDK

Edit 2009-02-09: I’ve updated the script slightly to reflect some errors that were occurring because I suck at regex.

I wanted a quick way of showing all snapshots for the VMs in vCenter using perl, so I spent a few minutes on this script. There are a lot of scripts for creating and deleting snapshots (and a couple to show them) using powershell, but not many using perl. I’m a *nix guy, so I wasn’t really interested in including the ability to send a mail to yourself or others in the script (just create a bash wrapper and use mail/mailx with a cron job) which saved me some time.

Well, after writing this script, I discovered that VMware included this functionality in their sample script, which is included with the Perl Toolkit.

Without further rambling by me, some perl….

Read more

Unadvertized VI Perl Toolkit helper functions and options

As I’ve been getting more and more familiar with the VI Perl Toolkit over the last couple of weeks I’ve discovered that the perl modules created and provided by VMware have some options and routines that are not discussed in the programming guide. This is my attempt to document the ones that I have found useful and you may be interested in.

There are some additional helper routines that can be found in the perl modules (the files that end in .pm) provided by the Toolkit, and the VMware employee(s) who have written them have done a pretty good job of documenting them in the code. Of special note (I may add them to this post at a later date) are the HostUtil and VMUtil modules, which have routines that streamline some of the more common operations (getting host and VM views, migrating VMs, etc).

Without futher ado…

Read more

vMotion configuration from the ESX host command line and remotely using the Perl Toolkit

One of the things that I do when configuring my hosts after kickstart is setup a kernel interface and enable vMotion for that port group. This isn’t too difficult, but takes a little bit of futzing with some vmware-vim-cmd results to get the data we need.

Since I’m on the subject, I figured I may as well do the same thing using the SDK, which eliminates one more thing that the rCLI can’t do in order for me to configure a new ESX host completely.

Read more

VMware Tools Update Policy, errrrr, Updating

After hearing about the bug with ESX 3.5 Update 3 where a vMotion would cause a tools upgrade, and consequentially a VM reboot, I wanted to check and verify that my VMs would not exhibit this behavior. Apparently the bug is present when the tools update policy is set to “Update at Power On”. (Yes, I admit this bug has been known for a while, I just kept forgetting to post this script.)

There are a multitude of other scripts (including the powershell cmdlet “update-tools”) out there to kickoff a tools update task, so I wasn’t interested in that, all I wanted was to know the update policy and be able to change it.

This perl is the result of that…

Read more

vSwitch security policies

Update 2009-2-22: Yet again, I updated the script, this time just to simplify and shorten the code using the “normal” method of updating values in objects retrieved from the SDK (rather than creating a whole new object and copying values, the script now updates the object retrieved, then uses that to update).

Update 2009-01-02: I have updated the script again, this time using the standard “vihost” so that you can connect to vCenter and change a host’s switches, as opposed to just connecting to the ESX host directly. I have also started using the _default_ parameter, which means that it is no longer necessary to specify the “–vswitch” option, but rather it is the last option on the line (just like all the other VMware provided scripts).

Update 2008-12-30: I have updated the script so that it defaults to turning all options off without having to specify them. This makes it easier to use (thanks to Glenn for this idea…).

I haven’t posted in a while, but it’s not because I haven’t been busy. The bulk of my recent work has been in automating the droll configuration items for an ESX server. With the exception of hardening the COS, pretty much everything can be setup/configured remotely via the SDK or rCLI. If you can change or set something via the Virtual Infrastructure Client, then you can set it via the SDK.

I am no POSH coder (just ask Glenn…), but I do know some perl, so using the VI Perl Toolkit, I’ve been able to script most of the configuration items that I need to do for an ESX server. This post is the first in what I hope will be a line that will hopefully contain scripts on configuring most aspects of an ESX host remotely.

I set all of our vSwitches to have Promiscuous Mode, Forged Transmits and MAC changes disabled, and so far there are no port groups that override this setting, thus giving me at least a little sense of security for certain aspects of my virtual networking.

Read more