Re: [Spacewalk-devel] [PATCH] Show systems that need reboot because of an errata

2012-04-19 Thread Michael Calmer
Hi,

Am Mittwoch, 18. April 2012, 15:00:01 schrieb Tomas Lestach:
  Attached patch, rebased against master. It contains all suggestions and
  fixed some formatting issues not relevant to the patch. Additionally
  changed to_timestamp() to something that works in both databases.
  
  Duncan
 
 Thanks Duncan,
 
 I committed your patch as: 433bd3a310f38577ff3066414a2f035e4c310e47

It seems that one query is not able to run on oracle and on postgres
it does not do what it should :-)

A possible fix is attached.

-- 
Regards

Michael Calmer

--
Michael Calmer
SUSE LINUX Products GmbH, Maxfeldstr. 5, D-90409 Nuernberg
T: +49 (0) 911 74053 0
F: +49 (0) 911 74053575  - e-mail: michael.cal...@suse.com
--
SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer
HRB 16746 (AG Nürnberg)
From dfb7e3e922eee62b615ba1c1294560e85341dd78 Mon Sep 17 00:00:00 2001
From: Michael Calmer m...@suse.de
Date: Thu, 19 Apr 2012 11:47:24 +0200
Subject: [PATCH] fix has_errata_with_keyword_applied_since_last_reboot query

Fixes:
com.redhat.rhn.common.db.WrappedSQLException: ORA-00936: missing expression
---
 .../common/db/datasource/xml/System_queries.xml|2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml b/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
index ace71cb..c05c98f 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
@@ -790,7 +790,6 @@ SELECT DISTINCT S.id, S.NAME,
 
 mode name=has_errata_with_keyword_applied_since_last_reboot
   query params=org_id, user_id, keyword, sid
-  SELECT EXISTS (
 	SELECT 1
 	FROM rhnServer S,
 	  rhnErrata E,
@@ -808,7 +807,6 @@ SELECT DISTINCT S.id, S.NAME,
 	  AND EP.errata_id = E.id AND EP.package_id = P.id
 	  AND (to_date('1970-01-01', '-MM-DD') + numtodsinterval(S.last_boot, 'second')) lt; SP.installtime
 	  AND E.id IN (SELECT EK.errata_id FROM rhnErrataKeyword EK WHERE EK.keyword = :keyword)
-)
 /query
 /mode
 
-- 
1.7.3.4

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Re: [Spacewalk-devel] [PATCH] Show systems that need reboot because of an errata

2012-04-19 Thread Tomas Lestach
On Thursday 19 of April 2012 11:51:21 Michael Calmer wrote:
 Hi,
 
 Am Mittwoch, 18. April 2012, 15:00:01 schrieb Tomas Lestach:
   Attached patch, rebased against master. It contains all suggestions and
   fixed some formatting issues not relevant to the patch. Additionally
   changed to_timestamp() to something that works in both databases.
   
   Duncan
  
  Thanks Duncan,
  
  I committed your patch as: 433bd3a310f38577ff3066414a2f035e4c310e47
 
 It seems that one query is not able to run on oracle and on postgres
 it does not do what it should :-)
 
 A possible fix is attached.

Thanks Michael!

Your fix resolves the exception.
I commited your patch as: 389ee5d29b993be189921407a6c422a5a64af6d9


Best Regards,
Tomas
-- 
Tomas Lestach
RHN Satellite Engineering

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel


Re: [Spacewalk-devel] [PATCH] Show systems that need reboot because of an errata

2012-04-18 Thread Tomas Lestach
 Attached patch, rebased against master. It contains all suggestions and
 fixed some formatting issues not relevant to the patch. Additionally
 changed to_timestamp() to something that works in both databases.
 
 Duncan

Thanks Duncan,

I committed your patch as: 433bd3a310f38577ff3066414a2f035e4c310e47

:-)
Regards,
Tomas
-- 
Tomas Lestach
RHN Satellite Engineering

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel


[Spacewalk-devel] [PATCH] Show systems that need reboot because of an errata

2012-04-17 Thread Duncan Mac-Vicar P.

On 04/16/2012 11:25 AM, Tomas Lestach wrote:

On Friday 13 of April 2012 17:28:05 Duncan Mac-Vicar P. wrote:

On 04/13/2012 02:30 PM, Tomas Lestach wrote:

A separate query for a single system would definitelly be more efficient.

Looking at what you pointed out in IRC: what happens if the errata is
applied on the client side. So I modified them to look at the package
install time instead:

For the system list:

