WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple

Automating Storage DRS & Datastore Cluster Management in vSphere 5

07.27.2011 by William Lam // 1 Comment

Storage DRS is probably one of, if not the coolest feature in vSphere 5. Storage DRS allows you to cluster your datastores into what is known as a datastore cluster (storage pod) and automatically balances both your storage I/O and capacity just like DRS does with your compute. The user interface is extremely easy to use but as always, if you need to click through several screens to get to the outcome, some automation can never hurt 🙂

I decided to create a vSphere SDK for Perl script called datastoreClusterManagement.pl which allows you to automate all aspects of creating and managing your storage pod/cluster. You will need a system that has the vCLI installed or you can use VMware vMA 5 to run the script. You will also need to connect to a vCenter Server 5 for all SDRS operations.

The script supports 8 different types of operations and are describe below:

Operation Description
List List all available datastore clusters
Query  Query details for a specific datastore cluster
Create  Create a datastore cluster
Delete  Delete a datastore cluster (Datastores are left intact)
Add Datastore  Add datastore(s) to an existing datastore cluster
Remove Datastore  Remove datastore(s) from an existing datastore cluster
Enter Maintenance Mode  Put a datastore into maintenance mode
Exit Maintenance Mode  Take a datastore out of maintenance mode
Here is an example of performing the "list" operation: 

./datastoreClusterManagement.pl --server vcenter50-1 --username root --operation list

Here is an example of performing the "query" operation:

./datastoreClusterManagement.pl --server vcenter50-1 --username root --operation query --pod homer-NFS-pod

Here is an example of performing the "create" operation w/single datastore:

./datastoreClusterManagement.pl --server vcenter50-1 --username root --operation create --datacenter MN-physical --enable_sdrs true --enable_sdrs_iometric true --pod moe-NFS-pod --sdrs_automation automated --sdrs_evaluate_period 480 --sdrs_imbal_thres 30 --sdrs_latency 15 --sdrs_util_diff 20 --sdrs_util_space 60 --datastore himalaya-NFS-moe-primp-1

Here is an example of performing the "create" operation w/datastore file:

./datastoreClusterManagement.pl --server vcenter50-1 --username root --operation create --datacenter MN-physical --enable_sdrs true --enable_sdrs_iometric true --pod moe-NFS-pod --sdrs_automation automated --sdrs_evaluate_period 480 --sdrs_imbal_thres 30 --sdrs_latency 15 --sdrs_util_diff 20 --sdrs_util_space 60 --datastore_file dsfile

Here is an example of performing the "delete" operation:

./datastoreClusterManagement.pl --server vcenter50-1 --username root --operation delete --pod moe-NFS-pod

Here is an example of performing the "add_datastore" operation:

./datastoreClusterManagement.pl --server vcenter50-1 --username root --operation add_datastore --pod moe-NFS-pod --datastore himalaya-NFS-moe-primp-2

Here is an example of performing the "remove_datastore" operation:

./datastoreClusterManagement.pl --server vcenter50-1 --username root --operation remove_datastore --pod moe-NFS-pod --datastore himalaya-NFS-moe-primp-1

Note: Both "add_datastore" and "remove_datastore" operation support single datastore and/or datastore file

Here is an example of performing the "ent_maint" operation:

./datastoreClusterManagement.pl --server vcenter50-1 --username root --operation ent_maint --pod homer-NFS-pod --datastore himalaya-NFS-moe-primp-5

Here is an example of performing the "ext_maint" operation:

./datastoreClusterManagement.pl --server vcenter50-1 --username root --operation exi_maint --pod homer-NFS-pod --datastore himalaya-NFS-moe-primp-5

There is also complete perl docs for this script which can be called using the following command:

perldoc datastoreClusterManagement.pl

Categories // Automation, vSphere Tags // ESXi 5.0, SDRS, storage drs, storagePod, vSphere 5.0

How to extract host information from within a VM?

01.15.2011 by William Lam // 34 Comments

From time to time, I see this question come up asking how one might be able to extract a certain piece of information from either ESX(i) or the management APIs (vSphere API) from within a virtual machine. The simple answer is you can not, by default the guest operating system has no idea of the underlying hypervisor nor does it have the access to the management APIs. This of course, assumes you are following VMware's best practices in isolated and segregating off your management network from your virtual machine network.

Having said that, there are certain bits of information that you can extract about your ESX(i) host from within the guestOS using some of the utilities that is installed with VMware Tools. The first utility is called VMware Toolbox command which can be found on both UNIX/Linux and Windows systems that have tools installed.

[Read more...]

Categories // Automation, OVFTool, vSphere Tags // guestinfo, vmtoolsd, vmware tools, vmware-cmd

How to control maximum number of VMware snapshots

10.31.2010 by William Lam // 21 Comments

There are currently no methods of controlling the number of VMware snapshots using vCenter or ESX(i) permissions today, you either provide the snapshot privilege or you deny it all together. I recently discovered an undocumented .vmx entry that allows you to control the maximum number of VMware snapshots for a given virtual machine. By default, a virtual machine can have a snapshot tree depth of 31, in the worse case scenario supporting up to a maximum of 496 snapshots.

Here is what a VM looks like with 496 snapshots (unexpanded):

 

Note: If you are interested in what this looks like fully expanded, take a look at the screenshot at the very bottom of this post.

If you like to prevent the above or at least control the maximum number of snapshots for a given virtual machine, you can add the following into a VM's .vmx configuration file. Ideally, this is deployed using vSphere API as there is no need to directly edit the VMX's file and this can also be applied to a live running VM (another benefit of using the vSphere API).

Here is an example using PowerCLI:

$vm = Get-VM -Name TestVM
New-AdvancedSetting -Name snapshot.maxSnapshots -Value 1 -Entity $vm

For those that prefer using another vSphere SDK, you just need to use the ReconfigVM_Task() to add the VM Advanced Setting. Please take a look at this sample for here for how to add/update VM Advanced Settings.

snapshot.maxSnapshots = "n"

where n = max number of snapshots and n <= 496

Here is a screenshot of adding this .vmx parameter using the vSphere Client:

The virtual machine above already has one snapshot and per the configuration change, we should not be able to take any additional snapshots:

Next, we will try to take a second snapshot:

As you can see, an error is thrown that we have reached the maximum number of permitted snapshots. If you would like to disable snapshots all together, you can set the value to be 0 and this will prevent anyone from taking snapshots, including administrators.

Here is a an screenshot of the expanded view of a VM with 496 snapshots:

Note: These snapshots were created with a VM running in an vESXi host and script to exhaust the maximum snapshot depth of 31. Each snapshot level was also exhausted with the maximum number of snapshots. Starting from level-1: it was the maximum depth minus 1, level-2: it was maximum depth minus 2, and so fourth. This was just a test to see what the system could handle, you should not try this a home or on a production VM 😉 Use at your own risk

Categories // Automation, vSphere Tags // snapshot

  • « Previous Page
  • 1
  • …
  • 106
  • 107
  • 108
  • 109
  • Next Page »

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025
  • vCenter Server Identity Federation with Kanidm 04/10/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025