Project

General

Profile

Actions

Bug #38648

open

Cloning an existing VMware VM fails in Foreman 3.15: undefined method ‘include?’ for nil:NilClass

Added by Leos Stejskal 8 months ago. Updated 8 months ago.

Status:
New
Priority:
Normal
Assignee:
Category:
Compute resources - VMware
Target version:
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

From community post:

https://community.theforeman.org/t/cloning-an-existing-vmware-vm-fails-in-foreman-3-15-undefined-method-include-for-nil-nilclass/44043

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”

Actions

Also available in: Atom PDF