Resize VMWare Disk During Provisioning (w/ Fat Template)


#1

Hello Everyone,

As the title says, I need to resize the first disk during a catalog provisioning from a fat template based on the ram amount that the person who orders the machine. For example:

Person A orders a machine with 8 GB of RAM, the machine is provisioned with 20GB of the first disk of the template.

Person B orders a machine with 16 GB of RAM, the machine is provisioned with 40GB of the first disk of the template.

Person x orders a machine with nGB of RAM, the machine is provisioned with mGB of the first disk of the template.

For reference, I have searched the web and I found this:


The first link provides a method but this works when the machine is already provisioned. And the second link provides a method (that I actually use) to add a new disk to the machine during provisioning (in CatalogItemInitialization):

extra_disk = $evm.root['dialog_extra_disk'].to_i
extra_disk = extra_disk * 1024
$evm.log('info', "Adding disk of #{extra_disk} MB")
new_disks = []
new_disks << {:bus=>0, :pos=>1, :sizeInMB=> extra_disk}
$evm.log('info', "Disks to add: #{new_disks}")
prov.set_option(:disk_scsi, new_disks)

I have tried with the previous code including to the array ‘new_disks’ the resize that I want but It didn’t work:
new_disks << {:bus=>0, :pos=>0, :sizeInMB=> 92160}

But It doesn’t meet the requirements that I have.

Could anyone help me?

Thanks in advance!!!