Explicit building of facets
|Assigned To:||Shimon Shtein|
|Found in release:||Pull request:||https://github.com/theforeman/foreman/pull/3987|
|Velocity based estimate||-|
This is a ticket to track required refactoring of the Facet framework. Since I am in hurry with patch for Foreman 1.13 and downstream, I will propose a dirty patch into Katello. This ticket is about properly extending the Facet framework allowing facets to be created in a nice way when creating hosts in a different way (not via expected entry point).
Originally, this is needed for #16063
#3 Updated by Shimon Shtein over 1 year ago
I suggest modifying #apply_inherited_attributes method to query facets about additional attributes that should be added to the host before it is created.
This won't solve the general case of building facets explicitly, unless we assume that "build_xxx_facet" method (which is added by the ActiveRecord framework) will be enough for facet initialization.
This could solve Katello's specific case, since the information to build content facet is available for the hostgroup that is being added to the host.
Basic outline of the suggested solution:
Each facet will have a class method (https://github.com/theforeman/foreman/blob/develop/app/models/host_facets/base.rb#L36) that will be called inside #apply_inherited_attributes. The result of this call will be added to the attributes list that is sent to ActiveRecord for further instantiation of the host.
Optional addition: the hostgroup could store a list of facets that should or should no be created by default - this list can be exposed to the user, so he can decide that despite the fact that the hostgroup contains info about a facet, that facet won't be created automatically.