On 04/11/2012 11:00 AM, Tomas Lestach wrote:
This is ok, because it's not used in the elaborator. Regards,
Ok, here is a patch for review for the first part: adding a list of
systems that need review, and showing a notification in the system
detail that it needs reboot with a link to the action.
Screenshots:
http://imgur.com/z8Y9u
http://imgur.com/oLE4H
I am still missing something. In the query I am doing:
AND EA.errata_id = E.id
AND to_timestamp(S.last_boot) < SA.completion_time
This to_timestamp() only works (with those types) in Postgres. The
problem is that both attributes have different types: numeric &
timestamp in Postgres, numeric & date in oracle. But Oracle's
to_timestamp takes a char. Any ideas how to make this query work across
both? I hope a PL/SQL is not the the path :-/
Duncan
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 a6cbc2b..67673d0 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,43 @@ 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" params="org_id, user_id, keyword">
+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 = :keyword)
+ ORDER BY SI.checkin DESC
+</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"/>
+ <elaborator name="system_overview" />
+ <elaborator name="entitlements" />
+ <elaborator name="is_virtual_guest" />
+ <elaborator name="is_virtual_host" />
+</mode>
+
+<mode name="has_errata_with_keyword_applied_since_last_reboot">
+ <query name="having_errata_with_keyword_applied_since_last_reboot"/>
+ <elaborator params="sid">
+ SELECT 1 FROM rhnServer S WHERE S.id IN (%s) AND S.id=:sid
+ </elaborator>
+</mode>
+
<mode name="inactive" class="com.redhat.rhn.frontend.dto.SystemOverview">
<query params="org_id, user_id, checkin_threshold">
SELECT S.id, S.NAME,
diff --git a/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemOverviewAction.java b/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemOverviewAction.java
index 8b22bc0..c28c921 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemOverviewAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemOverviewAction.java
@@ -59,6 +59,7 @@ public class SystemOverviewAction extends RhnAction {
.RECEIVE_NOTIFICATIONS};
/** {@inheritDoc} */
+ @Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
RequestContext rctx = new RequestContext(request);
@@ -106,6 +107,9 @@ public class SystemOverviewAction extends RhnAction {
boolean hasUpdates =
criticalErrataCount + nonCriticalErrataCount + upgradablePackagesCount > 0;
+ // Reboot needed after certain types of updates
+ boolean rebootRequired = SystemManager.requiresReboot(user, sid);
+
// Monitoring
processRequestForMonitoring(user, s, request);
@@ -118,6 +122,7 @@ public class SystemOverviewAction extends RhnAction {
SdcHelper.ssmCheck(request, sid, user);
+ request.setAttribute("rebootRequired", Boolean.valueOf(rebootRequired));
request.setAttribute("unentitled", Boolean.valueOf(s.getEntitlements().isEmpty()));
request.setAttribute("systemInactive", Boolean.valueOf(s.isInactive()));
request.setAttribute("documentation", ConfigDefaults.get().isDocAvailable());
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index 08db82c..d5f2977 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -5070,6 +5070,13 @@ value for this entitlement, excluding the default organization's consumption.</s
</context-group>
</trans-unit>
+ <trans-unit id="requiringrebootlist.jsp.header">
+ <source>Systems requiring reboot</source>
+ <context-group name="ctx">
+ <context context-type="sourcefile">/rhn/systems/RequiringReboot</context>
+ <context context-type="sourcefile">/rhn/systems/YourRhn.do</context>
+ </context-group>
+ </trans-unit>
<trans-unit id="inactivelist.jsp.header">
<source>Inactive Systems</source>
@@ -17558,6 +17565,13 @@ The Tree Path, Base Channel, and Installer Generation should always match. This
</context-group>
</trans-unit>
+ <trans-unit id="sdc.details.overview.requires_reboot">
+ <source>The system requires a reboot</source>
+ <context-group name="ctx">
+ <context context-type="sourcefile">/systems/details/Overview.do</context>
+ </context-group>
+ </trans-unit>
+
<trans-unit id="sdc.details.overview.inactive1">
<source><strong>System not checking in with @@PRODUCT_NAME@@</strong></source>
<context-group name="ctx">
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/nav/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/nav/StringResource_en_US.xml
index c787d8c..6aec426 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/nav/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/nav/StringResource_en_US.xml
@@ -111,6 +111,12 @@ http://www.oasis-open.org/committees/xliff/documents/xliff-core-1.1.xsd"
<context context-type="sourcefile">Systems Navigation Menu</context>
</context-group>
</trans-unit>
+ <trans-unit id="Requiring Reboot">
+ <source>Requiring Reboot</source>
+ <context-group name="ctx">
+ <context context-type="sourcefile">Systems Navigation Menu</context>
+ </context-group>
+ </trans-unit>
<trans-unit id="duplicate.systems.nav.ips">
<source>Duplicate IP Address</source>
diff --git a/java/code/src/com/redhat/rhn/manager/system/SystemManager.java b/java/code/src/com/redhat/rhn/manager/system/SystemManager.java
index 0caad8a..bcc21a3 100644
--- a/java/code/src/com/redhat/rhn/manager/system/SystemManager.java
+++ b/java/code/src/com/redhat/rhn/manager/system/SystemManager.java
@@ -31,8 +31,8 @@ import com.redhat.rhn.common.validator.ValidatorError;
import com.redhat.rhn.common.validator.ValidatorResult;
import com.redhat.rhn.common.validator.ValidatorWarning;
import com.redhat.rhn.domain.channel.Channel;
-import com.redhat.rhn.domain.channel.ClonedChannel;
import com.redhat.rhn.domain.channel.ChannelFamily;
+import com.redhat.rhn.domain.channel.ClonedChannel;
import com.redhat.rhn.domain.entitlement.Entitlement;
import com.redhat.rhn.domain.entitlement.VirtualizationEntitlement;
import com.redhat.rhn.domain.errata.Errata;
@@ -75,6 +75,7 @@ import org.apache.commons.lang.BooleanUtils;
import org.apache.log4j.Logger;
import org.hibernate.Session;
+import java.net.IDN;
import java.sql.Date;
import java.sql.Types;
import java.text.DateFormat;
@@ -86,17 +87,17 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.ListIterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import java.net.IDN;
/**
* SystemManager
+ *
* @version $Rev$
*/
public class SystemManager extends BaseManager {
@@ -196,10 +197,53 @@ public class SystemManager extends BaseManager {
return m.execute(params);
}
+ /**
+ * @param user
+ * Currently logged in user.
+ * @param sid
+ * System id
+ * @return true if the system requires a reboot i.e: because kernel updates.
+ */
+ public static boolean requiresReboot(User user, Long sid) {
+ SelectMode m = ModeFactory.getMode("System_queries",
+ "has_errata_with_keyword_applied_since_last_reboot");
+ Map params = new HashMap();
+ params.put("user_id", user.getId());
+ params.put("org_id", user.getOrg().getId());
+ params.put("sid", sid);
+ params.put("keyword", "reboot_suggested");
+ DataResult dr = m.execute(params);
+ return !dr.isEmpty();
+ }
+
+ /**
+ * Returns list of systems requiring a reboot i.e: because kernel updates,
+ * visible to user, sorted by name.
+ *
+ * @param user
+ * Currently logged in user.
+ * @param pc
+ * PageControl
+ * @return list of SystemOverviews.
+ */
+ public static DataResult<SystemOverview> requiringRebootList(User user,
+ PageControl pc) {
+ SelectMode m = ModeFactory
+.getMode("System_queries",
+ "having_errata_with_keyword_applied_since_last_reboot");
+ Map<String, Object> params = new HashMap<String, Object>();
+ params.put("org_id", user.getOrg().getId());
+ params.put("user_id", user.getId());
+ params.put("keyword", "reboot_suggested");
+ Map<String, Object> elabParams = new HashMap<String, Object>();
+ return makeDataResult(params, elabParams, pc, m);
+ }
/**
* Gets the latest upgradable packages for a system
- * @param sid The id for the system we want packages for
+ *
+ * @param sid
+ * The id for the system we want packages for
* @return Returns a list of the latest upgradable packages for a system
*/
public static DataResult latestUpgradablePackages(Long sid) {
diff --git a/java/code/webapp/WEB-INF/nav/sitenav-authenticated.xml b/java/code/webapp/WEB-INF/nav/sitenav-authenticated.xml
index 1228394..f6547d7 100644
--- a/java/code/webapp/WEB-INF/nav/sitenav-authenticated.xml
+++ b/java/code/webapp/WEB-INF/nav/sitenav-authenticated.xml
@@ -41,6 +41,7 @@
<rhn-tab name="All" url="/rhn/systems/SystemList.do"/>
<rhn-tab name="Virtual Systems" url="/rhn/systems/VirtualSystemsList.do"/>
<rhn-tab name="Out of Date" url="/rhn/systems/OutOfDate.do"/>
+ <rhn-tab name="Requiring Reboot" url="/rhn/systems/RequiringReboot.do"/>
<rhn-tab name="Unentitled" url="/rhn/systems/Unentitled.do"/>
<rhn-tab name="Ungrouped" url="/rhn/systems/Ungrouped.do" acl="org_entitlement(sw_mgr_enterprise); user_role(org_admin)"/>
<rhn-tab name="Inactive" url="/rhn/systems/Inactive.do"/>
diff --git a/java/code/webapp/WEB-INF/pages/systems/sdc/overview.jsp b/java/code/webapp/WEB-INF/pages/systems/sdc/overview.jsp
index 3083109..b1a8fb9 100644
--- a/java/code/webapp/WEB-INF/pages/systems/sdc/overview.jsp
+++ b/java/code/webapp/WEB-INF/pages/systems/sdc/overview.jsp
@@ -22,7 +22,10 @@
<bean:message key="sdc.details.overview.inactive2" arg0="/rhn/help/reference/en-US/s1-sm-systems.jsp#s2-sm-system-list"/>
</c:if>
</c:when>
-
+ <c:when test="${rebootRequired}">
+ <img src="/img/restart.png"/><bean:message key="sdc.details.overview.requires_reboot"/>
+ <bean:message key="sdc.details.overview.schedulereboot" arg0="/network/systems/details/reboot_confirm.pxt?sid=${system.id}"/>
+ </c:when>
<c:when test="${hasUpdates}">
<c:choose>
<c:when test="${criticalErrataCount > 0}">
diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml
index 5434c4e..03b4018 100644
--- a/java/code/webapp/WEB-INF/struts-config.xml
+++ b/java/code/webapp/WEB-INF/struts-config.xml
@@ -2709,6 +2709,16 @@
path="/WEB-INF/pages/systems/inactivelist.jsp"/>
</action>
+ <action path="/systems/RequiringReboot"
+ scope="request"
+ input="/WEB-INF/pages/systems/requiringreboot.jsp"
+ type="com.redhat.rhn.frontend.action.systems.RequiringRebootSetupAction"
+ className="com.redhat.rhn.frontend.struts.RhnActionMapping">
+ <set-property property="postRequiredIfSubmitted" value="true" />
+ <forward name="default"
+ path="/WEB-INF/pages/systems/requiringrebootlist.jsp"/>
+ </action>
+
<action path="/systems/Registered"
scope="request"
name="recentlyRegisteredSystemsForm"
_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel