On 02/27/2014 02:51 PM, Dan Callaghan wrote:
Excerpts from Nick Coghlan's message of 2014-02-27 14:29:23
+1000:
> Sort of - the template conditions in some cases currently look like:
> "distro is osmajor('RedHatEnterpriseLinux7')".
Yes that is a Jinja filter, shorthand for:
distro.osversion.osmajor.osmajor == 'RedHatEnterpriseLinux7'
The important thing is that we are talking about (at the database level)
a new relationship from OSMajor to OSMajor.
How we expose it in the templates is less important, although I would be
inclined to expose the actual OSMajor instance (rather than its name)
just for consistency. In fact we needn't expose it as a new variable at
all, it would be reachable from the distro variable just as the ordinary
OSMajor currently is.
So instead of distro.osversion.osmajor it becomes
distro.osversion.osmajor.base_osmajor. We could even encapsulate that in
the existing 'osmajor' Jinja filter so that the current template
conditions that use "distro is osmajor()" remain unchanged. This way
users don't have to update their custom snippets to obey base_osmajor.
Or if that is too magical it could be a separate Jinja filter,
based_on_osmajor:
distro is based_on_osmajor('RedHatEnterpriseLinux7')
It couldn't be "is" due to the 1->many relationship involved, but yeah,
a custom filter makes sense.
RFE filed at
https://bugzilla.redhat.com/show_bug.cgi?id=1070597
Cheers,
Nick.
--
Nick Coghlan
Red Hat Hosted & Shared Services
Software Engineering & Development, Brisbane
Testing Solutions Team Lead
Beaker Development Lead (
http://beaker-project.org/)