diff --git a/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemDetailsEditAction.java b/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemDetailsEditAction.java index 6074ca21ccef..a5680fadaccb 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemDetailsEditAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemDetailsEditAction.java @@ -31,6 +31,7 @@ import com.redhat.rhn.frontend.struts.RhnHelper; import com.redhat.rhn.frontend.struts.RhnValidationHelper; import com.redhat.rhn.manager.entitlement.EntitlementManager; +import com.redhat.rhn.manager.kickstart.cobbler.CobblerSystemRenameCommand; import com.redhat.rhn.manager.system.SystemManager; import com.redhat.rhn.manager.system.entitling.SystemEntitlementManager; import com.redhat.rhn.manager.user.UserManager; @@ -111,6 +112,7 @@ public ActionForward execute(ActionMapping mapping, ActionForm form, "sdc.details.edit.propertieschanged", s.getName()); + SystemManager.updateSystemOverview(s.getId()); return getStrutsDelegate().forwardParam(mapping.findForward("success"), "sid", s.getId().toString()); @@ -143,7 +145,9 @@ private boolean processSubmission(HttpServletRequest request, boolean success = true; ActionErrors errors = new ActionErrors(); - s.setName(daForm.getString(NAME)); + String name = daForm.getString(NAME); + boolean renamed = name.equals(s.getName()); + s.setName(name); s.setDescription(daForm.getString(DESCRIPTION)); // Process the base entitlement selection. Need to @@ -243,6 +247,10 @@ else if (s.getMaintenanceScheduleOpt().isPresent()) { if (!success) { getStrutsDelegate().saveMessages(request, errors); } + + if (success && renamed) { + new CobblerSystemRenameCommand(s, name).store(); + } return success; } diff --git a/java/code/src/com/redhat/rhn/manager/kickstart/cobbler/CobblerSystemRenameCommand.java b/java/code/src/com/redhat/rhn/manager/kickstart/cobbler/CobblerSystemRenameCommand.java new file mode 100644 index 000000000000..c0126ad385a1 --- /dev/null +++ b/java/code/src/com/redhat/rhn/manager/kickstart/cobbler/CobblerSystemRenameCommand.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 SUSE LLC + * + * 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.manager.kickstart.cobbler; + +import com.redhat.rhn.common.validator.ValidatorError; +import com.redhat.rhn.domain.server.Server; +import com.redhat.rhn.manager.satellite.CobblerSyncCommand; + +import org.cobbler.SystemRecord; + +/** + * Rename system in cobbler + */ +public class CobblerSystemRenameCommand extends CobblerCommand { + + private Server server; + private String newName; + + /** + * Constructor + * @param serverIn - Server instance being renamed. + * @param newNameIn - new name + */ + public CobblerSystemRenameCommand(Server serverIn, String newNameIn) { + this.server = serverIn; + this.newName = newNameIn; + } + + /** + * Rename the System in cobbler + * @return ValidatorError + */ + @Override + public ValidatorError store() { + SystemRecord rec = lookupExisting(server); + if (rec != null) { + rec.setName(CobblerSystemCreateCommand.getCobblerSystemRecordName(newName, server.getOrg().getId())); + return new CobblerSyncCommand(user).store(); + } + return null; + } +} diff --git a/java/spacewalk-java.changes.welder.bsc1210455 b/java/spacewalk-java.changes.welder.bsc1210455 new file mode 100644 index 000000000000..9bf97ca35cbb --- /dev/null +++ b/java/spacewalk-java.changes.welder.bsc1210455 @@ -0,0 +1 @@ +- Propagate system rename to Cobbler (bsc#1210455)