Project

General

Profile

Actions

Bug #10237

closed

Host.new and API disregard provision_method

Added by Felix Kellner almost 9 years ago. Updated about 8 years ago.

Status:
Duplicate
Priority:
Normal
Assignee:
-
Category:
Host creation
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

This example was done with VMware provisioning. The issue seems to be global and probably also affects other provisioning providers, however.

When having a compute resource defined with an image set (image_id), creating a host can either be done via image provisioning or build provisioning. Whatever is chosen within the UI means that the image_id in the compute attributes is either set and sent or not (the UI does this).

Upon using the API or calling Host.new within a plugin, image_id will always be set, since compute attributes are usually simply retrieved from the DB (which includes image_id). Setting provision_method to 'build' or 'image' doesn't make any difference and image provisioning will always be chosen.

For VMware provisioning the problem is within https://github.com/theforeman/foreman/blob/develop/app%2Fmodels%2Fcompute_resources%2Fforeman%2Fmodel%2Fvmware.rb#L322

Temporary workaround I used in a plugin:

compute_attributes = compute_resource.compute_profile_attributes_for(hostgroup.nested('compute_profile_id') || hostgroup.compute_profile_id)
# Workaround for Foreman not regarding provision_method = 'build' if image_id is set
compute_attributes[:image_id] = nil

From IRC:

Dominic | IceBear: hm, you're right. The UI applies compute profiles in the browser, and when doing an image build the image dropdown menu is disabled and hidden, so the image_id doesn't get sent back to Foreman, so it's not present. When using the API or console, everything is simply copied from the profile into the attrs...
Dominic | we could probably filter it out in the `set_compute_attributes` method in Host::Managed
Dominic | or pass provision_method through to compute resources properly so they don't need to guess
Dominic | (or use two separate methods, instead of create_vm for everything


Related issues 2 (1 open1 closed)

Related to Foreman - Bug #11050: Host Groups do not allow to specify image-based buildsNew07/08/2015Actions
Related to Foreman - Bug #12517: VMWare VM should be created network based if it is selected in the guiClosedTimo Goebel11/18/2015Actions
Actions #1

Updated by Dominic Cleal over 8 years ago

  • Related to Bug #11050: Host Groups do not allow to specify image-based builds added
Actions #2

Updated by Dominic Cleal over 8 years ago

  • Related to Bug #12517: VMWare VM should be created network based if it is selected in the gui added
Actions #3

Updated by Dominic Cleal about 8 years ago

  • Status changed from New to Duplicate

Thanks for the report, I'm now going to close it as it's been resolved under ticket #12517 in Foreman 1.10.1 instead. #13986 goes further in fixing this for other compute resources too.

Actions

Also available in: Atom PDF