Unable to provision VMWare with additional disks

Problem:

When provisioning a VMWare Template via “Create host” function I add a additional disk specifying the datastore etc; the template clone fails with the below message:

2018-06-21T11:35:47 e773dee3 [app] [W] Failed to create a compute #### instance dewey-scatton: InvalidDeviceSpec: Invalid configuration for device '3'.

/app/foreman/vendor/ruby/2.1.0/gems/fog-vsphere-2.2.0/lib/fog/vsphere/requests/compute/vm_clone.rb:692:invm_clone’`

Provisioning the template with it’s standard disks works fine and extending them does too; any additional disks causes failure. Is this a known issue?

Expected outcome:

Template is provisioned with a additional 10Gb disk attached ~ doesn’t need to be mounted just attached as “hard disk 3”

Foreman and Proxy versions:
Foreman Version 1.16.2
Vmware VCenter Server 6.0.0

Other relevant data:

Longer error indicates:

 |
 | RbVmomi::Fault: InvalidDeviceSpec: Invalid configuration for device '3'.
 | /app/foreman/vendor/ruby/2.1.0/gems/rbvmomi-1.12.0/lib/rbvmomi/vim/Task.rb:14:in `wait_for_completion'
 | /app/foreman/vendor/ruby/2.1.0/gems/fog-vsphere-2.2.0/lib/fog/vsphere/requests/compute/vm_clone.rb:692:in `vm_clone'
 | /app/foreman/app/models/compute_resources/foreman/model/vmware.rb:500:in `clone_vm'
 | /app/foreman/app/models/compute_resources/foreman/model/vmware.rb:432:in `create_vm'
 | /app/foreman/app/models/concerns/orchestration/compute.rb:77:in `setCompute'
 | /app/foreman/app/models/concerns/orchestration.rb:220:in `execute'
 | /app/foreman/app/models/concerns/orchestration.rb:145:in `block in process'
 | /app/foreman/app/models/concerns/orchestration.rb:137:in `each'
 | /app/foreman/app/models/concerns/orchestration.rb:137:in `process'
 | /app/foreman/app/models/concerns/orchestration.rb:44:in `around_save_orchestration'``

Hi @lukayeh

It looks like you are hitting the following BZ:

https://bugzilla.redhat.com/show_bug.cgi?id=1538597

I can give you a modifed version of the fog-gem which removes the prs that caused this if you like?

I am working on filing an issue in fog-vsphere and will work to get it fixed there correctly.

Hi @cintrix84

Thanks for the quick response, If you could provide a modified fog-gem then I’d be eternally grateful :slight_smile:

Much appreciated !

Hi @lukayeh

Can I have you provide the output for me:

rpm -qa | grep fog

Hi @cintrix84

I work with Luka and we have tracked the issue down to the change to the create_disk method in requests/compute/create_vm.rb. The change removes the ability to set the unit_number in the call to create_disk and instead relies upon a method in models/compute/volume.rb to automagically set the id based on the server object. This ends up with the new disk getting the unit_number of 0 as all the disks that are in the template at the time the code does this have the unit_number set as nil. This then ends up with the new disk conflicting with the templates disks.

We’ve worked around it with a one liner that adds a unit_number based on the index (as it was previously in fog-vsphere < 1.7.0) before calling create_disk.

Basically by adding:
new_volumes.map { |volume| volume.unit_number = volumes.index(volume) }
Just before:
specs.concat(new_volumes.map { |volume| create_disk(volume) })
in the function:
modify_template_volumes_specs
in the file:
fog-vsphere-2.2.0/lib/fog/vsphere/requests/compute/create_vm.rb

Hi @AndyM

I can work on getting this patched into fog-vsphere if you like or if you wanted to submit a PR I can test and merge, whatever works for you, I would want you to take credit for the find :slight_smile:

I’ll submit a PR as soon as I can. Thanks @cintrix84

3 Likes