Skip to content

Commit

Permalink
Propagate system rename to Cobbler
Browse files Browse the repository at this point in the history
  • Loading branch information
wweellddeerr committed Nov 13, 2024
1 parent b4ca421 commit 7f8365d
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -243,6 +247,10 @@ else if (s.getMaintenanceScheduleOpt().isPresent()) {
if (!success) {
getStrutsDelegate().saveMessages(request, errors);
}

if (success && renamed && s.getCobblerId() != null) {
new CobblerSystemRenameCommand(s, name).store();
}
return success;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
1 change: 1 addition & 0 deletions java/spacewalk-java.changes.welder.bsc1210455
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Propagate system rename to Cobbler (bsc#1210455)

0 comments on commit 7f8365d

Please sign in to comment.