Project

General

Profile

Actions

Bug #20374

closed

Image templates don't resolve any more during host creation

Added by Joop van de Wege over 7 years ago. Updated about 7 years ago.

Status:
Duplicate
Priority:
High
Assignee:
-
Category:
Templates
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Foreman version 1.15-2 with a Vmware compute resource that used to work with 1.14.2/3
To reproduce:
Create a template in Vmware, windows2012R2 in my case. Add the image to compute resource/images
Create a host based on the image and on the tab Operating System tick the radio button Image Based, make sure that the required fields are filled with info and hit the Provisioning templates Resolve button --> Sorry but no templates were configured. despite the fact that all was working well with 1.14.2/3
The following stacktrace is found in production.log:

2017-07-21 10:36:19 ac197707 [app] [W] Action failed
 | NoMethodError: undefined method `[]' for nil:NilClass
 | /usr/share/foreman/app/models/concerns/hostext/operating_system.rb:47:in `template_kinds'
 | /usr/share/foreman/app/models/concerns/hostext/operating_system.rb:26:in `available_template_kinds'
 | /usr/share/foreman/app/controllers/hosts_controller.rb:649:in `template_used'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/actionpack-4.2.5.1/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/actionpack-4.2.5.1/lib/abstract_controller/base.rb:198:in `process_action'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/actionpack-4.2.5.1/lib/action_controller/metal/rendering.rb:10:in `process_action'

And if I modify the following file (/usr/share/foreman/app/models/concerns/hostext/operating_system.rb) to use some logging.info lines then I get the following:

2017-07-21 10:48:37 54f7774f [app] [I] In Available_template_kinds
2017-07-21 10:48:37 54f7774f [app] [I] Template_kinds start parameter= image.
2017-07-21 10:48:37 54f7774f [app] [I] Computeresource is: VMWare  (VMware).
2017-07-21 10:48:37 54f7774f [app] [I] Images: #<Image::ActiveRecord_Associations_CollectionProxy:0x0000000d34dd68>.
2017-07-21 10:48:37 54f7774f [app] [I] Before UUID.
2017-07-21 10:48:37 54f7774f [app] [W] Action failed
 | NoMethodError: undefined method `[]' for nil:NilClass
 | /usr/share/foreman/app/models/concerns/hostext/operating_system.rb:48:in `template_kinds'
 | /usr/share/foreman/app/models/concerns/hostext/operating_system.rb:27:in `available_template_kinds'

def template_kinds(provisioning = nil)
logger.info "Template_kinds start parameter= #{provisioning}."
return TemplateKind.all unless provisioning == 'image'
cr = ComputeResource.find_by_id(self.compute_resource_id)
logger.info "Computeresource is: #{cr}."
images = cr.try(:images)
logger.info "Images: #{images}."
if images.blank?
[TemplateKind.friendly.find('finish')]
else
logger.info "Before UUID."
uuid = self.compute_attributes[cr.image_param_name]
logger.info "After UUID, uuid=: #{uuid}."
image_kind = images.find_by_uuid(uuid).try(:user_data) ? 'user_data' : 'finish'
logger.info "Imagekind: #{image_kind} (finish omdat uuid =nil)."
[TemplateKind.friendly.find(image_kind)]
end
end

Looks like the uuid can't be filled but if I use foreman-rake console then I can see that images does have an uuid for this compute resource.


Related issues 2 (0 open2 closed)

Related to Foreman - Bug #18557: Image based provisioning brokenResolved02/18/2017Actions
Is duplicate of Foreman - Bug #20098: Cannot resolve user_data template with all kind of compute-resourceClosedDaniel Lobato Garcia06/23/2017Actions
Actions

Also available in: Atom PDF