Bug #38648
openCloning an existing VMware VM fails in Foreman 3.15: undefined method ‘include?’ for nil:NilClass
Description
From community post:
I’m currently using Foreman 3.15 with a VMware vCenter compute resource.
I’m trying to provision a new host by cloning an existing VMware VM (not a template) using the “Image” provisioning method.
However, the provisioning fails with the following error:
undefined method `include?' for nil:NilClass
This appears to originate from the fog-vsphere plugin, specifically in the method get_vm_by_name in:
/usr/share/gems/gems/fog-vsphere-3.7.1/lib/fog/vsphere/requests/compute/get_virtual_machine.rb:40
The issue occurs because name is nil, and name.include?('/') is called without a check, causing a crash.
Expected behavior:
I expect Foreman to allow me to clone an existing VM (not a template) by specifying its name, and to handle this process gracefully without crashing if parameters are missing or misconfigured.
Steps to reproduce:
In Foreman 3.15, go to Hosts > Create Host
Use provision method = Image
Select a compute profile and a VMware compute resource
Fill in the VM settings (CPU, memory, disks, etc.)
Attempt to submit the form without explicitly setting the “VM to clone”