Refactor #16987

Explicit building of facets

Added by Lukas Zapletal about 1 year ago. Updated about 1 year ago.

Status:Closed
Priority:Normal
Assigned To:Shimon Shtein
Category:Plugins-Engines
Target version:-
Difficulty: Bugzilla link:
Found in release: Pull request:https://github.com/theforeman/foreman/pull/3987
Story points-
Velocity based estimate-
Release1.14.0Release relationshipAuto

Description

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


Related issues

Related to Katello - Bug #16063: Autoprovisioning fails with Katello plugin installed Closed 08/11/2016
Related to Foreman - Refactor #17439: Refactor facet base class to a concern. Closed 11/22/2016
Copied to Katello - Refactor #17869: Explicit building of facets Closed 10/18/2016

Associated revisions

Revision 86f7f4f5
Added by Shimon Shtein about 1 year ago

Fixes #16987 - Added ability to apply facet attributes

Revision f26b3127
Added by Shimon Shtein about 1 year ago

Fixes #16987 - Added ability to apply facet attributes

(cherry picked from commit 86f7f4f58a08488c0ea7d3e06c71eaba2be71d57)

History

#1 Updated by Lukas Zapletal about 1 year ago

  • Related to Bug #16063: Autoprovisioning fails with Katello plugin installed added

#2 Updated by Lukas Zapletal about 1 year ago

Fore more info visit https://github.com/Katello/katello/pull/6401

Shimon, I assigned to you if you don't mind.

This is not refactoring, but rather extending the code (bad wording).

#3 Updated by Shimon Shtein about 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.

#4 Updated by The Foreman Bot about 1 year ago

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

#5 Updated by Shimon Shtein about 1 year ago

  • Related to Refactor #17439: Refactor facet base class to a concern. added

#6 Updated by Shimon Shtein about 1 year ago

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

#7 Updated by Dominic Cleal about 1 year ago

  • Release set to 1.14.0

#8 Updated by Justin Sherrill 12 months ago

Also available in: Atom PDF