On 04/04/2012 11:48 AM, Tomas Lestach wrote:
An elaborator is an additional query, that fetches additional information from
the DB for a DTO object (may have additional parameters). It's always run with
a main query. It may be associated only with those queries, where the
additional information is needed. Let's say you would need the errata keywords
only for some ErrataOverview queries. (The other queries shall not be slowed
down by fetching information, that isn't needed.)
Check the errata_cves_elab elaborator in Errata_queries.xml. I'd suggest to
introduce a similar one for the keywords. Then check SecurityErrataOverview
class to see, how the CVEs get added to the ErrataOverview dto. Add the
keywords to the ErrataOverview in the same way. At least a simple method
similar to the ErrataOverview.isProductEnhancement is needed, that determins
reboot need on the fly.
Thanks for the suggestions. I am implementing the feature in 4 parts:
a) showing an icon next to a patch that needs reboot
b) a list System -> Requiring Reboot (to be used with System Set Manager)
c) a yellow sign on the system page "This system requires a reboot [link
to schedule reboot]"
d) something in the main overview, may be in most critical systems, but
I don't want to add another column.
While fetching the Errata keywords seemed like a good idea, that was
then I was implementing only (a). When implementing (b) and (c) I need
to get a list of systems as well, so I have:
<query name="requiring_reboot_list" params="org_id, user_id">
SELECT S.id, S.NAME,
(SELECT 1
FROM rhnServerFeaturesView SFV
WHERE SFV.server_id = S.id
AND SFV.label = 'ftr_system_grouping') AS selectable
FROM rhnServerInfo SI,
rhnServer S,
rhnActionErrataUpdate EA,
rhnServerAction SA,
rhnErrata E
WHERE S.org_id = :org_id
AND EXISTS (SELECT 1 FROM rhnUserServerPerms USP WHERE USP.user_id =
:user_id AND USP.server_id = S.id)
AND SI.server_id = S.id
AND S.id = SA.server_id
AND SA.action_id = EA.action_id
AND EA.errata_id = E.id
AND to_timestamp(S.last_boot) < SA.completion_time
AND E.id IN (SELECT EK.errata_id FROM rhnErrataKeyword EK WHERE
EK.keyword = 'reboot_suggested')
ORDER BY SI.checkin DESC
</query>
<mode name="requiring_reboot"
class="com.redhat.rhn.frontend.dto.SystemOverview">
<query name="requiring_reboot_list"/>
<elaborator name="system_overview" />
<elaborator name="entitlements" />
<elaborator name="is_virtual_guest" />
<elaborator name="is_virtual_host" />
</mode>
<mode name="requires_reboot">
<query name="requiring_reboot_list"/>
<elaborator params="sid">
SELECT 1 FROM rhnServer S WHERE S.id IN (%s) AND S.id=:sid
</elaborator>
</mode>
The last one is just a bool to check if one system requires reboot, but
the main query is reused for the list and this bool check.
If I implement this at the Java level, by fetching the keywords, I would
not be able to reuse the queries "Give me the systems who had this kind
of errata applied", but still because limitations in the framework, I
don't seem to be able to refactor requiring_reboot_list into a list of
erratas plus a elaborator that fetches the systems with those erratas,
because they would be in different files.
So I am kind of stuck with (a) and (d) with both solutions now :-) (but
I have (b) and (c) working with the solution explained above)
Duncan
_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel