[katello-devel] Custom callbacks for optional backend services
Justin Sherrill
jsherril at redhat.com
Tue Oct 16 15:13:39 UTC 2012
While we are working on the pulpv2 stuff, we are breaking apart our
models a bit more and trying separate duties out more. As part of this
we should expect models to be able to operate on their own when backend
services are disabled (even if they dont' do a whole lot).
One such example where this breaks is in Systems and System Groups:
https://github.com/jlsherrill/katello/blob/pulpv2/src/app/models/system_group.rb#L24
You can see here that we've broken up System even more, splitting out
the elastic search code and authorization (in addition to the glue
modules). That specific line though will not function properly without
Pulp and Elastic search being present. You will get an error trying to
add a system to a system group because "add_pulp_consumer_group" will
have not been defined. Since SAM is talking about adding system this
will become more of a problem.
An interesting solution would be to use custom callbacks:
http://www.intridea.com/blog/2012/3/22/define-custom-callbacks-for-activerecord-and-more#
So we could define our own events that get triggered (for example
'before_system_group_added') and pulp glue layer could simply define a
trigger on that callback. In the SAM case that trigger'd method would
never be defined, so it could go on its way happily.
Thoughts?
-Justin
More information about the katello-devel
mailing list