Hi, I noticed something that I would call a little bug in spacewalk. If you have uploaded/created a kickstart/autoyast profile and then you rename the profile in the webfrontend, the filename in /var/lib/rhn/kickstarts/uploads/ or /var/lib/rhn/kickstarts/wizard/ stays the same. That leads to problems when you create a 2nd profile now with the old name that was used before. So if you have created a kickstart "test_profile" and then you rename it later to "webserver_profile" and then you create a new "test_profile", your webserver_profile is lost as a file.
I have attached a patch that solves the problem but I'm not sure if it's the best way to fix it. Something I don't do in the patch is deleting the old files if a rename has happened. What the patch does is: * change getCobblerFileName() to always calculate the name and never read it from the cobbler DB * create an empty file if you used the wizard and did a rename of a profile, because otherwise cobbler would complain that it can not find the new file. That's only needed with a wizard profile * if you rename a profile, change the "Kickstart" (filepath) in cobbler too I'm not 100% happy with the empty file creation but I did not see an easy way how to solve it differently. -- ciao, Uwe Gansert SUSE LINUX Products GmbH, HRB 16746 (AG Nürnberg) GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer Home: http://www.suse.de/~ug - Blog: http://suse.gansert.net
diff --git a/java/code/src/com/redhat/rhn/domain/kickstart/KickstartData.java b/java/code/src/com/redhat/rhn/domain/kickstart/KickstartData.java index 9bfa4ec..5edb9ee 100644 --- a/java/code/src/com/redhat/rhn/domain/kickstart/KickstartData.java +++ b/java/code/src/com/redhat/rhn/domain/kickstart/KickstartData.java @@ -1311,16 +1311,6 @@ public class KickstartData { * @return the cobblerName */ public String getCobblerFileName() { - if (getCobblerId() != null) { - Profile prof = Profile.lookupById( - CobblerXMLRPCHelper.getConnection( - Config.get().getString(ConfigDefaults.COBBLER_AUTOMATED_USER)), - getCobblerId()); - if (prof != null && !StringUtils.isBlank(prof.getKickstart())) { - return prof.getKickstart(); - } - } - String path = ""; if (isRawData()) { diff --git a/java/code/src/com/redhat/rhn/domain/kickstart/KickstartFactory.java b/java/code/src/com/redhat/rhn/domain/kickstart/KickstartFactory.java index 6e26939..1454646 100644 --- a/java/code/src/com/redhat/rhn/domain/kickstart/KickstartFactory.java +++ b/java/code/src/com/redhat/rhn/domain/kickstart/KickstartFactory.java @@ -385,7 +385,8 @@ public class KickstartFactory extends HibernateFactory { else { log.debug("No ks meta for this profile."); } - String path = getKickstartTemplatePath(ksdataIn, p); + String path = ksdataIn.getCobblerFileName(); + log.debug("writing ks file to : " + path); FileUtils.writeStringToFile(fileData, path); } diff --git a/java/code/src/com/redhat/rhn/frontend/action/kickstart/KickstartDetailsEditAction.java b/java/code/src/com/redhat/rhn/frontend/action/kickstart/KickstartDetailsEditAction.java index 4b6ed44..9ebac96 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/kickstart/KickstartDetailsEditAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/kickstart/KickstartDetailsEditAction.java @@ -16,6 +16,7 @@ package com.redhat.rhn.frontend.action.kickstart; import com.redhat.rhn.common.conf.ConfigDefaults; +import com.redhat.rhn.common.util.FileUtils; import com.redhat.rhn.common.validator.ValidatorError; import com.redhat.rhn.common.validator.ValidatorException; import com.redhat.rhn.domain.kickstart.KickstartData; @@ -304,6 +305,12 @@ public class KickstartDetailsEditAction extends BaseKickstartEditAction { return; } + // if we use the wizard and changed the label, the file does not exist yet. + // we create an empty one, so cobbler will not complain + if (!ksdata.isRawData() && !prof.getKickstart().equals(ksdata.getCobblerFileName())) { + FileUtils.writeStringToFile("", ksdata.getCobblerFileName()); + } + prof.setKickstart(ksdata.getCobblerFileName()); if (KickstartDetailsEditAction.canSaveVirtOptions(ksdata, form)) { prof.setVirtRam((Integer) form.get(VIRT_MEMORY)); prof.setVirtCpus((Integer) form.get(VIRT_CPU));
_______________________________________________ Spacewalk-devel mailing list Spacewalk-devel@redhat.com https://www.redhat.com/mailman/listinfo/spacewalk-devel