Build Windows VMs with Multiple Drives with VCF Automation

We've discussed building VMs with VCF Automation many times over the years. I've published dozens of Blueprints over the years, you can get them here.
I've been working on a Blueprint to deploy Windows VMs with a couple features:
Add Notes to the VM Notes tile
Configure C:\drive space allocation
Add additional drives with varying space allocated (D:\, E:\, etc)
Here's what I came up with. All screenshots here are from VCF Automation 8.18.8, but this applies to VCFA 9.x VM Apps as well.
To highlight a couple things, I'm asking the requester for the C:\ drive space and any additional drives (including size and label) they'd like. The inputs look like this:
Blueprint Input Snippet Here
c_drive_gb:
type: integer
title: C:\ Size (GB)
description: Boot drive. Must be at least the template disk size; it can only grow.
default: 150
minimum: 150
maximum: 500
extra_disks:
type: array
title: Additional Drives (D:\, E:\, ...)
description: Add one row per extra drive. Each drive letter should only be used once.
minItems: 0
maxItems: 10
items:
type: object
properties:
driveLetter:
type: string
title: Drive Letter
default: D
enum:
- D
- E
- F
- G
- H
- I
- J
- K
- L
- M
sizeGB:
type: integer
title: Size (GB)
default: 50
minimum: 1
maximum: 2048
label:
type: string
title: Volume Label
default: Data
Then I'm using the input later in the Blueprint to build the VM, it looks like this:
Blueprint Resources Snippet Here
Cloud_Volume_1:
type: Cloud.Volume
allocatePerInstance: true
properties:
count: ${length(input.extra_disks)}
capacityGb: ${input.extra_disks[count.index].sizeGB}
name: ${input.vm_display_name + '-' + input.extra_disks[count.index].driveLetter}
provisioningType: thin
Cloud_vSphere_Machine_1:
type: Cloud.vSphere.Machine
properties:
image: ${input.os}
cpuCount: ${input.vcpuCount}
totalMemoryMB: ${input.totalMemoryMB}
name: ${input.vm_display_name}
hostname: ${input.vm_dns_name}
vm_snapshot: ${input.vm_snapshot}
owner: ${input.owner}
description: ${input.description}
category: ${input.category}
customizationSpec: ${input.customizationSpec}
# C:\ - resize the boot disk
storage:
bootDiskCapacityInGB: ${input.c_drive_gb}
# D:\ and up - attach the new volumes
attachedDisks: ${map_to_object(resource.Cloud_Volume_1[*].id, "source")}
# Passed to the vRO post-provision workflow (drive letters + labels)
extraDisks: ${input.extra_disks}
If you were to test this Blueprint it would look something like this.

You'll notice the inputs for C:\ drive size and additional drives. I've wrapped this Blueprint with a Custom Form for a bit better user experience, it looks like this.
If you'd like this Custom Form you can get it here.
Now, if you were to run this Blueprint at this point (requesting additional drives), you'd get a VM with 3 Hard Disks, but they wouldn't be available for use (formatted/online). In order for that to happen we need a vRO Workflow and a Subscription that runs it. The vRO Workflow connects to the VM and runs a PowerShell script to do the work. Note: the vRO Workflow includes as input the user (Administrator) and the password (which is the same as the one being set by the Customization Specification called from the Blueprint). If you want the vRO Package you can get it here.
Next we need a Subscription that runs the vRO Workflow above. I've created a Subscription against the Compute post provision Event that looks like this.
Now when I go to request a Windows VM with extra drives it looks like this.

Once I click REQUEST I'm prompted for input.
Once complete click DEPLOY. Over in vCenter you'll notice the following.

Notice the three disks and the VM Notes (which we discussed in the previous blog). Logging into the new Windows VM with the credentials set via the Customization Specification called in our Blueprint shows the following.

There we have our additional drives with the size/labels as expected. I hope this was helpful, enjoy!



Comments