private KickstartScript lookupScriptByType(String typeIn) { if (this.getScripts() != null && this.getScripts().size() > 0) { Iterator<KickstartScript> i = this.getScripts().iterator(); while (i.hasNext()) { KickstartScript kss = i.next(); if (kss.getScriptType().equals(typeIn)) { return kss; } } } return null; }
/** * Add a KickstartScript to the KickstartData * * @param ksIn to add */ public void addScript(KickstartScript ksIn) { // The ordering goes: Pre scripts and post (chroot) scripts have // positive positions, post nochroot scripts have negative // positions where the most negative script is run right before // Red Hat's scripts. The user can adjust these default positions // later, but this allows us to preserve previous behavor where // adding a nochroot post script added it right before Red Hat's // post scripts and adding a post (chroot) script added it as the // last script that runs. if (ksIn.getScriptType().equals(KickstartScript.TYPE_POST) && !ksIn.thisScriptIsChroot()) { Long minPosition = 0L; for (KickstartScript script : scripts) { if (script.getPosition() < minPosition) { minPosition = script.getPosition(); } } ksIn.setPosition(minPosition - 1); } else { Long maxPosition = 0L; for (KickstartScript script : scripts) { if (script.getPosition() > maxPosition) { maxPosition = script.getPosition(); } } ksIn.setPosition(maxPosition + 1); } ksIn.setKsdata(this); scripts.add(ksIn); }
protected void updateCloneDetails(KickstartData cloned, User user, String newLabel) { cloned.setLabel(newLabel); cloned.setActive(this.isActive()); cloned.setPostLog(this.getPostLog()); cloned.setPreLog(this.getPreLog()); cloned.setKsCfg(this.getKsCfg()); cloned.setComments(this.getComments()); cloned.setNonChrootPost(this.getNonChrootPost()); cloned.setVerboseUp2date(this.getVerboseUp2date()); cloned.setOrg(this.getOrg()); cloned.setChildChannels(new HashSet<Channel>(this.getChildChannels())); cloned.setPartitionData(getPartitionData()); copyKickstartCommands(getCommands(), cloned); // Gotta remember to create a new HashSet with // the other objects. Otherwise hibernate will // complain that you are using the same collection // in two objects. if (this.getCryptoKeys() != null) { cloned.setCryptoKeys(new HashSet<CryptoKey>(this.getCryptoKeys())); } // NOTE: Make sure we *DONT* clone isOrgDefault cloned.setIsOrgDefault(Boolean.FALSE); cloned.setKernelParams(this.getKernelParams()); if (this.getKickstartDefaults() != null) { cloned.setKickstartDefaults(this.getKickstartDefaults().deepCopy(cloned)); } cloned.setOrg(this.getOrg()); if (this.getKsPackages() != null) { for (KickstartPackage kp : this.getKsPackages()) { cloned.getKsPackages().add(kp.deepCopy(cloned)); } } if (this.getPreserveFileLists() != null) { cloned.setPreserveFileLists(new HashSet<FileList>(this.getPreserveFileLists())); } if (this.getScripts() != null) { Iterator<KickstartScript> i = this.getScripts().iterator(); while (i.hasNext()) { KickstartScript kss = i.next(); KickstartScript ksscloned = kss.deepCopy(cloned); cloned.getScripts().add(ksscloned); } } // copy all of the non-session related kickstarts Set<Token> newTokens = new HashSet<Token>(); if (this.getDefaultRegTokens() != null) { for (Token tok : this.getDefaultRegTokens()) { ActivationKey key = ActivationKeyFactory.lookupByToken(tok); if (key == null || key.getKickstartSession() == null) { newTokens.add(tok); } } } cloned.setDefaultRegTokens(newTokens); cloned.setNoBase(this.getNoBase()); cloned.setIgnoreMissing(this.getIgnoreMissing()); }