Bug #16545

Host node YAML import calls AR finder with incorrect second argument

Added by Dominic Cleal over 1 year ago. Updated over 1 year ago.

Assigned To:Dominic Cleal
Target version:-
Difficulty: Bugzilla link:
Found in release: Pull request:https://github.com/theforeman/foreman/pull/3842
Story points-
Velocity based estimate-
Release1.14.0Release relationshipAuto


Under Rails 5, the Host::Managed#importNode method raises an error when importing a YAML file that contains parameterised classes (as in our unit test):

HostTest::location or organizations are not enabled.test_0013_should import from external nodes output
TypeError: can't quote Hash
    app/models/host/managed.rb:489:in `block in importNode'
    app/models/host/managed.rb:488:in `each'
    app/models/host/managed.rb:488:in `importNode'
    test/unit/host_test.rb:757:in `block (2 levels) in <class:HostTest>' (TypeError)

On Rails 4, calling Puppetclass.find_by_name(["klass", {:params => foo}]) was just returning the klass and ignoring the second element of the array. Under Rails 5 it raises an error.

The .find_by_name call should only be passed a string with a name.

Note that the classes in an ENC YAML may be either an array or hash, but the unit test only checks the hash format.

Associated revisions

Revision 37c0b37f
Added by Dominic Cleal over 1 year ago

fixes #16545 - correctly search for classes from YAML import

Prevents a full class hash of name => parameters being passed to the AR
finder when using a parameterized (hash-style) YAML format.


#1 Updated by The Foreman Bot over 1 year ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/3842 added

#2 Updated by Dominic Cleal over 1 year ago

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

#3 Updated by Dominic Cleal over 1 year ago

  • Release set to 1.14.0

Also available in: Atom PDF