Tuesday, August 26, 2014

Using PrimType in the vSphere Perl SDK

One of the issues that can arise with the vSphere Perl SDK is the serialization of various numeric types as strings.  For example, when trying to remove a DRS rule from a ClusterComputeResource the following error will manifest: SOAP fault: A specified parameter was not correct.  Internally, the vSphere Perl SDK is setting the removeKey property type to xsd:string and the vSphere Web Service is unable to coerce the string into the expected xsd:int type.

However, a base type called PrimType is available to set the proper SOAP XSD data type when serializing the data objects for the vSphere Web Service.

Sunday, December 1, 2013

Rename ESXi Hosts in vCenter (Without Losing Historical Data)

Changing the display name of an ESXi host in vCenter is typically done by removing and then adding the host back into the vCenter inventory.  While this doesn't impact running virtual machines, the ESXi host's task, event and performance history is lost.  Also, the host managed object reference is modified and all custom values are cleared, which could impact 3rd party tools which track inventory objects externally.

There is, however, a way to rename the ESXi host in vCenter while retaining all of its historical data through the ReconnectHost_Task API method.

Sunday, December 2, 2012

Querying vCenter Linked Mode with the vSphere API

One question I'm asked now and then is how to retrieve the list of Linked Mode vCenter Servers from the vSphere API.  Unfortunately, the Linked Mode configuration is not provided through the published vSphere SDK.

VMware products that are aware of Linked Mode, such as the vSphere Client, use an undocumented API method called QueryServiceEndpointList.  We can leverage the same API method to discover Linked Mode vCenter server instances for use in custom automation tools.

Wednesday, November 21, 2012

Best Practices for Faster vSphere SDK Scripts

The VMware vSphere API is one of the more powerful vendor SDKs available in the Virtualization Ecosystem.  As adoption of VMware vSphere has grown over the years, so has the size of Virtual Infrastructure environments.  In many larger enterprises, the increasing number of VirtualMachines and HostSystems is driving the architectural requirement to deploy multiple vCenter Servers.

In response, the necessity for automation tooling has grown just as quickly.  Automation to create daily reports, perform bulk operations, and aggregate data from large, distributed Virtual Infrastructure environments is a common requirement for managing the increasing virtual sprawl.

In a Virtual Infrastructure comprised of thousands of objects, even a simple script to list all VirtualMachines and their associated HostSystem and Datastores can result in very slow runtime execution.  Developing automation with the following, simple best practices can take orders of magnitude off your vSphere API tool's runtime.

Thursday, November 8, 2012

Automate Adding ESXi Hosts to vCenter With SSL Thumbprint

Recently, I was asked how to automate adding ESXi hosts to vCenter with a custom Perl script.  For security purposes, vSphere vCenter requires SSL verification of the ESXi SSL certificate thumbprint.  The automation challenge is generating the SHA1 digest for the ESXi host certificate, so it can then be passed as a parameter to AddHost_Task() method.

There are two solutions for getting the SSL thumbprint before adding an ESXi host to vCenter's inventory.