MAC Adress gets removed when using VMware Import

When using the VMware import (Compute Resource -> VirtualMachines -> Import as managed), the MAC address is visible at first (in the Interface tab) but gets removed when choosing a Organization or Location.
Afterwards, the MAC can not be added because the field is greyed out (unless switching the type back and forth).
If not paying attention and fixing this manually, this results in a Host without TFTP/DHCP config deployed.

Expected outcome:
The MAC address should stay configured.

Foreman and Proxy versions:

  • Foreman 2.3.3
  • Smartproxy 2.3.3

Foreman and Proxy plugin versions:

  • tfm-rubygem-fog-vsphere-3.4.0-1.el7.noarch

The problem is observed with at least Firefox and Microsoft Edge (based on chromium).

Other relevant data:

This has worked in the past (with Foreman 1.24). I can not really say anything about Foreman 2.0 to 2.2 because we never used it.

I do see the following in the JavaScript console:

[DOM] Found 2 elements with non-unique id #interface: (More info: 

The Foreman log looks fine; I can just see the request without any MAC address configured:

2021-06-08T14:52:24 [I|app|98212efb] Completed 200 OK in 18ms (Views: 5.4ms | ActiveRecord: 4.9ms | Allocations: 12730)
2021-06-08T14:52:24 [I|aud|5cd53b8f] Nic::Managed (66948) create event on mac
2021-06-08T14:52:24 [I|aud|5cd53b8f] Nic::Managed (66948) create event on ip
2021-06-08T14:52:24 [I|aud|5cd53b8f] Nic::Managed (66948) create event on type Nic::Managed
2021-06-08T14:52:24 [I|aud|5cd53b8f] Nic::Managed (66948) create event on name
2021-06-08T14:52:24 [I|aud|5cd53b8f] Nic::Managed (66948) create event on host_id 32838
2021-06-08T14:52:24 [I|aud|5cd53b8f] Nic::Managed (66948) create event on subnet_id 189
2021-06-08T14:52:24 [I|aud|5cd53b8f] Nic::Managed (66948) create event on domain_id 4

After enabling debug mode, I see the following in the Foreman log:

2021-06-17T09:10:20 [I|app|32e5f748] Started POST "/hosts/process_taxonomy" for at 2021-06-17 09:10:20 +0200
2021-06-17T09:10:20 [I|app|32e5f748] Processing by HostsController#process_taxonomy as */*
2021-06-17T09:10:20 [I|app|32e5f748]   Parameters: {"utf8"=>"✓", "authenticity_token"=>"xyz", "host"=>{"name"=>"tst-manuelimport-01", "organization_id"=>"", "location_id"=>"4", "hostgroup_id"=>"", "compute_profile_id"=>"", "content_facet_attributes"=>{"lifecycle_environment_id"=>"", "content_view_id"=>"", "content_source_id"=>""}, "environment_id"=>"", "zone_policy_facet_attributes"=>{"systemgroup_id"=>""}, "puppet_proxy_id"=>"", "puppet_ca_proxy_id"=>"", "monitoring_proxy_id"=>"", "managed"=>"true", "uuid"=>"50044311-6bd1-c1f2-5808-a94a06c71fd7", "compute_resource_id"=>"4", "progress_report_id"=>"[FILTERED]", "type"=>"Host::Managed", "interfaces_attributes"=>{"0"=>{"_destroy"=>"0", "type"=>"Nic::Managed", "identifier"=>"", "name"=>"tst-manuelimport-01", "domain_id"=>"3", "subnet_id"=>"", "ip"=>"", "ip6"=>"", "managed"=>"1", "primary"=>"1", "provision"=>"1", "execution"=>"1", "virtual"=>"0", "tag"=>"", "attached_to"=>"", "compute_attributes"=>{"type"=>"VirtualVmxnet3", "network"=>"dvportgroup-2530452"}}}, "architecture_id"=>"", "operatingsystem_id"=>"", "provision_method"=>"build", "build"=>"0", "medium_id"=>"", "ptable_id"=>"", "disk"=>"", "root_pass"=>"[FILTERED]", "is_owned_by"=>"481-Users", "enabled"=>"1", "expired_on(1i)"=>"", "expired_on(2i)"=>"", "expired_on(3i)"=>"", "comment"=>"", "overwrite"=>"false"}, "compute_resources_vm"=>{"compute_attributes"=>{"cpus"=>"2", "corespersocket"=>"1", "memory_mb"=>"4096", "boot_order"=>["network", "disk"], "scsi_controllers"=>"{\"scsiControllers\":[{\"type\":\"VirtualLsiLogicController\",\"shared_bus\":\"noSharing\",\"unit_number\":7,\"key\":1000}],\"volumes\":[{\"thin\":true,\"name\":\"Hard disk 1\",\"mode\":\"persistent\",\"controllerKey\":1000,\"serverId\":\"50044311-6bd1-c1f2-5808-a94a06c71fd7\",\"datastore\":\"LX-RZ1-LAN-Mirror-05\",\"id\":\"6000C29c-79b9-1127-a9c2-599e45d78443\",\"eagerZero\":false,\"filename\":\"[LX-RZ1-LAN-Mirror-05]\",\"unitNumber\":0,\"sizeGb\":100}]}", "image_id"=>""}}, "fakepassword"=>"[FILTERED]"}
2021-06-17T09:10:20 [D|tax|32e5f748] Current location set to none
2021-06-17T09:10:20 [D|tax|32e5f748] Current organization set to none
2021-06-17T09:10:20 [D|app|32e5f748] Unpermitted parameter: :compute_resources_vm

Note the Unpermitted parameter: :compute_resources_vm

The relevant code seems to be: foreman/hosts_controller.rb at develop · theforeman/foreman (

The problem happens when process_hostgroup or process_taxonomy in the hosts controller is called. This does not affect editing an existing host (as there hostgroup_or_environment_selected is called when changing the hostgroup).

I think this is some Ruby on Rails feature that prevents sending parameters, but I can’t remember much. @ezr-ondrej could you refresh my memory? I remember we have some “filters” or some special concerns with these “permitted” attributes.

So the disabling of mac is Fixes #28754 - Disabling MAC address input for virtualization by domitea · Pull Request #7366 · theforeman/foreman · GitHub where we forgot about the import feature completely, this was added by @dmatoulek.
If the mac address is passed through properly on some occassions the filter is not relevant in this case, but if we would need to allow some additional attributes, which I belive we don’t, we would do it in foreman/host_base.rb at 3256e1396e157b8a84960fc40e4754ab0ebc9c98 · theforeman/foreman · GitHub

I think we just need to handle the import case and not disable the UI field.

1 Like

Thank’s for the heads up - I did not find that change before.

I can confirm that reverting the commit does indeed fix the import problem described above.
I’ll prepare a PR tomorrow, if I can find some spare time for that.

1 Like

I don’t understand how UI-related commit can affect an unpermitted parameter, this is just lack of understanding of RoR here.

Maybe the error was there before, but nobody noticed as it’s only shown in Debug mode and seems to not break anything.
Though, I don’t have a Foreman 1.24 (or whatever) setup here to test this theory.

As Manuel is saying it did not affect it, but noone pays attention to it. It is unrelated to the bug

1 Like

I’ve prepared a PR here: Fixes #32842: Don't disable MAC address input for VMs being imported by laugmanuel · Pull Request #8612 · theforeman/foreman · GitHub
However, I’m not sure if there is a better way to detect if it is an import…

1 Like