java/code/src/com/redhat/rhn/frontend/action/ssm/MigrateSystemsAction.java | 110 ++++++++++ java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml | 9 java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml | 36 ++- java/code/webapp/WEB-INF/pages/ssm/ssmindex.jsp | 1 java/code/webapp/WEB-INF/pages/ssm/systems/migrate.jsp | 61 +++++ java/code/webapp/WEB-INF/pages/ssm/systems/misc/index.jsp | 14 + java/code/webapp/WEB-INF/struts-config.xml | 18 + 7 files changed, 244 insertions(+), 5 deletions(-)
New commits: commit 17d8750a4ada5f742c748ec8ab272cb34c97db58 Author: Colin Coe coec@war.coesta.com Date: Sat Oct 2 19:04:20 2010 +0800
Fix SSM Index regression
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 4b558fc..beb458f 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 @@ -5441,10 +5441,7 @@ value for this entitlement, excluding the default organization's consumption.</s </trans-unit>
<trans-unit id="ssm.overview.misc.updateprofiles"> - <source>Update <a - href="/network/systems/ssm/misc/index.pxt#profiles">hardware/package - profiles</a> and <a href="/network/systems/ssm/misc/index.pxt#sysprefs">system - preferences</a></source> + <source>Update <a href="/rhn/systems/ssm/misc/Index.do#profiles">hardware/package profiles</a> and <a href="/rhn/systems/ssm/misc/Index.do#sysprefs">system preferences</a></source> </trans-unit>
<trans-unit id="ssm.overview.misc.customvalues"> @@ -5452,12 +5449,15 @@ value for this entitlement, excluding the default organization's consumption.</s </trans-unit>
<trans-unit id="ssm.overview.misc.entitlements"> - <source><a href="/network/systems/ssm/misc/index.pxt#entitle">Add or Remove</a> Add-On Entitlements</source> + <source><a href="/rhn/systems/ssm/misc/Index.do#entitle">Add or Remove</a> Add-On Entitlements</source> </trans-unit>
<trans-unit id="ssm.overview.misc.deletereboot"> <source><a href="/rhn/systems/ssm/DeleteConfirm.do">Delete</a> / <a href="/network/systems/ssm/misc/reboot_systems.pxt?pxt:trap=rhn:empty_set&set_label=target_systems">Reboot</a> systems</source> </trans-unit> + <trans-unit id="ssm.overview.misc.migrate"> + <source><a href="/rhn/systems/ssm/misc/Index.do#migrate">Migrate</a> systems to another organization</source> + </trans-unit> </group>
<!-- SSM System Migration --> diff --git a/java/code/webapp/WEB-INF/pages/ssm/ssmindex.jsp b/java/code/webapp/WEB-INF/pages/ssm/ssmindex.jsp index d526a85..0263d57 100644 --- a/java/code/webapp/WEB-INF/pages/ssm/ssmindex.jsp +++ b/java/code/webapp/WEB-INF/pages/ssm/ssmindex.jsp @@ -74,6 +74,7 @@ <bean:message key="ssm.overview.misc.customvalues"/><br /> <bean:message key="ssm.overview.misc.entitlements"/><br /> <bean:message key="ssm.overview.misc.deletereboot"/><br /> + <bean:message key="ssm.overview.misc.migrate"/><br /> </p> </td> </tr>
commit af85ce96038d40b429dae361df63b557a00345f2 Author: Colin Coe coec@war.coesta.com Date: Sat Oct 2 18:40:48 2010 +0800
SSM System migration
diff --git a/java/code/src/com/redhat/rhn/frontend/action/ssm/MigrateSystemsAction.java b/java/code/src/com/redhat/rhn/frontend/action/ssm/MigrateSystemsAction.java new file mode 100644 index 0000000..eebf713 --- /dev/null +++ b/java/code/src/com/redhat/rhn/frontend/action/ssm/MigrateSystemsAction.java @@ -0,0 +1,110 @@ +/** + * Copyright (c) 2010 Red Hat, Inc. + * + * 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.ssm; + +import com.redhat.rhn.domain.org.Org; +import com.redhat.rhn.domain.org.OrgFactory; +import com.redhat.rhn.domain.rhnset.RhnSet; +import com.redhat.rhn.domain.rhnset.RhnSetElement; +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.taglibs.list.helper.ListHelper; +import com.redhat.rhn.frontend.taglibs.list.helper.Listable; +import com.redhat.rhn.manager.org.MigrationManager; +import com.redhat.rhn.manager.rhnset.RhnSetDecl; +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.ArrayList; +import java.util.Iterator; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + + +/** + * MigrateSystemsAction + * @version $Rev$ + */ +public class MigrateSystemsAction extends RhnAction implements Listable { + /** + * + * {@inheritDoc} + */ + public ActionForward execute(ActionMapping mapping, + ActionForm formIn, + HttpServletRequest request, + HttpServletResponse response) { + RequestContext context = new RequestContext(request); + + RequestContext rctx = new RequestContext(request); + User user = rctx.getLoggedInUser(); + + if (context.wasDispatched("ssm.migrate.systems.confirmbutton")) { + RhnSet set = RhnSetDecl.SYSTEMS.get(context.getLoggedInUser()); + List<Server> serverList = new ArrayList<Server>(); + + Iterator it = set.iterator(); + while (it.hasNext()) { + Long sid = ((RhnSetElement)it.next()).getElement(); + Server server = SystemManager.lookupByIdAndUser(sid, user); + serverList.add(server); + } + + DynaActionForm daForm = (DynaActionForm)formIn; + + if (daForm.getString("org").equals("")) { + getStrutsDelegate().saveMessage("ssm.migrate.systems.orgnone", + context.getRequest()); + } + else { + Org toOrg = OrgFactory.lookupByName(daForm.getString("org")); + MigrationManager.migrateServers(user, toOrg, serverList); + + // Empty the set as we no longer have access to these systems + RhnSetDecl.SYSTEMS.clear(user); + + getStrutsDelegate().saveMessage("ssm.migrate.systems.confirmmessage", + context.getRequest()); + } + return mapping.findForward("confirm"); + } + + request.setAttribute("trustedOrgs", user.getOrg().getTrustedOrgs().size()); + request.setAttribute("orgs", user.getOrg().getTrustedOrgs()); + ListHelper helper = new ListHelper(this, request); + helper.setListName("systemList"); + helper.setDataSetName("pageList"); + helper.execute(); + + return mapping.findForward("default"); + } + + /** + * {@inheritDoc} + */ + public List getResult(RequestContext contextIn) { + return SystemManager.inSet(contextIn.getLoggedInUser(), + RhnSetDecl.SYSTEMS.getLabel()); + } + +} diff --git a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml index ed46f4d..158bbf5 100644 --- a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml +++ b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml @@ -8685,6 +8685,15 @@ Follow this url to see the full list of inactive systems: <trans-unit id="ssm.package.delete.operationname"> <source>Server Delete</source> </trans-unit> + <trans-unit id="ssm.migrate.systems.confirmmessage"> + <source>Systems Migrated</source> + </trans-unit> + <trans-unit id="ssm.migrate.systems.confirmbutton"> + <source>Migrate Systems</source> + </trans-unit> + <trans-unit id="ssm.migrate.systems.orgnone"> + <source>This organisation has no trusted organisations. Systems can only be migrated between organisations with defined trusts.</source> + </trans-unit> <trans-unit id="channel.manage.merge.finished"> <source>{0} Package(s) have been added and {1} Package(s) have been removed from the channel.</source> </trans-unit> 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 e8f485d..4b558fc 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 @@ -5460,6 +5460,22 @@ value for this entitlement, excluding the default organization's consumption.</s </trans-unit> </group>
+<!-- SSM System Migration --> + <group> + <context-group name="ctx"> + <context context-type="sourcefile">/rhn/systems/ssm/MigrateSystems.do</context> + </context-group> + <trans-unit id="ssm.migrate.systems.header"> + <source>Migrate Systems</source> + </trans-unit> + <trans-unit id="ssm.migrate.systems.summary"> + <source>Migrate the selected systems to the selected organisation. If the operation is successful, the systems will no longer be visible in this organisation.</source> + </trans-unit> + <trans-unit id="ssm.migrate.systems.org"> + <source>Target Organisation</source> + </trans-unit> + </group> + <!-- SSM System list--> <group> <context-group name="ctx"> @@ -5542,6 +5558,16 @@ value for this entitlement, excluding the default organization's consumption.</s <source>Update Software Profile</source> </trans-unit>
+ <trans-unit id="ssm.misc.index.migrate.header"> + <source>Migrate Systems</source> + </trans-unit> + <trans-unit id="ssm.misc.index.migrate.summary"> + <source>Migrate multiple systems from the current organistation to another (trusted) organisation in a single action. The migrated systems will no longer be visible in the original organisation.</source> + </trans-unit> + <trans-unit id="ssm.misc.index.migrate.migrate"> + <source>Migrate Systems to another organisation</source> + </trans-unit> + <trans-unit id="ssm.misc.index.csi.header"> <source>Custom System Information</source> </trans-unit> diff --git a/java/code/webapp/WEB-INF/pages/ssm/systems/migrate.jsp b/java/code/webapp/WEB-INF/pages/ssm/systems/migrate.jsp new file mode 100644 index 0000000..75482dc --- /dev/null +++ b/java/code/webapp/WEB-INF/pages/ssm/systems/migrate.jsp @@ -0,0 +1,61 @@ +<%@ taglib uri="http://rhn.redhat.com/rhn" prefix="rhn" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %> +<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %> +<%@ taglib uri="http://rhn.redhat.com/tags/list" prefix="rl" %> + +html:xhtml/ +<html> +<body> +<%@ include file="/WEB-INF/pages/common/fragments/ssm/header.jspf" %> +<h2> + <bean:message key="ssm.migrate.systems.header" /> +</h2> +<p><bean:message key="ssm.migrate.systems.summary" /></p> +<c:set var="notSelectable" value="true"/> +<c:set var="showLastCheckin" value="true"/> +<c:set var="noPackages" value="true"/> +<c:set var="noErrata" value="true"/> + + <c:choose> + <c:when test="${trustedOrgs == 0}"> + <strong><bean:message key="ssm.migrate.systems.notrust"/></strong> + </c:when> + <c:otherwise> + <html:form method="post" action="/systems/ssm/MigrateSystems.do"> + <table class="details"> + <tr> + <th> + <bean:message key="ssm.migrate.systems.org"/> + </th> + <td> + <html:select property="org"> + <html:option value="">-- None --</html:option> + <c:forEach var="o" items="${orgs}"> + <html:option value="${o.name}">${o.name}</html:option> + </c:forEach> + </html:select> + </td> + <td align="right"> + <input type ="submit" name="dispatch" value="${rhn:localize('ssm.migrate.systems.confirmbutton')}"/> + </td> + </tr> + </table> + </html:form> + </c:otherwise> + </c:choose> + +<rl:listset name="systemListSet" legend="system"> + <%@ include file="/WEB-INF/pages/common/fragments/systems/system_listdisplay.jspf" %> +<%-- + <div align="right"> + <hr /> + <input type ="submit" name="dispatch" value="${rhn:localize('ssm.migrate.systems.confirmbutton')}"/> + </div> +--%> +</rl:listset> + + +</body> +</html> + diff --git a/java/code/webapp/WEB-INF/pages/ssm/systems/misc/index.jsp b/java/code/webapp/WEB-INF/pages/ssm/systems/misc/index.jsp index d4a6b12..e354f9a 100644 --- a/java/code/webapp/WEB-INF/pages/ssm/systems/misc/index.jsp +++ b/java/code/webapp/WEB-INF/pages/ssm/systems/misc/index.jsp @@ -20,6 +20,20 @@ </ul> <br />
+<a id="migrate"> </a> +<h2><bean:message key="ssm.misc.index.migrate.header"/></h2> + +<div class="page-summary"> +<p><bean:message key="ssm.misc.index.migrate.summary"/></p> + +</div> + +<ul> + <li><a href="/rhn/systems/ssm/MigrateSystems.do"><bean:message key="ssm.misc.index.migrate.migrate"/></a></li> +</ul> + +<br /> + <a id="profiles"> </a> <h2><bean:message key="ssm.misc.index.csi.header"/></h2> <div class="page-summary"> diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml index d9473eb..dfd0fee 100644 --- a/java/code/webapp/WEB-INF/struts-config.xml +++ b/java/code/webapp/WEB-INF/struts-config.xml @@ -1028,6 +1028,12 @@ <form-property name="submitted" type="java.lang.Boolean"/> </form-bean>
+ <form-bean name="ssmMigrateForm" + type="com.redhat.rhn.frontend.struts.ScrubbingDynaActionForm" > + <form-property name="org" type="java.lang.String"/> + <form-property name="submitted" type="java.lang.Boolean"/> + </form-bean> + <form-bean name="targetSystemsForm" type="com.redhat.rhn.frontend.struts.ScrubbingDynaActionForm" > <form-property name="use_date" type="java.lang.Boolean"/> @@ -3107,6 +3113,18 @@ path="/systems/ssm/misc/Index.do" redirect="true"/> </action>
+ <action path="/systems/ssm/MigrateSystems" + scope="request" + input="/WEB-INF/pages/ssm/systems/ssmdeleteconfirm.jsp" + type="com.redhat.rhn.frontend.action.ssm.MigrateSystemsAction" + name="ssmMigrateForm" + className="com.redhat.rhn.frontend.struts.RhnActionMapping"> + <forward name="default" + path="/WEB-INF/pages/ssm/systems/migrate.jsp"/> + <forward name="confirm" + path="/systems/Overview.do" redirect="true"/> + </action> + <!--System Details Configuration --> <action path="/systems/details/configuration/Overview" scope="request"
spacewalk-commits@lists.fedorahosted.org