Project

General

Profile

Bug #8405

Resolve Templates button on Host#edit broken for multi-nic systems

Added by Greg Sutcliffe over 4 years ago. Updated 11 months ago.

Status:
Closed
Priority:
High
Category:
Host creation
Target version:
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

If a host has extra interfaces, then the Resolve Templates button is broken for existing hosts, because the DB tries to match Nics with IDs to a Host without. THis is because we call Host.new(params[:host]) which creates a new Host with id=nil, but uses the nested attrs for the nics. This leads to logs like this:

Nic::Base Load (0.2ms)  SELECT "nics".* FROM "nics" WHERE "nics"."host_id" IS NULL AND "nics"."id" IN (17, 19) ORDER BY identifier
not found: Couldn't find Nic::Base with ID=17 for Host::Managed with ID=

To reproduce, create a host with at least one nic in the Network tab (i.e not just the primary interface). Save it (as it works fine while both entities have id=nil), then edit and try the Resolve Templates button. It should say "Sorry but no templates were configured."

To fix, we should probably a) drop the nested attrs for the application.js#template_info JS function, and b) drop them again in the controller (in case someone hits it from outside the UI).


Related issues

Related to Foreman - Bug #9058: Changing organization/location when creating new host resets interfaces setupClosed2015-01-21
Related to Foreman - Bug #11767: Templates are not being resolved in the host formClosed2015-09-10

Associated revisions

Revision be4602e8 (diff)
Added by Greg Sutcliffe over 4 years ago

Fixes #8405 - Filter :interfaces_attributes when calculating templates_used

Revision 5c72a840 (diff)
Added by Greg Sutcliffe over 4 years ago

Fixes #8405 - Filter :interfaces_attributes when calculating templates_used

(cherry picked from commit be4602e87f8a8f35f49c8568fdea41e1570e5bb2)

History

#1 Updated by The Foreman Bot over 4 years ago

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

#2 Updated by Dominic Cleal over 4 years ago

  • Assignee set to Greg Sutcliffe

#3 Updated by Greg Sutcliffe over 4 years ago

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

#4 Updated by Tomáš Strachota over 4 years ago

  • Related to Bug #9058: Changing organization/location when creating new host resets interfaces setup added

#5 Updated by Marek Hulán over 3 years ago

  • Related to Bug #11767: Templates are not being resolved in the host form added

Also available in: Atom PDF