java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemRebootAction.java | 88
++++++++++
java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml | 24
++
java/code/webapp/WEB-INF/nav/system_detail.xml | 2
java/code/webapp/WEB-INF/pages/systems/sdc/overview.jsp | 4
java/code/webapp/WEB-INF/pages/systems/sdc/rebootsystem.jsp | 52
+++++
java/code/webapp/WEB-INF/struts-config.xml | 13
+
web/html/network/systems/details/reboot_confirm.pxt | 39
----
web/include/nav/system_detail.xml | 2
web/modules/rhn/RHN/DB/Scheduler.pm | 22
--
web/modules/sniglets/Sniglets/Servers.pm | 26
--
10 files changed, 181 insertions(+), 91 deletions(-)
New commits:
commit 6a11236104d95e085c676f522f73ec2858b52e12
Author: Michael Calmer <mc(a)suse.de>
Date: Thu Jan 16 17:20:53 2014 +0100
remove unused perl code after porting reboot_confirm.pxt to java
diff --git a/web/html/network/systems/details/reboot_confirm.pxt
b/web/html/network/systems/details/reboot_confirm.pxt
deleted file mode 100644
index 898ff1f..0000000
--- a/web/html/network/systems/details/reboot_confirm.pxt
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf8"?>
-<pxt-passthrough>
-
-<pxt-use class="Grail::Frame" />
-<pxt-use class="Sniglets::Servers" />
-<pxt-use class="Sniglets::Sets" />
-<pxt-use class="Sniglets::HTML" />
-<pxt-use class="Sniglets::ServerActions" />
-
-
-<grail-canvas-template base="/templates/c.pxt"
mode="main_canvas">
-<pxt-formvar>
- <pxt-include-late
file="/network/components/systems/system_details_toolbar.pxi" />
-</pxt-formvar>
-
- <rhn-navi-nav prefix="system_details"
file="/nav/system_detail.xml" style="contentnav" />
-
-<pxt-include-late file="/network/components/message_queues/local.pxi" />
-
-<rhn-up2date-at-least version="2.9.3" release="2.2.1AS">
-
-<h2>System Reboot Confirmation</h2>
-
-<p>This will schedule a reboot of this system.</p>
-
-
-<pxt-form method="post">
-<p>If you are <strong>certain</strong> you wish to do this, you may
schedule the reboot to take place as soon as possible, or no earlier than a specified
time:</p>
-
-<rhn-schedule-action-interface action="schedule_errata_updates"
callback="rhn:reboot_server_cb" label="Schedule Reboot" />
-
-<pxt-hidden name="sid" />
-
-</pxt-form>
-
-</rhn-up2date-at-least>
-
-</grail-canvas-template>
-</pxt-passthrough>
diff --git a/web/modules/rhn/RHN/DB/Scheduler.pm b/web/modules/rhn/RHN/DB/Scheduler.pm
index a23043f..cf190db 100644
--- a/web/modules/rhn/RHN/DB/Scheduler.pm
+++ b/web/modules/rhn/RHN/DB/Scheduler.pm
@@ -175,28 +175,6 @@ EOQ
}
}
-
-sub schedule_reboot {
- my $class = shift;
- my %params = @_;
-
- my ($org_id, $user_id, $server_set, $server_id, $earliest, $prerequisite, $transaction)
=
- map { $params{"-" . $_} } qw/org_id user_id server_set server_id earliest
prerequisite transaction/;
-
- my ($action_id, $stat_id) = $class->make_base_action(-org_id => $org_id,
- -user_id => $user_id,
- -type_label => 'reboot.reboot',
- -earliest => $earliest,
- -prerequisite => $prerequisite,
- -transaction => $transaction);
-
- $class->add_servers_to_action($action_id, $stat_id, $user_id, $server_set,
$server_id);
-
- osa_wakeup_tickle();
-
- return $action_id;
-}
-
sub sscd_schedule_reboot {
my $class = shift;
my %params = @_;
diff --git a/web/modules/sniglets/Sniglets/Servers.pm
b/web/modules/sniglets/Sniglets/Servers.pm
index 792dd3d..13a03e3 100644
--- a/web/modules/sniglets/Sniglets/Servers.pm
+++ b/web/modules/sniglets/Sniglets/Servers.pm
@@ -71,8 +71,6 @@ sub register_callbacks {
my $class = shift;
my $pxt = shift;
- $pxt->register_callback('rhn:reboot_server_cb' =>
\&reboot_server_cb);
-
$pxt->register_callback('rhn:server_prefs_form_cb' =>
\&server_prefs_form_cb);
$pxt->register_callback('rhn:ssm_change_system_prefs_cb' =>
\&ssm_change_system_prefs_cb);
@@ -313,30 +311,6 @@ sub server_history_event_details {
return $params{__block__};
}
-sub reboot_server_cb {
- my $pxt = shift;
- my $sid = $pxt->param('sid');
- die "no server id" unless $sid;
-
- my $server = RHN::Server->lookup(-id => $sid);
- die "no server obj" unless $server;
-
- my $earliest_date = Sniglets::ServerActions->parse_date_pickbox($pxt);
- my $action_id = RHN::Scheduler->schedule_reboot(-org_id =>
$pxt->user->org_id,
- -user_id => $pxt->user->id,
- -earliest => $earliest_date,
- -server_id => $sid);
-
-
- my $pretty_earliest_date = $pxt->user->convert_time($earliest_date);
-# my $message = sprintf(<<EOM, $server->name, $server->name, $action_id);
-#Reboot scheduled for system <strong>%s</strong> for $pretty_earliest_date.
To cancel the reboot, remove <strong>%s</strong> from <a
href="/rhn/schedule/InProgressSystems.do?aid=%d"><strong>the list of
systems to be rebooted</strong></a>.
-#EOM
-#
-# $pxt->push_message(site_info => $message);
-
$pxt->redirect("/rhn/systems/details/Overview.do?sid=$sid&message=system.reboot.scheduled&messagep1="
. $server->name . "&messagep2=" . $pretty_earliest_date .
"&messagep3=" . $action_id);
-}
-
my @user_server_prefs = ( { name => 'receive_notifications',
label => 'Receive Notifications of Updates/Errata' },
{ name => 'include_in_daily_summary',
commit c98ed65274570d849a93c732b9082a353c4c861f
Author: Michael Calmer <mc(a)suse.de>
Date: Thu Jan 16 14:08:11 2014 +0100
port reboot_confirm.pxt from perl to java
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemRebootAction.java
b/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemRebootAction.java
new file mode 100644
index 0000000..5e4c998
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemRebootAction.java
@@ -0,0 +1,88 @@
+/**
+ * Copyright (c) 2014 SUSE
+ *
+ * This software is licensed to you under the GNU General Public License,
+ * version 2 (GPLv2). There is NO WARRANTY for this software, express or
+ * implied, including the implied warranties of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+ * along with this software; if not, see
+ *
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * Red Hat trademarks are not licensed under GPLv2. No permission is
+ * granted to use or replicate Red Hat trademarks that are incorporated
+ * in this software or its documentation.
+ */
+package com.redhat.rhn.frontend.action.systems.sdc;
+
+import com.redhat.rhn.common.util.DatePicker;
+import com.redhat.rhn.domain.action.Action;
+import com.redhat.rhn.domain.action.ActionFactory;
+import com.redhat.rhn.domain.server.Server;
+import com.redhat.rhn.domain.user.User;
+import com.redhat.rhn.frontend.struts.RequestContext;
+import com.redhat.rhn.frontend.struts.RhnAction;
+import com.redhat.rhn.frontend.struts.RhnHelper;
+import com.redhat.rhn.manager.action.ActionManager;
+import com.redhat.rhn.manager.system.SystemManager;
+
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.DynaActionForm;
+
+import java.util.Date;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * SystemRebootAction handles the interaction of the system reboot.
+ */
+public class SystemRebootAction extends RhnAction {
+ /** Success forward name. */
+ private static final String CONFIRM_FORWARD = "confirm";
+
+ /** {@inheritDoc} */
+ @Override
+ @SuppressWarnings("unchecked")
+ public ActionForward execute(ActionMapping mapping, ActionForm formIn,
+ HttpServletRequest request, HttpServletResponse response) {
+
+ DynaActionForm form = (DynaActionForm) formIn;
+ RequestContext context = new RequestContext(request);
+ User user = context.getLoggedInUser();
+ Map<String, Object> params = (Map<String, Object>)
makeParamMap(request);
+ String forward = RhnHelper.DEFAULT_FORWARD;
+
+ Long sid = context.getRequiredParam(RequestContext.SID);
+ Server server = SystemManager.lookupByIdAndUser(sid, user);
+
+ if (isSubmitted(form)) {
+ Date earliest = getStrutsDelegate().readDatePicker((DynaActionForm) formIn,
+ "date", DatePicker.YEAR_RANGE_POSITIVE);
+ Action action = ActionManager.scheduleRebootAction(user, server, earliest);
+ ActionFactory.save(action);
+
+ String[] messageParams = new String[3];
+ messageParams[0] = server.getName();
+ messageParams[1] = earliest.toString();
+ messageParams[2] = action.getId().toString();
+ createMessage(request, "system.reboot.scheduled", messageParams);
+
+ // goes to sdc/overview.jsp
+ params.put(RequestContext.SID, sid);
+ forward = CONFIRM_FORWARD;
+ }
+
+ DatePicker picker = getStrutsDelegate().prepopulateDatePicker(request, form,
+ "date", DatePicker.YEAR_RANGE_POSITIVE);
+ request.setAttribute("date", picker);
+ request.setAttribute(RequestContext.SID, sid);
+ request.setAttribute("system", server);
+
+ SdcHelper.ssmCheck(request, server.getId(), user);
+
+ return getStrutsDelegate().forwardParams(mapping.findForward(forward), params);
+ }
+}
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 c4cdf75..62ec065 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
@@ -5130,6 +5130,30 @@ value for this entitlement, excluding the default
organization's consumption.</s
<context
context-type="sourcefile">/rhn/systems/SystemGroupList</context>
</context-group>
</trans-unit>
+ <trans-unit id="reboot.jsp.header">
+ <source>System Reboot Confirmation</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/systems/details/RebootSystem</context>
+ </context-group>
+ </trans-unit>
+ <trans-unit id="reboot.jsp.summary">
+ <source>This will schedule a reboot of this system.</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/systems/details/RebootSystem</context>
+ </context-group>
+ </trans-unit>
+ <trans-unit id="reboot.jsp.widgetsummary">
+ <source>If you are <strong>certain</strong> you
wish to do this, you may schedule the reboot to take place after a specified
time:</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/systems/details/RebootSystem</context>
+ </context-group>
+ </trans-unit>
+ <trans-unit id="reboot.jsp.confirm">
+ <source>Reboot system</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/systems/details/RebootSystem</context>
+ </context-group>
+ </trans-unit>
<!--- System Duplicates pages -->
<group>
<context-group name="ctx">
diff --git a/java/code/webapp/WEB-INF/nav/system_detail.xml
b/java/code/webapp/WEB-INF/nav/system_detail.xml
index 6c20453..5261dec 100644
--- a/java/code/webapp/WEB-INF/nav/system_detail.xml
+++ b/java/code/webapp/WEB-INF/nav/system_detail.xml
@@ -4,7 +4,7 @@
<rhn-tab name="Details"
url="/rhn/systems/details/Overview.do">
<rhn-tab name="Overview">
<rhn-tab-url>/rhn/systems/details/Overview.do</rhn-tab-url>
- <rhn-tab-url>/network/systems/details/reboot_confirm.pxt</rhn-tab-url>
+ <rhn-tab-url>/rhn/systems/details/RebootSystem.do</rhn-tab-url>
</rhn-tab>
<rhn-tab name="Properties" url="/rhn/systems/details/Edit.do"
/>
<rhn-tab name="Remote Command"
acl="system_feature(ftr_remote_command)">
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 ce473c4..0dc87b4 100644
--- a/java/code/webapp/WEB-INF/pages/systems/sdc/overview.jsp
+++ b/java/code/webapp/WEB-INF/pages/systems/sdc/overview.jsp
@@ -54,7 +54,7 @@
<div class="systeminfo">
<div class="systeminfo-full">
<rhn:icon type="system-reboot" /><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}"/>
+ <bean:message key="sdc.details.overview.schedulereboot"
arg0="/rhn/systems/details/RebootSystem.do?sid=${system.id}"/>
</div>
</div>
</c:if>
@@ -255,7 +255,7 @@
<td><fmt:formatDate value="${system.lastBootAsDate}"
type="both" dateStyle="short"
timeStyle="long"/><br/>
<rhn:require acl="system_feature(ftr_reboot)"
mixins="com.redhat.rhn.common.security.acl.SystemAclHandler">
- <bean:message key="sdc.details.overview.schedulereboot"
arg0="/network/systems/details/reboot_confirm.pxt?sid=${system.id}"/>
+ <bean:message key="sdc.details.overview.schedulereboot"
arg0="/rhn/systems/details/RebootSystem.do?sid=${system.id}"/>
</rhn:require>
</td>
</tr>
diff --git a/java/code/webapp/WEB-INF/pages/systems/sdc/rebootsystem.jsp
b/java/code/webapp/WEB-INF/pages/systems/sdc/rebootsystem.jsp
new file mode 100644
index 0000000..6e03b4a
--- /dev/null
+++ b/java/code/webapp/WEB-INF/pages/systems/sdc/rebootsystem.jsp
@@ -0,0 +1,52 @@
+<%--
+ Document : rebootsystem
+ Created on : Jan 15, 2014, 2:35:54 PM
+ Author : Michael Calmer <mc(a)suse.de>
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+
+<%@taglib
uri="http://rhn.redhat.com/rhn" prefix="rhn" %>
+<%@taglib
uri="http://java.sun.com/jsp/jstl/core" prefix="c"
%>
+<%@taglib
uri="http://struts.apache.org/tags-html" prefix="html"
%>
+<%@taglib
uri="http://struts.apache.org/tags-bean" prefix="bean"
%>
+<%@taglib
uri="http://rhn.redhat.com/tags/list" prefix="rl" %>
+
+<html>
+ <body>
+ <%@ include
file="/WEB-INF/pages/common/fragments/systems/system-header.jspf" %>
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <h4><bean:message key="reboot.jsp.header"
/></h4>
+ </div>
+ <div class="panel-body">
+ <bean:message key="reboot.jsp.summary" />
+ <br>
+ <bean:message key="reboot.jsp.widgetsummary"/>
+
+ <form
action="/rhn/systems/details/RebootSystem.do?sid=${sid}" method="post"
class="form-horizontal">
+ <rhn:csrf />
+ <rhn:submitted />
+
+ <div class="form-group">
+ <div class="col-lg-offset-3 col-lg-6">
+ <jsp:include
page="/WEB-INF/pages/common/fragments/date-picker.jsp">
+ <jsp:param name="widget"
value="date"/>
+ </jsp:include>
+ </div>
+ </div>
+
+ <div class="form-group">
+ <div class="col-lg-offset-3 col-lg-6">
+ <html:submit styleClass="btn btn-danger">
+ <bean:message key="reboot.jsp.confirm"/>
+ </html:submit>
+ </div>
+ </div>
+
+ <input type="hidden" name="use_date"
value="true" />
+ </form>
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/java/code/webapp/WEB-INF/struts-config.xml
b/java/code/webapp/WEB-INF/struts-config.xml
index 1e96b02..c96c141 100644
--- a/java/code/webapp/WEB-INF/struts-config.xml
+++ b/java/code/webapp/WEB-INF/struts-config.xml
@@ -3063,6 +3063,19 @@
path="/systems/ssm/ListSystems.do"
redirect="true" />
</action>
+ <action path="/systems/details/RebootSystem"
+ scope="request"
+ name="datePickerForm"
+ input="/WEB-INF/pages/systems/sdc/rebootsystem.jsp"
+
type="com.redhat.rhn.frontend.action.systems.sdc.SystemRebootAction"
+ className="com.redhat.rhn.frontend.struts.RhnActionMapping">
+ <set-property property="postRequiredIfSubmitted"
value="true"/>
+ <forward name="confirm"
+ path="/WEB-INF/pages/systems/sdc/overview.jsp" />
+ <forward name="default"
+ path="/WEB-INF/pages/systems/sdc/rebootsystem.jsp" />
+ </action>
+
<action path="/systems/details/audit/ListScap"
scope="request"
input="/WEB-INF/pages/systems/details/audit/listscap.jsp"
diff --git a/web/include/nav/system_detail.xml b/web/include/nav/system_detail.xml
index 3332573..b45ba4d 100644
--- a/web/include/nav/system_detail.xml
+++ b/web/include/nav/system_detail.xml
@@ -4,7 +4,7 @@
<rhn-tab name="Details"
url="/rhn/systems/details/Overview.do">
<rhn-tab name="Overview">
<rhn-tab-url>/rhn/systems/details/Overview.do</rhn-tab-url>
- <rhn-tab-url>/network/systems/details/reboot_confirm.pxt</rhn-tab-url>
+ <rhn-tab-url>/rhn/systems/details/RebootSystem.do</rhn-tab-url>
</rhn-tab>
<rhn-tab name="Properties" url="/rhn/systems/details/Edit.do"
/>
<rhn-tab name="Remote Command"
acl="system_feature(ftr_remote_command)">