I have released a version 2 that allows the disks to be managed by vRA GitHub - pgsmith123/vRA8.1
So we have the requirement to allow our customers to create VMs with N disks, each with a unique size and on a unique tier. Our rules are that each disk can only be 1TB in size and that storage has to be purchased in "blocks" based on the selected tier. To facilitate this we used cloud assembly tied with a subscription to call a vRO workflow. Essentially CA creates the VM and at the compute allocated state we execute the "Add disk" vRO workflow to add disks. The disks show up in CA at the next inventory cycle under the VM resource storage section and are deleted when the VM is deleted. They do not show up as objects on the deployment topology nor in the deployment resource list and are not re-configurable in CA.
This is a work in progress and is a ghetto way to get this working. But if it satisfies your needs here's the specifics...
CA Blueprint Code
inputs:
az:
type: string
enum:
- AZ1
- AZ2
title: Availability Zone
bootDiskTier:
type: string
enum:
- Gold
- Silver
- Bronze
title: Boot Disk Tier
bootDiskCapacityGB:
type: number
title: Boot Disk Size GB
minimum: 80
maximum: 1000
disks:
type: array
title: Disks
items:
type: object
properties:
tier:
type: string
title: Tier
enum:
- Gold
- Silver
- Bronze
size:
type: number
title: Size GB
minimum: 80
maximum: 1000
resources:
Cloud_vSphere_Machine_1:
type: Cloud.vSphere.Machine
properties:
disks: '${to_string(input.disks)}'
az: '${input.az}'
storage:
bootDiskCapacityInGB: '${input.bootDiskCapacityGB}'
constraints:
- tag: 'storageTier:${input.bootDiskTier}'
I built two custom actions and two custom workflow. I cant figure out how to export them from the embedded vRO... so here's the code.
getVmFromVcenterByName
Inputs:
vmName string
Return type: VC:VirtualMachine
System.log("Trying to resolve a vCenter VM with ID: " + vmName);
var vms = Server.findAllForType('VC:VirtualMachine', vmName);
if (vms.length > 0) {
for each (vm in vms) {
if (vm.name == vmName) {
System.log('Found vCenter VM ' + vm.name);
return vm;
}
}
}
throw 'No vCenter found with name ' + vmName;
getDatastoreWithMostFreeSpace
Inputs:
vc VC:sdkConnection
datacenter string
tier string
Return type: VC:Datastore
Add disk to VM
The first workflow just calls the system "Add disk" workflow and takes in input of a composite type to work around the limit of one input array to the foreach workflow in the next workflow below. Input each type in the composite type to the appropriate input on the Add disk workflow.
Inputs:
disk Object CompositeType(vm:VC:VirtualMachine,datastore:VC:Datastore,diskIndex:number,diskSize:number,diskMode:VC:VirtualDiskMode,scsiBusNumber:number,thinProvisioned:boolean):disk
CA-Add disks to VM
This woflow grabs the VM name from the input properties, then runs the getVmFromVcenterByName action above then builds the array of composite types from the "disks" inputs from the CA blueprint then executes the "Add disk to VM" workflow above in a loop to add each disk.
Build Disk Objects script code
Inputs:
inputProperties Properties
vm VC:VirtualMachine
thinProvisioned boolean
diskMode VC:VirtualDiskMode
Outputs:
diskObjects Array/CompositeType(vm:VC:VirtualMachine,datastore:VC:Datastore,diskIndex:number,diskSize:number,diskMode:VC:VirtualDiskMode,scsiBusNumber:number,thinProvisioned:boolean):disk
This is a great post and addresses the requirement that I have too for specifying N disks and sizes in the CA blueprint.
Would you mind elaborating further how on to create the composite array that feeds in to the for each loop?
Do you set a value for diskMode anywhere? I can't see how this value gets populated.
Thank you.