Actions
Bug #12936
closedHostgroup environment isn't inherited by Host via model API
Difficulty:
Triaged:
Bugzilla link:
Pull request:
Description
Problem:
Since [[hostgroup_inherited_attributes](https://github.com/theforeman/foreman/blob/develop/app/models/host/managed.rb#L577)] uses association IDs instead of AR objects, creating hosts like
hg.environment = Environment.first sample_host = Host.new(:name => 'hostname', :hostgroup => hg).environment sample_host.environment == nil #=> true
will not work.
The method to inherit these attributes relies on string attributes so Host must be created using 'hostgroup_id' or 'hostgroup_name' to inherit hostgroup attributes, like:
sample_host = Host.new(:name => 'hostname', 'hostgroup_id' => hg.id)
Solution:
Make apply_inherited_attributes capable of inheriting regular AR relations, and not just attributes when passed as strings. That's why inheritance only works from the UI.
Updated by Dominic Cleal almost 9 years ago
- Subject changed from Hostgroup environment isn't inherited by Host to Hostgroup environment isn't inherited by Host via model API
- Category set to Host creation
Updated by The Foreman Bot over 8 years ago
- Status changed from New to Ready For Testing
- Assignee set to Ondřej Pražák
- Pull request https://github.com/theforeman/foreman/pull/3243 added
Updated by Ondřej Pražák over 8 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset d7110d54ad51a85eadde8283606e88cf01de8b19.
Updated by Dominic Cleal over 8 years ago
- Translation missing: en.field_release set to 141
Actions