SELECT DISTINCT S.id, S.NAME,
 (SELECT 1
FROM rhnServerFeaturesView SFV
   WHERE SFV.server_id = S.id
 AND SFV.label = 'ftr_system_grouping') AS selectable
FROM rhnServer S,
 rhnErrata E,
 rhnServerInfo SI,
 rhnServerPackage SP,
 rhnPackage P,
 rhnActionErrataUpdate EA,
 rhnServerAction SA,
 rhnErrataPackage EP,
 rhnPackageName PN
   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 SP.server_id = S.id
 AND P.evr_id = SP.evr_id
 AND P.name_id = SP.name_id
 AND EA.errata_id = E.id
 AND SA.action_id = EA.action_id AND SA.server_id = S.id
 AND EP.errata_id = E.id AND EP.package_id = P.id
 AND (to_timestamp(S.last_boot)  SP.installtime)
 AND E.id IN (SELECT EK.errata_id FROM rhnErrataKeyword EK WHERE
EK.keyword = :keyword)
 AND PN.id = P.name_id

Duncan,
if an erratum package is installed on the client side using yum, you
definitelly won't have any entry in the
rhnServerAction/rhnAction/rhnActionErrataUpdate tables. I would omit them from
the select.
Basicly you need only (user) servers having any errata packages installed
after the latest reboot, where the appropriate erratum has the need_reboot
flag. (no 'Actions' in the sentence)

I'm not sure, why you join also the rhnPackageName, if you do not really use
it.

Sorry for wasting your time. I pasted directly from the pgadmin3 console.

Attached patch, rebased against master. It contains all suggestions and 
fixed some formatting issues not relevant to the patch. Additionally 
changed to_timestamp() to something that works in both databases.


Duncan


From 34b8bea2ad8e64a4b9c5359d21ad6d0d480f054f Mon Sep 17 00:00:00 2001
From: Duncan Mac-Vicar P dmacvi...@suse.de
Date: Tue, 17 Apr 2012 15:31:06 +0200
Subject: [PATCH] Show systems that need reboot because of an errata.

---
 .../common/db/datasource/xml/System_queries.xml|   55 
 .../action/systems/RequiringRebootSetupAction.java |   37 +
 .../action/systems/sdc/SystemOverviewAction.java   |5 ++
 .../frontend/strings/jsp/StringResource_en_US.xml  |   14 +
 .../frontend/strings/nav/StringResource_en_US.xml  |6 ++
 .../redhat/rhn/manager/system/SystemManager.java   |   40 ++
 .../webapp/WEB-INF/nav/sitenav-authenticated.xml   |1 +
 .../WEB-INF/pages/systems/requiringrebootlist.jsp  |   25 +
 .../webapp/WEB-INF/pages/systems/sdc/overview.jsp  |5 ++-
 java/code/webapp/WEB-INF/struts-config.xml |   10 
 10 files changed, 197 insertions(+), 1 deletions(-)
 create mode 100644 java/code/src/com/redhat/rhn/frontend/action/systems/RequiringRebootSetupAction.java
 create mode 100644 java/code/webapp/WEB-INF/pages/systems/requiringrebootlist.jsp

diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml b/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
index cdb0cc5..64560e0 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
@@ -757,6 +757,61 @@ ORDER BY  UPPER(COALESCE(S.NAME, '(none)')), S.ID
   elaborator name=is_virtual_host /
 /mode
 
+query name=having_errata_with_keyword_applied_since_last_reboot_list params=org_id, user_id, keyword
+SELECT DISTINCT S.id, S.NAME,
+   (SELECT 1
+  FROM rhnServerFeaturesView SFV
+ WHERE SFV.server_id = S.id
+   AND SFV.label = 'ftr_system_grouping') AS selectable
+  FROM rhnServer S,
+   rhnErrata E,
+   rhnServerInfo SI,
+   rhnServerPackage SP,
+   rhnPackage P,
+   rhnErrataPackage EP
+ 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 SP.server_id = S.id
+   AND P.evr_id = SP.evr_id
+   AND P.name_id = SP.name_id
+   AND EP.errata_id = E.id AND EP.package_id = P.id
+   AND (to_date('1970-01-01', '-MM-DD') + numtodsinterval(S.last_boot, 'second')) lt; SP.installtime
+   AND E.id IN (SELECT EK.errata_id FROM rhnErrataKeyword EK WHERE EK.keyword = :keyword)
+/query
+
+mode name=having_errata_with_keyword_applied_since_last_reboot class=com.redhat.rhn.frontend.dto.SystemOverview
+  query name=having_errata_with_keyword_applied_since_last_reboot_list/
+  elaborator name=system_overview /
+