Documenting vRealize Orchestrator Code with JSDoc and Confluence

Recently I’ve been working on improving HobbitCloud’s DevOps practices, specifically around committing code to version control and documenting it. Once a developer checks code in, this should compile, and if successful be deployed to the test environment. Once here it will undergo automated testing before progressing to staging for unit and integration tests. Continue reading

Wednesday Tidbit: Shutdown your lab with one click

20150713 - PowerCLIRecently I’ve found myself having to shutdown my home lab quite often as the weather has been better than expected and the temperature has risen dramatically.  Great for sitting in beer gardens, not so good for the lab.

To speed up the process of shutting down all my VMs (currently 68 of them) I decided to knock up a very simple PowerCLI script:

# Variables

$esxi = "esxi.mdb-lab.com"
$credential = Get-Credential

Connect-VIServer $esxi -Credential $credential

Get-VM | where {$_.Powerstate -eq "PoweredOn"} | Shutdown-VMGuest -Confirm:$false

Start-Sleep -s 600

Stop-VMHost -Confirm:$false -Force:$true

Disconnect-VIserver $esxi -Confirm:$false

Definitely not rocket science, but the greatest scripts don’t always have to be complicated.

There are a lot of other devices (storage and networking equipment) that also have to be scripted to shutdown, but this is a start.

Wednesday Tidbit: Create custom ESXi ISO with ESX-tools-for-ESXi

20150713 - PowerCLIMy test cluster in the lab recently needed to be rebuilt.  As this cluster is nested and I wanted the latest version of ESXi to be deployed, I thought it would be good to use Image Builder to combine the two.

After downloading the VMware Tools for Nexted ESXi tools fling, I followed Andreas Peetz’ article on how to use them to build an offline bundle.

Once done, I used the following PowerCLI script with Image Builder to create my new ISO complete with VMware Tools for Nested ESXi:

# Add VMware depot
Add-EsxSoftwareDepot C:\Depot\ESXi550-201505002.zip

# Clone the ESXi 5.5 GA profile into a custom profile
$CloneProfile = Get-EsxImageProfile ESXi-5.5.0-20150504001-standard
$MyProfile = New-EsxImageProfile -CloneProfile $CloneProfile -Vendor $CloneProfile.Vendor -Name (($CloneProfile.Name) + "-virtualhobbit") -Description $CloneProfile.Description

# Add the Nested ESXi VMTools Offline bundle
Add-EsxSoftwareDepot C:\Depot\esx-tools-for-esxi-9.7.1-0.0.00000-offline_bundle.zip

# Add the esx-tools-for-esxi package to the custom profile
Add-EsxSoftwarePackage -SoftwarePackage esx-tools-for-esxi -ImageProfile $MyProfile

# Disable signature check
$DeployNoSignatureCheck=$true

# Export the custom profile into an ISO file
Export-EsxImageProfile -ImageProfile $MyProfile -ExportToISO -NoSignatureCheck -FilePath C:\Depot\ESXi550-201505002-virtualhobbit.iso

I also chose to export the image profile to a .zip file, so I could use it to remediate an existing cluster using VUM.

Export-EsxImageProfile -ImageProfile $MyProfile -ExportToBundle -NoSignatureCheck -FilePath C:\Depot\ESXi550-201505002-virtualhobbit.zip

Wednesday Tidbit: PowerCLI script to enable copy & paste

20150713 - PowerCLIUnlike at work, when I access servers in the lab I use the vSphere Client remote console.  Unfortunately since vSphere 4.1, copy & paste between the host and the console has been disabled – which I find a pain (even though it’s probably more secure).  It can be enabled per-VM with the following two settings:

isolation.tools.copy.disable="false"
isolation.tools.paste.disable="false"

I wanted to enable it on all my backend VMs, but not my other VMs (DMZ etc).  For this I used the following PowerCLI script:

$esxi = "lab01.mdb-lab.com"
$credential = Get-Credential
$tgtVLAN = 'VLAN70','VLAN80','VLAN120'

Connect-VIServer $esxi -Credential $credential

Get-VM |where {
   (Get-NetworkAdapter -VM $_ | %{$tgtVLAN -contains $_.NetworkName}) -contains $true} | %{
      New-AdvancedSetting $_ -Name isolation.tools.copy.disable -Value false -Confirm:$false -Force:$true
      New-AdvancedSetting $_ -Name isolation.tools.paste.disable -Value false -Confirm:$false -Force:$true
   }
}

Disconnect-VIServer $esxi -Confirm:$false

I’d like to thank Luc Dekens for helping me with that last bit. If you get chance, check him out at http://www.lucd.info/.