Skip to main content

Posts

Unmounting VMFS Datastores using vRO

Being a diligent admin, I always unmount a datastore from an ESXi server prior to completely deleting it.  It's a good way to verify the datastore isn't being used before the storage admin removes the ESXi server's visibility to the lun.  This is a task that I really want to perform in vRealize Orchestrator (vRO) instead of having to unmount the datastore from the ESXi server manually.  SPOILER ALERT - I'll include a workflow that allows you to execute the unmount across multiple ESXi servers in parallel at the end of this post.
The first step is to see what's available from an unmount standpoint.  We start by bringing up the API Explorer under the Tools menu.

From here we can search the "Attributes & methods" for text that contains the word unmount.  There quite a few methods which contain the text unmount.  I'm going to focus on the VcHostStorageSystem.unmountVmfsVolume() method.  


This method takes a single argument - the uuid of the VMFS datastor…
Recent posts

Reconnecting ESXi servers with PowerCLI

We recently needed to re-ip our vCenter servers; each with ~200 ESXi servers which needed to be reconnected - thank goodness for PowerCLI.  Since there isn't a "Reconnect-VMHost" cmdlet provided by PowerCLI we needed to check the HostSystem Object at https://www.vmware.com/support/developer/converter-sdk/conv55_apireference/vim.HostSystem.html and to see what methods were available (hint: there's a ReconnectHost_Task method which will do the trick).  We can still leverage the "Get-VMHost" cmdlet to return the disconnected ESXi servers and then call the ReconnectHost_Task method to reconnect each ESXi server.  The code is fairly short:

Get-VMHost -state Disconnected | foreach-object {
  $vmhost = $_
  $connectSpec = New-Object VMware.Vim.HostConnectSpec
  $connectSpec.force = $true
  $connectSpec.hostName = $vmhost.name
  $connectSpec.userName = 'root'
  $connectSpec.password = 'MySecretPassword'
$vmhost.extensionData.ReconnectHost_Task($connectSpec,…

vCO-CLI

I attended a VMworld TAM Customer Central session this morning title "What's Next in vCenter Orchestrator" (a.k.a. vRealize Orchestrator).  One of the cool features is vCO-CLI, which has actually been available for about 8 months now as a VMware Fling ( https://labs.vmware.com/flings/vco-cli ).  I'm by no means an expert but have used vCO-CLI to debug an issue I was having so I thought I would throw together a short page on it.  This will hopefully give an idea of how the tool can be used.  I'm not going to go through how to install the plug-in.

I'll start with creating a very basic workflow which takes just a VcHostSystem as an Input parameter.



Next, I'll add just a Scriptable task with my VcHostSystem as an IN parameter.  This Scriptable task has only one line which is what starts the vCO-CLI session.



That's it!  Now we can run the workflow providing a VcHostSystem object.



If you check the Logs tab on the running workflow then you'll see the session…

Querying for nested folders with PowerCLI

Have you fought trying to query nested, duplicate-named folders?  Hopefully this will help solve the problem!  Suppose you have a VM folder-tree similar to this:


So, how do you get the "\dotcom\linux\dev" folder using PowerCLI?  If you query for just "dev" then you can get an array of folders.
You can parse through the array and, using the parent object, traverse the tree backwards validating the folder names.  But, what if you have 100s of folders?  In my opinion, this is not an optimal approach.  We really need to do this:

This is great case for recursion.  In my words, recursion is a "stack" of operations.  When an operation completes its result is used by the next operation in the "stack".  Most importantly there has to be base-case which causes the last operation in the stack to return a valid result.  Then each operation can be popped off the "stack" and its result can be used by the previous operation until the final result is obta…

ESXi 5.0 kickstart / scripted install

Years ago when I first started playing with Linux kickstart I was also dabbling in php; using the two I was able to come up with a single "ks.php" file that we used for all our Linux installs.  When I was given the opportunity to work with our VMware infrastructure (ESX 4.0), one of my first tasks was the ESX 4.1 installation.  When I saw it was Red Hat Linux I knew exactly what to do and pulled out my php scripts.  As ESXi has evolved so has my scripts so even though ESXi isn't Red Hat Linux the same approach still works.  I hope someone will find these useful.

You may be asking, why not just use Auto Deploy?  First, the infrastructure to support our scripted install is already in place.  There is nothing new to install except for new ESXi images.  Second, we had a concern about relying on additional infrastructure to get things back online in the event our entire datacenter went down.  Now that ESXi 5.1 has the "stateless cache" option I do plan on investigati…

Parsing XML with VMware Orchestrator

For my first blog I thought I would start with something easy - parsing XML using VMware Orchestrator (a.k.a vCO)!  I started playing with vCO in September 2012 for a "Cloud" project so I still consider myself a newbie - if you happen across this post and find something incorrect or something that could be done better then please don't hesitate to speak up.

Since I can't post our actual XML, I'll be using the following XML which will give the gist of how to parse for elements & attributes.

<?xml version="1.0" encoding="UTF-8" ?>
<people>
  <person firstname="Jack" lastname="Smith" age="40">
    <phone type="home" number="1234567890" />
    <phone type="cell" number="1234567891" />
<sport name="basketball" position="shooting guard" />
  </person>
  <person firstname="Jill" lastname="Smith" age=&q…