Project

General

Profile

Bug #5630

VmWare clone from template fails if Network Adator has labels in VmWare

Added by Jean-Christophe Counio over 5 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Compute resources - VMware
Target version:
Difficulty:
Triaged:
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

In VmWare you can define labels for Network Adapters, and that's the list that is returned in the 'New Host' form 'Network interfaces' list.
In app/models/compute_resources/foreman/model/vmware.rb, in clone_vm, the network adapter is hardcoded as "Network adapter 1":
interface = interfaces.detect{|i| i[:name] == "Network adapter 1" }
Since it is not in the interfaces list, clone is failing with error :
Failed to save: Failed to create a compute [...] instance [...]: undefined method `[]' for nil:NilClass
/usr/share/foreman/app/models/compute_resources/foreman/model/vmware.rb:292:in `clone_vm'
/usr/share/foreman/app/models/compute_resources/foreman/model/vmware.rb:257:in `create_vm'

Solution would be to use the selected interface from args instead of having it hardcoded


Related issues

Related to Foreman - Bug #5483: Network label empty after cloning vware vm using image and distributed switch for networkClosed2014-04-29
Related to Foreman - Bug #7740: Installing from VMware Image breaks distributed Port Group supportClosed2014-09-29
Related to Foreman - Bug #9704: Network label is unchanged on additional network interfaces with VMware templatesClosed2015-03-10
Related to Foreman - Bug #14874: Path incorrect when using vm_clone methodClosed2016-04-28
Has duplicate Foreman - Support #9956: Failed to create a compute <Datacenter> (VMWare) instance foo.sub.domain.tld: undefined method `[]' for nil:NilClassResolved2015-03-31

Associated revisions

Revision e7d21bf0 (diff)
Added by Timo Goebel about 4 years ago

fixes #5630 - fixes VMWare clone from template fails if VMWare is in foreign language

Revision 73b70677 (diff)
Added by Timo Goebel about 4 years ago

fixes #5630 - fixes VMWare clone from template fails if VMWare is in foreign language

(cherry picked from commit e7d21bf01f2b9eee19b808c4ea320ddfd9c33b3d)

History

#1 Updated by Dominic Cleal over 5 years ago

  • Related to Bug #5483: Network label empty after cloning vware vm using image and distributed switch for network added

#2 Updated by Dominic Cleal over 5 years ago

  • Category set to Compute resources

#3 Updated by Jan Behrend about 5 years ago

Our vSphere was once upon a time (ESX3.x) installed in German and the expression for the "Network adapter 1" is then "Netzwerkadapter 1". I am not suggesting to support all locales at this point but i second Jean-Christophe that this should not be hard coded.

Cheers Jan

#4 Updated by Jan Behrend about 5 years ago

Here is another one for hardcoding. For some reason our vSphere has been installed with some german fragments. This is why all of the deployment features from within foreman did not work:

foreman/app/models/compute_resources/foreman/model/vmware.rb:309
path_replace = %r{/Datacenters/#{datacenter}/vm(/|)}

in german this rather is:
path_replace = %r(/Datencenter/#{datacenter}/vm(/|))

Again, so suggestion to support locales, but hardcoding seems to be causing trouble.

Thanks for all the work!
Cheers Jan

#5 Updated by Dominic Cleal about 5 years ago

  • Category changed from Compute resources to Compute resources - VMware

#6 Updated by Aaron Zauner almost 5 years ago

For people experiencing the same issue, this is a (very temporary) fix that seems to work just fine with Foreman 1.6.1: https://gist.github.com/azet/d55045995d0ef49497c5

A generic solution for the issue would be appreciated - but I understand that not many deployments will have this issue.

#7 Updated by Friedrich Seifts almost 5 years ago

We ran into this issue while trying to setup Foreman against our Vsphere 5.5U1 environment. From what I could tell there was no localization issues since this install was EN based.

The template we were trying to deploy from was copied over from another data-center(within vcenter).

When we copied the template over it was edited to reference the correct VDS for the new datacenter/network/hyp's it will be servicing. However with all that said, we still had this issue. When looking at the template when converted to a VM, it showed a single network adapter, but that adapter was #2 in the list.

What resolve the problem for us was to delete that network adapter, save(click ok), re-add a network adapter and select a default VDS/port-group. Now the adapter displays as "adapter #1" , instead of "adapter #2" and we are able to deploy VM's.

Cheers.

#8 Updated by Friedrich Seifts almost 5 years ago

Edit: This was with Foreman 1.6.1

#9 Updated by Friedrich Seifts almost 5 years ago

  • Related to Bug #7740: Installing from VMware Image breaks distributed Port Group support added

#10 Updated by Dominic Cleal over 4 years ago

  • Has duplicate Support #9956: Failed to create a compute <Datacenter> (VMWare) instance foo.sub.domain.tld: undefined method `[]' for nil:NilClass added

#11 Updated by Dominic Cleal about 4 years ago

  • Related to Bug #9704: Network label is unchanged on additional network interfaces with VMware templates added

#12 Updated by Dominic Cleal about 4 years ago

#9704 (which won't be merged for a while) will fix the Network Adapter name lookup, but the Datacenter name.

#13 Updated by The Foreman Bot about 4 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/2549 added
  • Pull request deleted ()

#14 Updated by Dominic Cleal about 4 years ago

  • Legacy Backlogs Release (now unused) set to 35

#15 Updated by Anonymous about 4 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#16 Updated by Dominic Cleal over 3 years ago

  • Related to Bug #14874: Path incorrect when using vm_clone method added

Also available in: Atom PDF