With the VI Toolkit (for Windows) we try to make easy-to-use cmdlets that any administrator with PowerShell knowledge can pick up and start managing and automating VMware almost right away. All of this takes time to develop, of course. But one of the nicest features of the toolkit is that you have complete access to the extremely powerful (if sometimes baffling) set of web service APIs, which means that you don’t have to wait for us to develop easy-to-use cmdlets in order to automate the things that matter most to you.
One request I’ve been hearing a lot lately is that people would like to automate configuration of storage paths. This tends to be most useful if you have lots of ESX hosts and lots of big expensive arrays to hold their VMs, but one aspect of storage path configuration can be very useful even if you don’t have a huge deployment. Hopefully this post will give you a few ideas of what’s possible.
Configuring storage paths through the web services in PowerShell turns out to be pretty easy, but before we talk about that I want to show how you do it in the VI Client. The first thing to do in the VI Client is navigate to a host and select the Configuration tab, then select the storage section.
Once you’ve done that, select a datastore and click Properties… This brings up a window like this one:
Now we click Manage Paths… to actually configure the paths.
Within this interface we can configure individual paths or set the path policy.
Now let’s see how to do the same thing in PowerShell. First, let’s log in.
With native cmdlets it’s easy to manage more than one host at a time, because it’s usually completely transparent. With the web services interfaces, it’s generally best to deal with one host at a time. In the next window I load my host in preparation for configuring it.
Next I load my host’s StorageSystem. This is the object that contains all data relevant to LUNs and paths, and allows me to change their configurations. The first thing to do is to see what LUNs are available and what paths they have. Here’s how to do it:
As in my screenshots from the VI Client, I’m going to focus on my vmhba2:1:1 LUN, which has 2 paths, vmhba2:1:1 and vmhba2:2:1. Let’s set this LUN to use the experimental round-robin policy.
Let’s make sure the call worked:
Again, these ideas are just to get you thinking about what’s possible. Configuring a single HBA in this way is not very interesting since it’s pretty easy to do it in the client. Let’s suppose you wanted to set the round-robin policy on every LUN that had multiple paths. Here’s a script to do it:
If experimental status sounds intimidating to you, it’s easy to set another policy, such as the fixed policy. This example sets my vmhba2:1:1 LUN to a fixed policy, with vmhba2:2:1 as the preferred path (refer to Step 3 above to see the list of valid paths.)
There are many, many more possibilities here. If you want to learn more about them, you basically have two choices, first you can wait until we get these sorts of things into our cmdlet set (note that this is not scheduled for our first GA release) or you can get acquainted with our HostStorageSystem interfaces and start configuring your host’s storage today.
As always, download the VI Toolkit (for Windows) to get started today.