java/code/src/com/redhat/rhn/common/db/datasource/xml/General_queries.xml
| 2
java/code/src/com/redhat/rhn/domain/kickstart/KickstartData.hbm.xml
| 7
java/code/src/com/redhat/rhn/domain/kickstart/KickstartData.java
| 115 ++-
java/code/src/com/redhat/rhn/domain/kickstart/KickstartFactory.java
| 299 ++++++----
java/code/src/com/redhat/rhn/domain/kickstart/KickstartableTree.hbm.xml
| 8
java/code/src/com/redhat/rhn/domain/kickstart/KickstartableTree.java
| 6
java/code/src/com/redhat/rhn/domain/kickstart/builder/KickstartBuilder.java
| 106 +--
java/code/src/com/redhat/rhn/domain/kickstart/builder/test/KickstartBuilderTest.java
| 43 -
java/code/src/com/redhat/rhn/domain/kickstart/test/KickstartRawDataTest.java
| 13
java/code/src/com/redhat/rhn/frontend/action/kickstart/AdvancedModeDetailsAction.java
| 112 ++-
java/code/src/com/redhat/rhn/frontend/action/kickstart/CreateProfileWizardAction.java
| 85 +-
java/code/src/com/redhat/rhn/frontend/action/kickstart/KickstartSoftwareEditAction.java
| 98 ++-
java/code/src/com/redhat/rhn/frontend/action/kickstart/KickstartTreeUpdateType.java
| 60 ++
java/code/src/com/redhat/rhn/frontend/action/kickstart/validation/kickstartCreateWizardForm.xsd
| 14
java/code/src/com/redhat/rhn/frontend/dto/kickstart/KickstartDto.java
| 15
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
| 12
java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/InvalidUpdateTypeAndKickstartTreeException.java
| 37 +
java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/InvalidUpdateTypeAndNoBaseTreeException.java
| 37 +
java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/InvalidUpdateTypeException.java
| 37 +
java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/KickstartHandler.java
| 231 +++++++
java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/profile/ProfileHandler.java
| 85 ++
java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/KickstartDtoSerializer.java
| 4
java/code/src/com/redhat/rhn/manager/kickstart/KickstartEditCommand.java
| 49 -
java/code/src/com/redhat/rhn/manager/kickstart/KickstartWizardHelper.java
| 27
java/code/src/com/redhat/rhn/taskomatic/task/CobblerSyncTask.java
| 34 +
java/code/webapp/WEB-INF/pages/common/fragments/kickstart/advanced/details.jspf
| 11
java/code/webapp/WEB-INF/pages/kickstart/softwareedit.jsp
| 54 +
java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/advanced/create.jsp
| 15
java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/advanced/edit.jsp
| 17
java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/first.jsp
| 36 +
java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/second.jsp
| 1
java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/third.jsp
| 1
java/code/webapp/WEB-INF/struts-config.xml
| 25
java/spacewalk-java.spec
| 8
rel-eng/packages/spacewalk-java
| 2
rel-eng/packages/spacewalk-schema
| 2
schema/spacewalk/common/tables/rhnKSData.sql
| 3
schema/spacewalk/spacewalk-schema.spec
| 5
schema/spacewalk/upgrade/spacewalk-schema-1.8-to-spacewalk-schema-1.9/023-rhnKsData.sql
| 2
40 files changed, 1330 insertions(+), 397 deletions(-)
New commits:
commit 0bf6ffedf499b7c7d7b513936646a5f838c53a3c
Author: Stephen Herr <sherr(a)redhat.com>
Date: Mon Feb 25 00:58:41 2013 -0500
Automatic commit of package [spacewalk-schema] release [1.9.33-1].
diff --git a/rel-eng/packages/spacewalk-schema b/rel-eng/packages/spacewalk-schema
index c8f1f84..b325607 100644
--- a/rel-eng/packages/spacewalk-schema
+++ b/rel-eng/packages/spacewalk-schema
@@ -1 +1 @@
-1.9.32-1 schema/spacewalk/
+1.9.33-1 schema/spacewalk/
diff --git a/schema/spacewalk/spacewalk-schema.spec
b/schema/spacewalk/spacewalk-schema.spec
index ffc5db0..fa9eef7 100644
--- a/schema/spacewalk/spacewalk-schema.spec
+++ b/schema/spacewalk/spacewalk-schema.spec
@@ -2,7 +2,7 @@ Name: spacewalk-schema
Group: Applications/Internet
Summary: Oracle SQL schema for Spacewalk server
-Version: 1.9.32
+Version: 1.9.33
Release: 1%{?dist}
Source0: %{name}-%{version}.tar.gz
@@ -69,6 +69,9 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man1/spacewalk-sql*
%changelog
+* Mon Feb 25 2013 Stephen Herr <sherr(a)redhat.com> 1.9.33-1
+- 915158 - Allow kickstart profile to update to latest available tree
+
* Thu Feb 21 2013 Tomas Kasparek <tkasparek(a)redhat.com> 1.9.32-1
- *._index.sql files can be used for definition of indexes
commit bb3b4717f559cea36634cc38364c8db678f777e8
Author: Stephen Herr <sherr(a)redhat.com>
Date: Mon Feb 25 00:58:11 2013 -0500
Automatic commit of package [spacewalk-java] release [1.9.73-1].
diff --git a/java/spacewalk-java.spec b/java/spacewalk-java.spec
index b352957..61ccd7e 100644
--- a/java/spacewalk-java.spec
+++ b/java/spacewalk-java.spec
@@ -28,7 +28,7 @@ Name: spacewalk-java
Summary: Spacewalk Java site packages
Group: Applications/Internet
License: GPLv2
-Version: 1.9.72
+Version: 1.9.73
Release: 1%{?dist}
URL:
https://fedorahosted.org/spacewalk
Source0:
https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
@@ -678,6 +678,12 @@ fi
%{jardir}/postgresql-jdbc.jar
%changelog
+* Mon Feb 25 2013 Stephen Herr <sherr(a)redhat.com> 1.9.73-1
+- 915158 - Allow kickstart profile to update to latest available tree
+- abrt: deleteCrash xml-rpc api call
+- abrt: listSystemCrashFiles api call
+- abrt: listSystemCrashes() api call returns crash package info
+
* Sat Feb 23 2013 Milan Zazrivec <mzazrivec(a)redhat.com> 1.9.72-1
- Fix 'SystemCrashHandler' compile error
- Fix cobbler login errors
diff --git a/rel-eng/packages/spacewalk-java b/rel-eng/packages/spacewalk-java
index 57367ea..fb4c321 100644
--- a/rel-eng/packages/spacewalk-java
+++ b/rel-eng/packages/spacewalk-java
@@ -1 +1 @@
-1.9.72-1 java/
+1.9.73-1 java/
commit d2d3ad28da4edb7644ff9c7a7725d38dc678a004
Author: Stephen Herr <sherr(a)redhat.com>
Date: Mon Feb 25 00:57:52 2013 -0500
915158 - Allow kickstart profile to update to latest available tree
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/General_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/General_queries.xml
index dec05e8..a43dd5b 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/General_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/General_queries.xml
@@ -4,7 +4,7 @@
<query params="org_id">
SELECT KS.id, KS.org_id, KS.label, KS.is_org_default,
KS.active, KSD.kstree_id, KT.label as tree_label,KS.cobbler_id,
- KS.ks_type as kickstart_type
+ KS.ks_type as kickstart_type, KS.update_type
FROM rhnKickstartDefaults KSD, rhnKSData KS, rhnKickstartableTree KT
WHERE KS.org_id = :org_id
AND KSD.kickstart_id = KS.id
diff --git a/java/code/src/com/redhat/rhn/domain/kickstart/KickstartData.hbm.xml
b/java/code/src/com/redhat/rhn/domain/kickstart/KickstartData.hbm.xml
index 57ee011..f4dcae3 100644
--- a/java/code/src/com/redhat/rhn/domain/kickstart/KickstartData.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/kickstart/KickstartData.hbm.xml
@@ -36,7 +36,8 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<property name="ignoreMissing" column="ignore_missing"
not-null="false" type="yes_no" />
<property name="verboseUp2date" column="verboseup2date"
not-null="false" type="yes_no" />
<property name="partitionDataBinary" column="partition_data"
type="binary" />
- <property name="cobblerId" column="cobbler_id"
type="string" length="64" />
+ <property name="cobblerId" column="cobbler_id"
type="string" length="64" />
+ <property name="updateType" column="update_type"
length="7" type="string" not-null="true" />
<set name="ksPackages" lazy="true"
sort="natural" inverse="true" cascade="all-delete-orphan"
>
<key column="kickstart_id"/>
<one-to-many
class="com.redhat.rhn.domain.kickstart.KickstartPackage" />
@@ -95,7 +96,9 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<query name="KickstartData.findByCobblerIdAndOrg">
<![CDATA[from com.redhat.rhn.domain.kickstart.KickstartData as t where
t.cobblerId = :id and t.org = :org_id]]>
</query>
-
+ <query name="KickstartData.lookupByUpdateable">
+ <![CDATA[from com.redhat.rhn.domain.kickstart.KickstartData as t where not
t.updateType = 'none']]>
+ </query>
<query name="KickstartData.findByIdAndOrg">
<![CDATA[from com.redhat.rhn.domain.kickstart.KickstartData as t where t.id =
:id and t.org = :org_id]]>
</query>
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 26024fd..c305a2c 100644
--- a/java/code/src/com/redhat/rhn/domain/kickstart/KickstartData.java
+++ b/java/code/src/com/redhat/rhn/domain/kickstart/KickstartData.java
@@ -26,6 +26,7 @@ import com.redhat.rhn.domain.token.ActivationKey;
import com.redhat.rhn.domain.token.ActivationKeyFactory;
import com.redhat.rhn.domain.token.Token;
import com.redhat.rhn.domain.user.User;
+import com.redhat.rhn.frontend.action.kickstart.KickstartTreeUpdateType;
import com.redhat.rhn.manager.kickstart.KickstartFormatter;
import com.redhat.rhn.manager.kickstart.cobbler.CobblerCommand;
import com.redhat.rhn.manager.kickstart.cobbler.CobblerXMLRPCHelper;
@@ -84,9 +85,10 @@ public class KickstartData {
private KickstartDefaults kickstartDefaults;
private boolean noBase;
private boolean ignoreMissing;
+ private String updateType;
private static final Pattern URL_REGEX =
- Pattern.compile("--url\\s*(\\S+)", Pattern.CASE_INSENSITIVE);
+ Pattern.compile("--url\\s*(\\S+)", Pattern.CASE_INSENSITIVE);
public static final String LEGACY_KICKSTART_PACKAGE_NAME =
"auto-kickstart-";
public static final String WIZARD_DIR = "wizard";
@@ -98,7 +100,7 @@ public class KickstartData {
public static final String TYPE_RAW = "raw";
private static String[] advancedOptions =
{"partitions", "raids", "logvols",
"volgroups", "include",
- "repo", "custom", "custom_partition"};
+ "repo", "custom", "custom_partition"};
private static final List ADANCED_OPTIONS = Arrays.asList(advancedOptions);
@@ -122,6 +124,7 @@ public class KickstartData {
kickstartType = TYPE_WIZARD;
noBase = false;
ignoreMissing = false;
+ setUpdateType(KickstartTreeUpdateType.NONE.getType());
}
/**
@@ -133,7 +136,7 @@ public class KickstartData {
/**
* Getter for id
* @return Long to get
- */
+ */
public Long getId() {
return this.id;
}
@@ -141,7 +144,7 @@ public class KickstartData {
/**
* Setter for id
* @param idIn to set
- */
+ */
public void setId(Long idIn) {
this.id = idIn;
}
@@ -157,7 +160,7 @@ public class KickstartData {
/**
* Getter for org
* @return org to get
- */
+ */
public Org getOrg() {
return org;
}
@@ -165,7 +168,7 @@ public class KickstartData {
/**
* Getter for label
* @return String to get
- */
+ */
public String getLabel() {
return this.label;
}
@@ -173,7 +176,7 @@ public class KickstartData {
/**
* Setter for label
* @param labelIn to set
- */
+ */
public void setLabel(String labelIn) {
this.label = labelIn;
}
@@ -181,7 +184,7 @@ public class KickstartData {
/**
* Getter for comments
* @return String to get
- */
+ */
public String getComments() {
return this.comments;
}
@@ -189,7 +192,7 @@ public class KickstartData {
/**
* Setter for comments
* @param commentsIn to set
- */
+ */
public void setComments(String commentsIn) {
this.comments = commentsIn;
}
@@ -197,7 +200,7 @@ public class KickstartData {
/**
* Getter for active
* @return String to get
- */
+ */
public Boolean isActive() {
return this.active;
}
@@ -206,14 +209,14 @@ public class KickstartData {
/**
* Getter for active
* @return String to get
- */
+ */
public boolean getActive() {
return isActive();
}
/**
* Setter for active
* @param activeIn to set
- */
+ */
public void setActive(Boolean activeIn) {
this.active = activeIn;
}
@@ -221,7 +224,7 @@ public class KickstartData {
/**
* Getter for created
* @return Date to get
- */
+ */
public Date getCreated() {
return this.created;
}
@@ -229,7 +232,7 @@ public class KickstartData {
/**
* Setter for created
* @param createdIn to set
- */
+ */
public void setCreated(Date createdIn) {
this.created = createdIn;
}
@@ -237,7 +240,7 @@ public class KickstartData {
/**
* Getter for modified
* @return Date to get
- */
+ */
public Date getModified() {
return this.modified;
}
@@ -245,7 +248,7 @@ public class KickstartData {
/**
* Setter for modified
* @param modifiedIn to set
- */
+ */
public void setModified(Date modifiedIn) {
this.modified = modifiedIn;
}
@@ -253,7 +256,7 @@ public class KickstartData {
/**
* Getter for isOrgDefault
* @return String to get
- */
+ */
public Boolean isOrgDefault() {
return getIsOrgDefault();
}
@@ -261,14 +264,14 @@ public class KickstartData {
/**
* Getter for isOrgDefault
* @return String to get
- */
+ */
protected boolean getIsOrgDefault() {
return this.isOrgDefault;
}
/**
* Setter for isOrgDefault
* @param isDefault to set
- */
+ */
protected void setIsOrgDefault(boolean isDefault) {
this.isOrgDefault = isDefault;
}
@@ -276,13 +279,13 @@ public class KickstartData {
/**
* Setter for isOrgDefault
* @param isDefault to set
- */
+ */
public void setOrgDefault(boolean isDefault) {
// We actually want to set the orgdefault
if (!isOrgDefault() &&
isDefault) {
KickstartData existingDefault = KickstartFactory.
- lookupOrgDefault(getOrg());
+ lookupOrgDefault(getOrg());
if (existingDefault != null) {
existingDefault.setIsOrgDefault(Boolean.FALSE);
KickstartFactory.saveKickstartData(existingDefault);
@@ -294,7 +297,7 @@ public class KickstartData {
/**
* Getter for kernelParams
* @return String to get
- */
+ */
public String getKernelParams() {
return this.kernelParams;
}
@@ -302,7 +305,7 @@ public class KickstartData {
/**
* Setter for kernelParams
* @param kernelParamsIn to set
- */
+ */
public void setKernelParams(String kernelParamsIn) {
this.kernelParams = kernelParamsIn;
}
@@ -333,7 +336,7 @@ public class KickstartData {
/**
* Remove a crypto key from the set.
* @param key to remove.
- */
+ */
public void removeCryptoKey(CryptoKey key) {
this.cryptoKeys.remove(key);
}
@@ -426,7 +429,7 @@ public class KickstartData {
/**
* Remove a file list from the set.
* @param fileList to remove.
- */
+ */
public void removePreserveFileList(FileList fileList) {
this.preserveFileLists.remove(fileList);
}
@@ -513,7 +516,7 @@ public class KickstartData {
private KickstartScript lookupScriptByType(String typeIn) {
if (this.getScripts() != null &&
- this.getScripts().size() > 0) {
+ this.getScripts().size() > 0) {
Iterator i = this.getScripts().iterator();
while (i.hasNext()) {
KickstartScript kss = (KickstartScript) i.next();
@@ -958,7 +961,7 @@ public class KickstartData {
*/
public boolean getEliloRequired() {
return this.getKickstartDefaults().getKstree().getChannel()
- .getChannelArch().getLabel().equals("channel-ia64");
+ .getChannelArch().getLabel().equals("channel-ia64");
}
/**
@@ -1035,7 +1038,7 @@ public class KickstartData {
}
LinkedList tokens =
- (LinkedList) StringUtil.stringToList(tzCommand.getArguments());
+ (LinkedList) StringUtil.stringToList(tzCommand.getArguments());
Iterator iter = tokens.iterator();
@@ -1063,7 +1066,7 @@ public class KickstartData {
}
LinkedList tokens =
- (LinkedList) StringUtil.stringToList(tzCommand.getArguments());
+ (LinkedList) StringUtil.stringToList(tzCommand.getArguments());
Iterator iter = tokens.iterator();
@@ -1097,7 +1100,7 @@ public class KickstartData {
}
protected void updateCloneDetails(KickstartData cloned, User user,
- String newLabel) {
+ String newLabel) {
cloned.setLabel(newLabel);
cloned.setActive(this.isActive());
@@ -1285,7 +1288,7 @@ public class KickstartData {
*/
public boolean isConfigManageable() {
return getKickstartDefaults() != null &&
- getKickstartDefaults().getCfgManagementFlag();
+ getKickstartDefaults().getCfgManagementFlag();
}
/**
@@ -1294,7 +1297,7 @@ public class KickstartData {
*/
public boolean isRemoteCommandable() {
return getKickstartDefaults() != null &&
- getKickstartDefaults().getRemoteCommandFlag();
+ getKickstartDefaults().getRemoteCommandFlag();
}
/**
@@ -1303,9 +1306,9 @@ public class KickstartData {
public String getCobblerFileName() {
if (getCobblerId() != null) {
Profile prof = Profile.lookupById(
- CobblerXMLRPCHelper.getConnection(
- ConfigDefaults.get().getCobblerAutomatedUser()),
- getCobblerId());
+ CobblerXMLRPCHelper.getConnection(
+ ConfigDefaults.get().getCobblerAutomatedUser()),
+ getCobblerId());
if (prof != null && !StringUtils.isBlank(prof.getKickstart())) {
return prof.getKickstart();
}
@@ -1372,7 +1375,7 @@ public class KickstartData {
* @return String containing kickstart file
*/
public String getFileData(String host,
- KickstartSession session) {
+ KickstartSession session) {
KickstartFormatter formatter = new KickstartFormatter(host, this, session);
return formatter.getFileData();
}
@@ -1420,7 +1423,7 @@ public class KickstartData {
* @param noBaseIn the noBase to set
*/
public void setNoBase(Boolean noBaseIn) {
- this.noBase = noBaseIn;
+ this.noBase = noBaseIn;
}
/**
@@ -1434,7 +1437,7 @@ public class KickstartData {
* @param ignoreMissingIn the ignoreMissing to set
*/
public void setIgnoreMissing(Boolean ignoreMissingIn) {
- this.ignoreMissing = ignoreMissingIn;
+ this.ignoreMissing = ignoreMissingIn;
}
/**
@@ -1486,7 +1489,7 @@ public class KickstartData {
}
return RegistrationType.find((String)prof.getKsMeta().get(
- RegistrationType.COBBLER_VAR));
+ RegistrationType.COBBLER_VAR));
}
/**
@@ -1543,4 +1546,38 @@ public class KickstartData {
public void setPartitionData(String data) {
setPartitionDataBinary(HibernateFactory.stringToByteArray(data));
}
+
+ /**
+ * get the update type
+ * @return the update type
+ */
+ public String getUpdateType() {
+ return this.updateType;
+ }
+
+ /**
+ * get the update type
+ * @return the update type
+ */
+ public KickstartTreeUpdateType getRealUpdateType() {
+ return KickstartTreeUpdateType.find(this.updateType);
+ }
+
+ /**
+ * Set the update type
+ * Hibernate wigs out if this is called "setUpdateType", which is should
be
+ * @param updateTypeIn the update type to set
+ */
+ public void setUpdateType(String updateTypeIn) {
+ this.updateType = updateTypeIn;
+ }
+
+ /**
+ * Set the update type
+ * Hibernate wigs out if this is called "setUpdateType", which is should
be
+ * @param updateTypeIn the update type to set
+ */
+ public void setRealUpdateType(KickstartTreeUpdateType updateTypeIn) {
+ this.updateType = updateTypeIn.getType();
+ }
}
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 3a82dc2..2689d55 100644
--- a/java/code/src/com/redhat/rhn/domain/kickstart/KickstartFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/kickstart/KickstartFactory.java
@@ -22,7 +22,9 @@ import com.redhat.rhn.domain.kickstart.crypto.CryptoKeyType;
import
com.redhat.rhn.domain.org.Org;
import com.redhat.rhn.domain.org.OrgFactory;
import com.redhat.rhn.domain.rhnpackage.PackageName;
+import com.redhat.rhn.frontend.action.kickstart.KickstartTreeUpdateType;
import com.redhat.rhn.manager.kickstart.KickstartFormatter;
+import com.redhat.rhn.manager.kickstart.KickstartManager;
import com.redhat.rhn.manager.kickstart.KickstartUrlHelper;
import com.redhat.rhn.manager.kickstart.cobbler.CobblerXMLRPCHelper;
@@ -58,27 +60,27 @@ public class KickstartFactory extends HibernateFactory {
public static final CryptoKeyType KEY_TYPE_GPG = lookupKeyType("GPG");
public static final CryptoKeyType KEY_TYPE_SSL = lookupKeyType("SSL");
public static final KickstartSessionState SESSION_STATE_FAILED =
- lookupSessionStateByLabel("failed");
+ lookupSessionStateByLabel("failed");
public static final KickstartSessionState SESSION_STATE_CREATED =
- lookupSessionStateByLabel("created");
+ lookupSessionStateByLabel("created");
public static final KickstartSessionState SESSION_STATE_STARTED =
- lookupSessionStateByLabel("started");
+ lookupSessionStateByLabel("started");
public static final KickstartSessionState SESSION_STATE_COMPLETE =
- lookupSessionStateByLabel("complete");
+ lookupSessionStateByLabel("complete");
public static final KickstartSessionState SESSION_STATE_CONFIG_ACCESSED =
- lookupSessionStateByLabel("configuration_accessed");
+ lookupSessionStateByLabel("configuration_accessed");
public static final KickstartVirtualizationType VIRT_TYPE_PV_HOST =
- lookupKickstartVirtualizationTypeByLabel(KickstartVirtualizationType.PARA_HOST);
+
lookupKickstartVirtualizationTypeByLabel(KickstartVirtualizationType.PARA_HOST);
public static final KickstartVirtualizationType VIRT_TYPE_XEN_PV =
- lookupKickstartVirtualizationTypeByLabel("xenpv");
+ lookupKickstartVirtualizationTypeByLabel("xenpv");
private static final String KICKSTART_CANCELLED_MESSAGE =
- "Kickstart cancelled due to action removal";
+ "Kickstart cancelled due to action removal";
public static final KickstartTreeType TREE_TYPE_EXTERNAL =
- lookupKickstartTreeTypeByLabel("externally-managed");
+ lookupKickstartTreeTypeByLabel("externally-managed");
private KickstartFactory() {
super();
@@ -95,9 +97,73 @@ public class KickstartFactory extends HibernateFactory {
private static CryptoKeyType lookupKeyType(String label) {
return (CryptoKeyType) HibernateFactory.getSession()
-
.getNamedQuery("CryptoKeyType.findByLabel")
- .setString("label", label)
- .uniqueResult();
+ .getNamedQuery("CryptoKeyType.findByLabel")
+ .setString("label", label)
+ .uniqueResult();
+ }
+
+ /**
+ * Returns the most recently modified KickstartableTree for that channel
+ * @param updateType The type of kickstart tree to allow, all or redhat-only
+ * @param channelId The base chanenl
+ * @param org The users org to look for cusome kickstart trees in
+ * @return most recently modified KickstartableTree
+ */
+ public static KickstartableTree getNewestTree(
+ KickstartTreeUpdateType updateType,
+ Long channelId, Org org) {
+ List<KickstartableTree> trees = null;
+ if (updateType.equals(KickstartTreeUpdateType.ALL)) {
+ trees = KickstartManager.getInstance().removeInvalid(
+ lookupKickstartableTrees(channelId, org));
+ // they are ordered by last_modified, get the last element to get
+ // newest
+ // tree
+ return trees.get(trees.size() - 1);
+ }
+ else if (updateType.equals(KickstartTreeUpdateType.RED_HAT)) {
+ trees = KickstartManager.getInstance().removeInvalid(
+ lookupKickstartTreesByChannelAndNullOrg(channelId));
+ // This is harder, if they got synced at the same time they would
+ // have
+ // the same last_modified date. since they all are for the same base
+ // channel then we'll grep the last part of the ks tree label and
+ // guess
+ // based on that.
+ KickstartableTree newest = null;
+ int newestUpdate = -1;
+ for (KickstartableTree tree : trees) {
+ String[] update = tree.getLabel().split("-");
+ String major = update[update.length - 2];
+ String minor = update[update.length - 1];
+ // if major is not actually the major version, this must be an
+ // initial release, e.g. "...-server-5".
+ if (!major.matches("^[0-9]*$")) {
+ minor = "0";
+ }
+ else {
+ if (minor.contains(".")) {
+ String[] parts = minor.split("\\.");
+ minor = parts[parts.length - 1];
+ }
+ else if (minor.contains("u")) {
+ String[] parts = minor.split("u");
+ minor = parts[parts.length - 1];
+ }
+
+ }
+ int updateInt = Integer.parseInt(minor);
+ if (updateInt > newestUpdate) {
+ newestUpdate = updateInt;
+ newest = tree;
+ }
+
+ }
+ return newest;
+ }
+ else {
+ return null;
+ }
}
/**
@@ -107,10 +173,10 @@ public class KickstartFactory extends HibernateFactory {
*/
public static KickstartData lookupKickstartDataByIdAndOrg(Org orgIn, Long ksid) {
return (KickstartData) HibernateFactory.getSession()
-
.getNamedQuery("KickstartData.findByIdAndOrg")
- .setLong("id", ksid.longValue())
- .setLong("org_id",
orgIn.getId().longValue())
- .uniqueResult();
+ .getNamedQuery("KickstartData.findByIdAndOrg")
+ .setLong("id", ksid.longValue())
+ .setLong("org_id", orgIn.getId().longValue())
+ .uniqueResult();
}
/**
@@ -119,12 +185,12 @@ public class KickstartFactory extends HibernateFactory {
* @return Kickstart Data object by cobbler id
*/
public static KickstartData lookupKickstartDataByCobblerIdAndOrg(Org orgIn,
- String cobblerId) {
+ String cobblerId) {
return (KickstartData) HibernateFactory.getSession()
-
.getNamedQuery("KickstartData.findByCobblerIdAndOrg")
- .setString("id", cobblerId)
- .setLong("org_id", orgIn.getId())
- .uniqueResult();
+ .getNamedQuery("KickstartData.findByCobblerIdAndOrg")
+ .setString("id", cobblerId)
+ .setLong("org_id", orgIn.getId())
+ .uniqueResult();
}
/**
@@ -139,10 +205,10 @@ public class KickstartFactory extends HibernateFactory {
throw new IllegalArgumentException("kickstartLabel cannot be
null");
}
return (KickstartData) HibernateFactory.getSession().
-
getNamedQuery("KickstartData.findByLabelAndOrg")
- .setString("label", label)
- .setLong("org_id", orgId.longValue())
- .uniqueResult();
+ getNamedQuery("KickstartData.findByLabelAndOrg")
+ .setString("label", label)
+ .setLong("org_id", orgId.longValue())
+ .uniqueResult();
}
/**
@@ -158,10 +224,10 @@ public class KickstartFactory extends HibernateFactory {
throw new IllegalArgumentException("kickstartLabel cannot be
null");
}
return (KickstartData) HibernateFactory.getSession().
-
getNamedQuery("KickstartData.findByCILabelAndOrg")
- .setString("label", label)
- .setLong("org_id", orgId.longValue())
- .uniqueResult();
+ getNamedQuery("KickstartData.findByCILabelAndOrg")
+ .setString("label", label)
+ .setLong("org_id", orgId.longValue())
+ .uniqueResult();
}
/**
@@ -175,9 +241,9 @@ public class KickstartFactory extends HibernateFactory {
throw new IllegalArgumentException("kickstartLabel cannot be
null");
}
return (KickstartData) HibernateFactory.getSession().
-
getNamedQuery("KickstartData.findByLabel")
- .setString("label", label)
- .uniqueResult();
+ getNamedQuery("KickstartData.findByLabel")
+ .setString("label", label)
+ .uniqueResult();
}
@@ -188,7 +254,7 @@ public class KickstartFactory extends HibernateFactory {
*/
public static List<String> listKickstartDataCobblerIds() {
return singleton.listObjectsByNamedQuery("KickstartData.cobblerIds",
- Collections.EMPTY_MAP);
+ Collections.EMPTY_MAP);
}
@@ -198,7 +264,7 @@ public class KickstartFactory extends HibernateFactory {
* @return the Kickstartable Tree object
*/
public static KickstartableTree
- lookupKickstartTreeByCobblerIdOrXenId(String cobblerId) {
+ lookupKickstartTreeByCobblerIdOrXenId(String cobblerId) {
Map map = new HashMap();
map.put("cid", cobblerId);
return (KickstartableTree) singleton.lookupObjectByNamedQuery(
@@ -282,7 +348,7 @@ public class KickstartFactory extends HibernateFactory {
KickstartCommandName retval = null;
session = HibernateFactory.getSession();
Query query =
- session.getNamedQuery("KickstartCommandName.findByLabel");
+ session.getNamedQuery("KickstartCommandName.findByLabel");
//Retrieve from cache if there
query.setCacheable(true);
query.setParameter("name", commandName);
@@ -302,7 +368,7 @@ public class KickstartFactory extends HibernateFactory {
String nameIn) {
KickstartCommand retval = new KickstartCommand();
KickstartCommandName name =
- KickstartFactory.lookupKickstartCommandName(nameIn);
+ KickstartFactory.lookupKickstartCommandName(nameIn);
retval = new KickstartCommand();
retval.setCommandName(name);
retval.setKickstartData(ksdata);
@@ -323,8 +389,8 @@ public class KickstartFactory extends HibernateFactory {
String query = "KickstartCommandName.requiredOptions";
session = HibernateFactory.getSession();
retval = session.getNamedQuery(query)
- //Retrieve from cache if there
- .setCacheable(true).list();
+ //Retrieve from cache if there
+ .setCacheable(true).list();
return retval;
}
@@ -378,7 +444,7 @@ public class KickstartFactory extends HibernateFactory {
fileData = formatter.getFileData();
}
Profile p = Profile.lookupById(CobblerXMLRPCHelper.getAutomatedConnection(),
- ksdataIn.getCobblerId());
+ ksdataIn.getCobblerId());
if (p != null && p.getKsMeta() != null) {
Map ksmeta = p.getKsMeta();
Iterator i = ksmeta.keySet().iterator();
@@ -449,9 +515,9 @@ public class KickstartFactory extends HibernateFactory {
CryptoKey retval = null;
session = HibernateFactory.getSession();
retval = (CryptoKey)
session.getNamedQuery("CryptoKey.findByDescAndOrg")
- .setString("description", description)
- .setLong("org_id",
org.getId().longValue())
- .uniqueResult();
+ .setString("description", description)
+ .setLong("org_id", org.getId().longValue())
+ .uniqueResult();
return retval;
}
@@ -466,8 +532,8 @@ public class KickstartFactory extends HibernateFactory {
//look for Kickstart data by id
session = HibernateFactory.getSession();
retval = session.getNamedQuery("CryptoKey.findByOrg")
- .setLong("org_id",
org.getId().longValue())
- .list();
+ .setLong("org_id", org.getId().longValue())
+ .list();
return retval;
}
@@ -483,9 +549,9 @@ public class KickstartFactory extends HibernateFactory {
//look for Kickstart data by id
session = HibernateFactory.getSession();
retval = (CryptoKey) session.getNamedQuery("CryptoKey.findByIdAndOrg")
- .setLong("key_id", keyId.longValue())
- .setLong("org_id",
org.getId().longValue())
- .uniqueResult();
+ .setLong("key_id", keyId.longValue())
+ .setLong("org_id", org.getId().longValue())
+ .uniqueResult();
return retval;
}
@@ -498,8 +564,8 @@ public class KickstartFactory extends HibernateFactory {
Session session = null;
session = HibernateFactory.getSession();
return session.getNamedQuery("KickstartIpRange.lookupByOrg")
- .setEntity("org", org)
- .list();
+ .setEntity("org", org)
+ .list();
}
/**
@@ -516,17 +582,17 @@ public class KickstartFactory extends HibernateFactory {
KickstartableTree retval = null;
session = HibernateFactory.getSession();
retval = (KickstartableTree)
- session.getNamedQuery("KickstartableTree.findByLabelAndOrg")
- .setString("label", label)
- .setLong("org_id",
org.getId().longValue())
- .uniqueResult();
+ session.getNamedQuery("KickstartableTree.findByLabelAndOrg")
+ .setString("label", label)
+ .setLong("org_id", org.getId().longValue())
+ .uniqueResult();
// If we don't find by label + org then
// we try by label and NULL org (RHN owned channel)
if (retval == null) {
retval = (KickstartableTree)
-
session.getNamedQuery("KickstartableTree.findByLabelAndNullOrg")
- .setString("label", label)
- .uniqueResult();
+
session.getNamedQuery("KickstartableTree.findByLabelAndNullOrg")
+ .setString("label", label)
+ .uniqueResult();
}
return retval;
}
@@ -542,9 +608,9 @@ public class KickstartFactory extends HibernateFactory {
KickstartableTree retval = null;
session = HibernateFactory.getSession();
retval = (KickstartableTree)
- session.getNamedQuery("KickstartableTree.findByLabel")
- .setString("label", label)
- .uniqueResult();
+ session.getNamedQuery("KickstartableTree.findByLabel")
+ .setString("label", label)
+ .uniqueResult();
return retval;
}
@@ -564,10 +630,28 @@ public class KickstartFactory extends HibernateFactory {
String query = "KickstartableTree.findByChannelAndOrg";
session = HibernateFactory.getSession();
retval = session.getNamedQuery(query).
- setLong("channel_id", channelId.longValue()).
- setLong("org_id", org.getId().longValue())
- //Retrieve from cache if there
- .setCacheable(true).list();
+ setLong("channel_id", channelId.longValue()).
+ setLong("org_id", org.getId().longValue())
+ //Retrieve from cache if there
+ .setCacheable(true).list();
+ return retval;
+ }
+
+ /**
+ * Lookup a list of KickstartableTree objects that use the passed in channelId
+ * @param channelId The base channel of the kickstart trees
+ * @return List of KickstartableTree objects
+ */
+ public static List<KickstartableTree> lookupKickstartTreesByChannelAndNullOrg(
+ Long channelId) {
+ Session session = null;
+ List retval = null;
+ String query = "KickstartableTree.findByChannelAndNullOrg";
+ session = HibernateFactory.getSession();
+ retval = session.getNamedQuery(query)
+ .setLong("channel_id", channelId.longValue())
+ // Retrieve from cache if there
+ .setCacheable(true).list();
return retval;
}
@@ -587,9 +671,9 @@ public class KickstartFactory extends HibernateFactory {
query = "KickstartableTree.findByChannel";
session = HibernateFactory.getSession();
retval = session.getNamedQuery(query).
- setLong("channel_id", channelId.longValue()).
- setLong("org_id", org.getId().longValue()).
- list();
+ setLong("channel_id", channelId.longValue()).
+ setLong("org_id", org.getId().longValue()).
+ list();
return retval;
}
@@ -604,7 +688,7 @@ public class KickstartFactory extends HibernateFactory {
Map<String, Object> params = new HashMap<String, Object>();
params.put("org_id", org.getId());
return singleton.listObjectsByNamedQuery(
- "KickstartableTree.findAccessibleToOrg", params, false);
+ "KickstartableTree.findAccessibleToOrg", params, false);
}
/**
@@ -616,7 +700,7 @@ public class KickstartFactory extends HibernateFactory {
Map<String, Object> params = new HashMap<String, Object>();
params.put("org_id", org.getId());
return singleton.listObjectsByNamedQuery(
- "KickstartableTree.findByOrg", params, true);
+ "KickstartableTree.findByOrg", params, true);
}
/**
@@ -660,7 +744,7 @@ public class KickstartFactory extends HibernateFactory {
query.setLong("tree_id", treeId.longValue());
//Retrieve from cache if there
retval = (KickstartableTree)
- query.setCacheable(true).uniqueResult();
+ query.setCacheable(true).uniqueResult();
}
return retval;
}
@@ -680,8 +764,8 @@ public class KickstartFactory extends HibernateFactory {
Session session = null;
session = HibernateFactory.getSession();
List ksessions =
session.getNamedQuery("KickstartSession.findByServer")
- .setLong("server", sidIn.longValue())
- .list();
+ .setLong("server", sidIn.longValue())
+ .list();
if (ksessions.size() > 0) {
return (KickstartSession) ksessions.iterator().next();
}
@@ -695,15 +779,15 @@ public class KickstartFactory extends HibernateFactory {
* @return KickstartSession if found.
*/
public static KickstartSession
- lookupDefaultKickstartSessionForKickstartData(KickstartData ksdata) {
+ lookupDefaultKickstartSessionForKickstartData(KickstartData ksdata) {
Session session = null;
session = HibernateFactory.getSession();
List ksessions = session.getNamedQuery(
"KickstartSession.findDefaultKickstartSessionForKickstartData")
- .setLong("ksdata", ksdata.getId())
- .setString("mode",
KickstartSession.MODE_DEFAULT_SESSION)
- .list();
+ .setLong("ksdata", ksdata.getId())
+ .setString("mode", KickstartSession.MODE_DEFAULT_SESSION)
+ .list();
if (ksessions.size() > 0) {
return (KickstartSession) ksessions.iterator().next();
}
@@ -720,9 +804,9 @@ public class KickstartFactory extends HibernateFactory {
public static KickstartSessionState lookupSessionStateByLabel(String label) {
Session session = HibernateFactory.getSession();
KickstartSessionState retval = (KickstartSessionState) session
- .getNamedQuery("KickstartSessionState.findByLabel")
- .setString("label", label)
- .uniqueResult();
+ .getNamedQuery("KickstartSessionState.findByLabel")
+ .setString("label", label)
+ .uniqueResult();
return retval;
}
@@ -742,8 +826,8 @@ public class KickstartFactory extends HibernateFactory {
public static List lookupAllKickstartSessionsByServer(Long sidIn) {
Session session = HibernateFactory.getSession();
return session.getNamedQuery("KickstartSession.findByServer")
- .setLong("server", sidIn.longValue())
- .list();
+ .setLong("server", sidIn.longValue())
+ .list();
}
/**
@@ -754,15 +838,15 @@ public class KickstartFactory extends HibernateFactory {
public static KickstartSession lookupKickstartSessionById(Long sessionId) {
Session session = HibernateFactory.getSession();
return (KickstartSession)
- session.get(KickstartSession.class, sessionId);
+ session.get(KickstartSession.class, sessionId);
}
private static KickstartTreeType lookupKickstartTreeTypeByLabel(String label) {
Session session = HibernateFactory.getSession();
KickstartTreeType retval = (KickstartTreeType) session
- .getNamedQuery("KickstartTreeType.findByLabel")
- .setString("label", label)
- .uniqueResult();
+ .getNamedQuery("KickstartTreeType.findByLabel")
+ .setString("label", label)
+ .uniqueResult();
return retval;
}
@@ -780,7 +864,7 @@ public class KickstartFactory extends HibernateFactory {
if (channelId != null && orgId != null && treeId != null) {
session = HibernateFactory.getSession();
Query query = session.
- getNamedQuery("KickstartableTree.verifyTreeAssignment");
+ getNamedQuery("KickstartableTree.verifyTreeAssignment");
query.setLong("channel_id", channelId.longValue());
query.setLong("org_id", orgId.longValue());
query.setLong("tree_id", treeId.longValue());
@@ -799,7 +883,7 @@ public class KickstartFactory extends HibernateFactory {
public static KickstartableTree findTreeById(Long treeId, Long orgId) {
KickstartableTree retval = null;
retval = (KickstartableTree)
- HibernateFactory.getSession().load(KickstartableTree.class, treeId);
+ HibernateFactory.getSession().load(KickstartableTree.class, treeId);
if (retval != null) {
List<Channel> list =
OrgFactory.lookupById(orgId).getAccessibleChannels();
if (!list.contains(retval.getChannel())) {
@@ -817,9 +901,9 @@ public class KickstartFactory extends HibernateFactory {
public static KickstartInstallType lookupKickstartInstallTypeByLabel(String label) {
Session session = HibernateFactory.getSession();
KickstartInstallType retval = (KickstartInstallType) session
- .getNamedQuery("KickstartInstallType.findByLabel")
- .setString("label", label)
- .uniqueResult();
+ .getNamedQuery("KickstartInstallType.findByLabel")
+ .setString("label", label)
+ .uniqueResult();
return retval;
}
@@ -867,8 +951,8 @@ public class KickstartFactory extends HibernateFactory {
String query = "KickstartData.lookupByTreeId";
Session session = HibernateFactory.getSession();
return session.getNamedQuery(query)
- .setLong("kstree_id", tree.getId().longValue())
- .list();
+ .setLong("kstree_id", tree.getId().longValue())
+ .list();
}
/**
@@ -885,6 +969,17 @@ public class KickstartFactory extends HibernateFactory {
}
/**
+ * Lookup a list of all KickstartData objects that can automatically
+ * update their KS Tree.
+ * @return List of KickstartData objects if found
+ */
+ public static List<KickstartData> lookupKickstartDataByUpdateable() {
+ String query = "KickstartData.lookupByUpdateable";
+ Session session = HibernateFactory.getSession();
+ return session.getNamedQuery(query).list();
+ }
+
+ /**
* Lookup a KickstartData that has its isOrgDefault value set to true
* This may return null if there aren't any set.
*
@@ -894,10 +989,10 @@ public class KickstartFactory extends HibernateFactory {
public static KickstartData lookupOrgDefault(Org org) {
Session session = HibernateFactory.getSession();
return (KickstartData) session
- .getNamedQuery("KickstartData.findOrgDefault")
- .setEntity("org", org)
- .setString("isOrgDefault", "Y")
- .uniqueResult();
+ .getNamedQuery("KickstartData.findOrgDefault")
+ .setEntity("org", org)
+ .setString("isOrgDefault", "Y")
+ .uniqueResult();
}
/**
@@ -910,7 +1005,7 @@ public class KickstartFactory extends HibernateFactory {
String query = "KickstartVirtualizationType.findAll";
session = HibernateFactory.getSession();
retval = session.getNamedQuery(query)
- .setCacheable(true).list();
+ .setCacheable(true).list();
return retval;
}
@@ -920,12 +1015,12 @@ public class KickstartFactory extends HibernateFactory {
* @return KickstartVirtualizationType if found
*/
public static KickstartVirtualizationType
- lookupKickstartVirtualizationTypeByLabel(String label) {
+ lookupKickstartVirtualizationTypeByLabel(String label) {
Session session = HibernateFactory.getSession();
KickstartVirtualizationType retval = (KickstartVirtualizationType) session
- .getNamedQuery("KickstartVirtualizationType.findByLabel")
- .setString("label", label)
- .uniqueResult();
+ .getNamedQuery("KickstartVirtualizationType.findByLabel")
+ .setString("label", label)
+ .uniqueResult();
return retval;
}
@@ -940,7 +1035,7 @@ public class KickstartFactory extends HibernateFactory {
Iterator iter;
KickstartSessionState failed = KickstartFactory.SESSION_STATE_FAILED;
Query kickstartSessionQuery = session.getNamedQuery(
- "KickstartSession.findPendingForActions");
+ "KickstartSession.findPendingForActions");
kickstartSessionQuery.setParameterList("servers", servers);
kickstartSessionQuery.setParameterList("actions_to_delete",
actionsToDelete);
@@ -1038,7 +1133,7 @@ public class KickstartFactory extends HibernateFactory {
* @return KickstartPackge list
*/
public static List<KickstartPackage> lookupKsPackageByKsDataAndPackageName(
- KickstartData ksData, PackageName packageName) {
+ KickstartData ksData, PackageName packageName) {
return HibernateFactory.getSession()
.getNamedQuery("KickstartPackage.findByKickstartDataAndPackageName")
.setLong("ks_data", ksData.getId())
diff --git a/java/code/src/com/redhat/rhn/domain/kickstart/KickstartableTree.hbm.xml
b/java/code/src/com/redhat/rhn/domain/kickstart/KickstartableTree.hbm.xml
index 5255e31..24c2146 100644
--- a/java/code/src/com/redhat/rhn/domain/kickstart/KickstartableTree.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/kickstart/KickstartableTree.hbm.xml
@@ -71,6 +71,12 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
order by k.label]]>
</query>
+ <query name="KickstartableTree.findByChannelAndNullOrg">
+ <![CDATA[from com.redhat.rhn.domain.kickstart.KickstartableTree as k
+ where k.channel = :channel_id and k.org is null
+ order by k.lastModified]]>
+ </query>
+
<query name="KickstartableTree.findByChannel">
<![CDATA[from com.redhat.rhn.domain.kickstart.KickstartableTree as k
where k.channel.id = :channel_id and (k.org is null or
@@ -84,7 +90,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
</query>
<query name="KickstartableTree.findByOrg">
<![CDATA[from com.redhat.rhn.domain.kickstart.KickstartableTree as k
- where k.org.id = :org_id order by k.label]]>
+ where k.org.id = :org_id order by k.lastModified]]>
</query>
<query name="KickstartableTree.findAll">
<![CDATA[from com.redhat.rhn.domain.kickstart.KickstartableTree as k
diff --git a/java/code/src/com/redhat/rhn/domain/kickstart/KickstartableTree.java
b/java/code/src/com/redhat/rhn/domain/kickstart/KickstartableTree.java
index b2396fc..51f808e 100644
--- a/java/code/src/com/redhat/rhn/domain/kickstart/KickstartableTree.java
+++ b/java/code/src/com/redhat/rhn/domain/kickstart/KickstartableTree.java
@@ -277,7 +277,7 @@ public class KickstartableTree extends BaseDomainHelper {
}
else if (this.installType.isSUSE()) {
return StringUtil.addPath(getAbsolutePath(), "/boot/" +
- this.getChannel().getChannelArch().getName() +
"/loader/linux");
+ this.getChannel().getChannelArch().getName() +
"/loader/linux");
}
else {
return StringUtil.addPath(getAbsolutePath(),
"/images/pxeboot/vmlinuz");
@@ -315,7 +315,7 @@ public class KickstartableTree extends BaseDomainHelper {
}
else if (this.installType.isSUSE()) {
return new String[] {StringUtil.addPath(getAbsolutePath(), "/boot/"
+
- this.getChannel().getChannelArch().getName() +
"/loader/initrd")};
+ this.getChannel().getChannelArch().getName() +
"/loader/initrd")};
}
else {
return new String[] {
@@ -437,7 +437,7 @@ public class KickstartableTree extends BaseDomainHelper {
*/
public boolean isValid() {
return !StringUtils.isBlank(getCobblerId()) &&
- isPathsValid();
+ isPathsValid();
}
/**
diff --git a/java/code/src/com/redhat/rhn/domain/kickstart/builder/KickstartBuilder.java
b/java/code/src/com/redhat/rhn/domain/kickstart/builder/KickstartBuilder.java
index 11441af..6e42dff 100644
--- a/java/code/src/com/redhat/rhn/domain/kickstart/builder/KickstartBuilder.java
+++ b/java/code/src/com/redhat/rhn/domain/kickstart/builder/KickstartBuilder.java
@@ -33,6 +33,7 @@ import com.redhat.rhn.domain.rhnpackage.PackageFactory;
import com.redhat.rhn.domain.rhnpackage.PackageName;
import com.redhat.rhn.domain.role.RoleFactory;
import com.redhat.rhn.domain.user.User;
+import com.redhat.rhn.frontend.action.kickstart.KickstartTreeUpdateType;
import com.redhat.rhn.frontend.xmlrpc.kickstart.InvalidVirtualizationTypeException;
import com.redhat.rhn.manager.kickstart.KickstartEditCommand;
import com.redhat.rhn.manager.kickstart.KickstartScriptCreateCommand;
@@ -114,7 +115,7 @@ public class KickstartBuilder {
List<KickstartCommandName> availableOptions = KickstartFactory
.lookupAllKickstartCommandNames(ksData);
Map<String, KickstartCommandName> commandNames =
- new HashMap<String, KickstartCommandName>();
+ new HashMap<String, KickstartCommandName>();
for (KickstartCommandName cmdName : availableOptions) {
commandNames.put(cmdName.getName(), cmdName);
}
@@ -216,7 +217,7 @@ public class KickstartBuilder {
// Make sure the first line starts with %packages for sanity:
if (!(lines.get(0)).startsWith("%packages")) {
throw new KickstartParsingException("Packages section didn't start
with " +
- "%packages tag.");
+ "%packages tag.");
}
Set<KickstartPackage> ksPackagesSet = new
TreeSet<KickstartPackage>();
@@ -263,7 +264,7 @@ public class KickstartBuilder {
if (!(lines.get(0)).startsWith(prefix)) {
throw new KickstartParsingException("Pre section didn't start with
" +
- "%pre tag.");
+ "%pre tag.");
}
StringBuffer buf = new StringBuffer();
@@ -295,7 +296,7 @@ public class KickstartBuilder {
if (tokens[i].equals("--interpreter")) {
if (i == tokens.length - 1) {
throw new KickstartParsingException("Missing argument to "
+
- "--interpreter");
+ "--interpreter");
}
return tokens[i + 1];
}
@@ -310,7 +311,7 @@ public class KickstartBuilder {
if (tokens[i].equals("--nochroot")) {
if (prefix.equals("%pre")) {
throw new KickstartParsingException("Invalid %pre argument:
" +
- "--nochroot");
+ "--nochroot");
}
return "N";
}
@@ -321,7 +322,7 @@ public class KickstartBuilder {
private void storeScript(String prefix, KickstartData ksData, StringBuffer buf,
String interpreter, String chroot) {
KickstartScriptCreateCommand scriptCommand =
- new KickstartScriptCreateCommand(ksData.getId(), user);
+ new KickstartScriptCreateCommand(ksData.getId(), user);
String type = KickstartScript.TYPE_PRE;
if (prefix.equals("%post")) {
@@ -337,7 +338,7 @@ public class KickstartBuilder {
if (!user.hasRole(RoleFactory.ORG_ADMIN) &&
!user.hasRole(RoleFactory.CONFIG_ADMIN)) {
throw new PermissionException("Only Org Admins or Configuration Admins
can " +
- "modify kickstarts.");
+ "modify kickstarts.");
}
}
@@ -350,14 +351,15 @@ public class KickstartBuilder {
* @param tree KickstartableTree to associate with the new KickstartData.
* @param kickstartHost Kickstart host to use when constructing the default URL. Set
to
* null if you wish to use the url/cdrom/nfs/harddrive command values in the
kickstart
- * file instead.
- * the kickstart file and use the default for the given kickstart tree.
+ * file instead. the kickstart file and use the default for the given kickstart
tree.
+ * @param updateType way that the profile should automaticall update the ks tree
* @return KickstartData
*/
public KickstartData createFromParser(KickstartParser parser, String label,
- String virtualizationType, KickstartableTree tree, String kickstartHost) {
+ String virtualizationType, KickstartableTree tree,
+ String kickstartHost, KickstartTreeUpdateType updateType) {
KickstartData ksdata = new KickstartData();
- setupBasicInfo(label, ksdata, tree, virtualizationType);
+ setupBasicInfo(label, ksdata, tree, virtualizationType, updateType);
if (ksdata.getKsPackages() == null) {
ksdata.setKsPackages(new TreeSet<KickstartPackage>());
@@ -404,7 +406,7 @@ public class KickstartBuilder {
public void validateNewLabel(String label) {
if (StringUtils.isBlank(label)) {
ValidatorException.raiseException("kickstart.details.nolabel",
- MIN_KS_LABEL_LENGTH);
+ MIN_KS_LABEL_LENGTH);
}
KickstartData existing = labelAlreadyExists(label);
if (existing != null) {
@@ -413,7 +415,7 @@ public class KickstartBuilder {
}
if (!isLabelValid(label)) {
ValidatorException.raiseException("kickstart.error.invalidlabel",
- MIN_KS_LABEL_LENGTH);
+ MIN_KS_LABEL_LENGTH);
}
}
@@ -424,16 +426,18 @@ public class KickstartBuilder {
* @param tree the Ks tree
* @param virtType and KS virt type.
* @param fileContents to actually write out to disk.
+ * @param updateType to set for KS profile
* @return new Kickstart Raw Data object
*/
public KickstartRawData createRawData(String label,
- KickstartableTree tree,
- String fileContents,
- String virtType) {
+ KickstartableTree tree,
+ String fileContents,
+ String virtType,
+ KickstartTreeUpdateType updateType) {
checkRoles();
KickstartRawData ksdata = new KickstartRawData();
ksdata.setData(fileContents);
- setupBasicInfo(label, ksdata, tree, virtType);
+ setupBasicInfo(label, ksdata, tree, virtType, updateType);
KickstartWizardHelper cmd = new KickstartWizardHelper(user);
cmd.store(ksdata);
return ksdata;
@@ -443,13 +447,15 @@ public class KickstartBuilder {
private void setupBasicInfo(String ksLabel,
KickstartData ksdata,
KickstartableTree ksTree,
- String virtType) {
+ String virtType,
+ KickstartTreeUpdateType updateType) {
checkRoles();
validateNewLabel(ksLabel);
ksdata.setLabel(ksLabel);
ksdata.setOrg(user.getOrg());
ksdata.setActive(Boolean.TRUE);
ksdata.setOrgDefault(false);
+ ksdata.setRealUpdateType(updateType);
KickstartDefaults defaults = new KickstartDefaults();
defaults.setKstree(ksTree);
ksdata.setKickstartDefaults(defaults);
@@ -490,9 +496,9 @@ public class KickstartBuilder {
virtType = KickstartVirtualizationType.XEN_PARAVIRT;
}
KickstartVirtualizationType ksVirtType = KickstartFactory.
- lookupKickstartVirtualizationTypeByLabel(virtType);
+ lookupKickstartVirtualizationTypeByLabel(virtType);
if (ksVirtType == null) {
- throw new InvalidVirtualizationTypeException(virtType);
+ throw new InvalidVirtualizationTypeException(virtType);
}
data.getKickstartDefaults().setVirtualizationType(ksVirtType);
}
@@ -506,15 +512,17 @@ public class KickstartBuilder {
* @param downloadUrl Download location.
* @param rootPassword Root password.
* @param kickstartHost the host that is serving up the kickstart configuration
file.
+ * @param updateType how this profile will update the kickstart tree when new ones
+ * become available.
* @return Newly created KickstartData.
*/
public KickstartData create(String ksLabel, KickstartableTree tree,
String virtType, String downloadUrl, String rootPassword,
- String kickstartHost) {
+ String kickstartHost, KickstartTreeUpdateType updateType) {
checkRoles();
KickstartData ksdata = new KickstartData();
- setupBasicInfo(ksLabel, ksdata, tree, virtType);
+ setupBasicInfo(ksLabel, ksdata, tree, virtType, updateType);
KickstartCommandName kcn = null;
KickstartCommand kscmd = null;
ksdata.setCommands(new HashSet<KickstartCommand>());
@@ -638,30 +646,30 @@ public class KickstartBuilder {
}
else {
String virtType = ksdata.getKickstartDefaults().
- getVirtualizationType().getLabel();
+ getVirtualizationType().getLabel();
if (virtType.equals(KickstartVirtualizationType.XEN_PARAVIRT)) {
String data = "part /boot --fstype ext3 --size=100
--ondisk=xvda\n" +
- "part pv.00 --size=0 --grow --ondisk=xvda \n" +
- "volgroup VolGroup00 --pesize=32768 pv.00\n" +
- "logvol / --fstype ext3 --name=LogVol00 " +
- "--vgname=VolGroup00 --size=1024 --grow\n" +
- "logvol swap --fstype swap --name=LogVol01 " +
- "--vgname=VolGroup00 --size=272 --grow
--maxsize=544";
+ "part pv.00 --size=0 --grow --ondisk=xvda \n" +
+ "volgroup VolGroup00 --pesize=32768 pv.00\n" +
+ "logvol / --fstype ext3 --name=LogVol00 " +
+ "--vgname=VolGroup00 --size=1024 --grow\n" +
+ "logvol swap --fstype swap --name=LogVol01 " +
+ "--vgname=VolGroup00 --size=272 --grow --maxsize=544";
ksdata.setPartitionData(data);
}
else if (!ksdata.isLegacyKickstart()) {
String data = "part /boot --fstype=ext3 --size=200 \n" +
- "part pv.01 --size=1000 --grow \n" +
- "part swap --size=1000 --maxsize=2000 \n" +
- "volgroup myvg pv.01 \n" +
- "logvol / --vgname=myvg --name=rootvol --size=1000
--grow";
+ "part pv.01 --size=1000 --grow \n" +
+ "part swap --size=1000 --maxsize=2000 \n" +
+ "volgroup myvg pv.01 \n" +
+ "logvol / --vgname=myvg --name=rootvol --size=1000
--grow";
ksdata.setPartitionData(data);
}
else {
String data = "part /boot --fstype=ext3 --size=200 \n" +
- "part pv.01 --size=1000 --grow \n" +
- "part swap --size=1000 --maxsize=2000";
+ "part pv.01 --size=1000 --grow \n" +
+ "part swap --size=1000 --maxsize=2000";
ksdata.setPartitionData(data);
}
}
@@ -671,16 +679,16 @@ public class KickstartBuilder {
KickstartData ksdata) {
if (!ksdata.isLegacyKickstart()) {
String data = "part /boot/efi --fstype=vfat --size=100 \n" +
- "part swap --size=1000 --grow --maxsize=2000\n" +
- "part pv.01 --fstype=ext3 --size=700 --grow\n" +
- "volgroup myvg pv.01\n" +
- "logvol --vgname=myvg --name=rootvol --size=1000
--grow";
+ "part swap --size=1000 --grow --maxsize=2000\n" +
+ "part pv.01 --fstype=ext3 --size=700 --grow\n" +
+ "volgroup myvg pv.01\n" +
+ "logvol --vgname=myvg --name=rootvol --size=1000 --grow";
ksdata.setPartitionData(data);
}
else {
String data = "part /boot/efi --fstype=vfat --size=100 \n" +
- "part swap --size=1000 --grow --maxsize=2000\n" +
- "part pv.01 --fstype=ext3 --size=700 --grow";
+ "part swap --size=1000 --grow --maxsize=2000\n" +
+ "part pv.01 --fstype=ext3 --size=700 --grow";
ksdata.setPartitionData(data);
}
}
@@ -690,18 +698,18 @@ public class KickstartBuilder {
log.debug("Adding PPC specific partition info:");
if (!ksdata.isLegacyKickstart()) {
String data = "part /boot --fstype=ext3 --size=200\n" +
- "part prepboot --fstype \"PPC PReP Boot\" --size=4\n"
+
- "part swap --size=1000 --maxsize=2000 \n" +
- "part pv.01 --size=1000 --grow \n" +
- "volgroup myvg pv.01 \n" +
- "logvol / --vgname=myvg --name=rootvol --size=1000 --grow";
+ "part prepboot --fstype \"PPC PReP Boot\"
--size=4\n" +
+ "part swap --size=1000 --maxsize=2000 \n" +
+ "part pv.01 --size=1000 --grow \n" +
+ "volgroup myvg pv.01 \n" +
+ "logvol / --vgname=myvg --name=rootvol --size=1000
--grow";
ksdata.setPartitionData(data);
}
else {
String data = "part /boot --fstype=ext3 --size=200\n" +
- "part prepboot --fstype \"PPC PReP Boot\" --size=4\n" +
- "part swap --size=1000 --maxsize=2000 \n" +
- "part / --fstype=ext3 --size=700 --grow";
+ "part prepboot --fstype \"PPC PReP Boot\"
--size=4\n" +
+ "part swap --size=1000 --maxsize=2000 \n" +
+ "part / --fstype=ext3 --size=700 --grow";
ksdata.setPartitionData(data);
}
diff --git
a/java/code/src/com/redhat/rhn/domain/kickstart/builder/test/KickstartBuilderTest.java
b/java/code/src/com/redhat/rhn/domain/kickstart/builder/test/KickstartBuilderTest.java
index 404c630..47e68f2 100644
---
a/java/code/src/com/redhat/rhn/domain/kickstart/builder/test/KickstartBuilderTest.java
+++
b/java/code/src/com/redhat/rhn/domain/kickstart/builder/test/KickstartBuilderTest.java
@@ -31,6 +31,7 @@ import com.redhat.rhn.domain.kickstart.test.KickstartDataTest;
import com.redhat.rhn.domain.kickstart.test.KickstartRawDataTest;
import com.redhat.rhn.domain.kickstart.test.KickstartableTreeTest;
import com.redhat.rhn.domain.role.RoleFactory;
+import com.redhat.rhn.frontend.action.kickstart.KickstartTreeUpdateType;
import com.redhat.rhn.frontend.xmlrpc.kickstart.InvalidVirtualizationTypeException;
import com.redhat.rhn.testing.BaseTestCaseWithUser;
import com.redhat.rhn.testing.TestUtils;
@@ -63,9 +64,10 @@ public class KickstartBuilderTest extends BaseTestCaseWithUser {
tree.setInstallType(KickstartFactory.
lookupKickstartInstallTypeByLabel(KickstartInstallType.RHEL_5));
KickstartData data =
- builder.create(TestUtils.randomString(), tree,
- KickstartVirtualizationType.XEN_PARAVIRT,
- "http://localhost/ks", "redhat",
"localhost");
+ builder.create(TestUtils.randomString(), tree,
+ KickstartVirtualizationType.XEN_PARAVIRT,
+ "http://localhost/ks", "redhat",
"localhost",
+ KickstartTreeUpdateType.NONE);
assertNotNull(data);
}
@@ -77,9 +79,10 @@ public class KickstartBuilderTest extends BaseTestCaseWithUser {
tree.setInstallType(KickstartFactory.
lookupKickstartInstallTypeByLabel(KickstartInstallType.RHEL_4));
KickstartData rhel4data =
- builder.create(TestUtils.randomString(), tree,
- KickstartVirtualizationType.XEN_PARAVIRT,
- "http://localhost/ks", "redhat",
"localhost");
+ builder.create(TestUtils.randomString(),
+ tree, KickstartVirtualizationType.XEN_PARAVIRT,
+ "http://localhost/ks", "redhat",
"localhost",
+ KickstartTreeUpdateType.NONE);
String contents = FileUtils.readStringFromFile(rhel4data.getCobblerFileName());
assertTrue(contents.indexOf("langsupport") > 0);
@@ -92,9 +95,10 @@ public class KickstartBuilderTest extends BaseTestCaseWithUser {
tree.setInstallType(KickstartFactory.
lookupKickstartInstallTypeByLabel(KickstartInstallType.RHEL_5));
KickstartData rhel5data =
- builder.create(TestUtils.randomString(), tree,
- KickstartVirtualizationType.XEN_PARAVIRT,
- "http://localhost/ks", "redhat",
"localhost");
+ builder.create(TestUtils.randomString(),
+ tree, KickstartVirtualizationType.XEN_PARAVIRT,
+ "http://localhost/ks", "redhat",
"localhost",
+ KickstartTreeUpdateType.NONE);
contents = FileUtils.readStringFromFile(rhel5data.getCobblerFileName());
System.out.println("Contents: " + contents);
@@ -330,7 +334,8 @@ public class KickstartBuilderTest extends BaseTestCaseWithUser {
KickstartableTree tree = KickstartableTreeTest.createTestKickstartableTree();
//String randomLabel = RandomStringUtils.randomAlphabetic(10);
KickstartData ksData = builder.createFromParser(parser, "mykslabel",
- KickstartVirtualizationType.XEN_PARAVIRT, tree, null);
+ KickstartVirtualizationType.XEN_PARAVIRT, tree, null,
+ KickstartTreeUpdateType.NONE);
assertEquals(100, ksData.getKsPackages().size());
assertEquals(1, ksData.getScripts().size());
@@ -344,10 +349,12 @@ public class KickstartBuilderTest extends BaseTestCaseWithUser {
KickstartableTree tree = KickstartableTreeTest.createTestKickstartableTree();
builder.createFromParser(parser, "mykslabel",
- KickstartVirtualizationType.XEN_PARAVIRT, tree, null);
+ KickstartVirtualizationType.XEN_PARAVIRT, tree, null,
+ KickstartTreeUpdateType.NONE);
try {
builder.createFromParser(parser, "mykslabel",
- KickstartVirtualizationType.XEN_PARAVIRT, tree, null);
+ KickstartVirtualizationType.XEN_PARAVIRT, tree, null,
+ KickstartTreeUpdateType.NONE);
fail();
}
catch (ValidatorException e) {
@@ -361,7 +368,8 @@ public class KickstartBuilderTest extends BaseTestCaseWithUser {
KickstartableTree tree = KickstartableTreeTest.createTestKickstartableTree();
try {
- builder.createFromParser(parser, "badvirttype",
"whatever", tree, null);
+ builder.createFromParser(parser, "badvirttype",
"whatever", tree,
+ null, KickstartTreeUpdateType.NONE);
fail();
}
catch (InvalidVirtualizationTypeException e) {
@@ -375,7 +383,8 @@ public class KickstartBuilderTest extends BaseTestCaseWithUser {
KickstartableTree tree = KickstartableTreeTest.createTestKickstartableTree();
KickstartData data = builder.createFromParser(parser, "upgrade-ks",
- KickstartVirtualizationType.XEN_PARAVIRT, tree, null);
+ KickstartVirtualizationType.XEN_PARAVIRT, tree, null,
+ KickstartTreeUpdateType.NONE);
assertNotNull(data.getCommand("upgrade"));
assertNull(data.getCommand("install"));
@@ -385,9 +394,9 @@ public class KickstartBuilderTest extends BaseTestCaseWithUser {
KickstartParser parser = createKickstartParser("samplekickstart1.ks");
KickstartBuilder builder = new KickstartBuilder(user);
KickstartableTree tree = KickstartableTreeTest.createTestKickstartableTree();
- KickstartData data = builder.createFromParser(parser,
"testing-profile",
- KickstartVirtualizationType.XEN_PARAVIRT,
- tree, KICKSTART_HOST);
+ KickstartData data = builder.createFromParser(parser,
+ "testing-profile", KickstartVirtualizationType.XEN_PARAVIRT,
+ tree, KICKSTART_HOST, KickstartTreeUpdateType.NONE);
assertNull(data.getCommand("nfs"));
KickstartCommand urlCmd = data.getCommand("url");
diff --git a/java/code/src/com/redhat/rhn/domain/kickstart/test/KickstartRawDataTest.java
b/java/code/src/com/redhat/rhn/domain/kickstart/test/KickstartRawDataTest.java
index 55a6b52..1f08a7f 100644
--- a/java/code/src/com/redhat/rhn/domain/kickstart/test/KickstartRawDataTest.java
+++ b/java/code/src/com/redhat/rhn/domain/kickstart/test/KickstartRawDataTest.java
@@ -23,8 +23,8 @@ import com.redhat.rhn.domain.kickstart.KickstartableTree;
import com.redhat.rhn.domain.kickstart.builder.KickstartBuilder;
import com.redhat.rhn.domain.role.RoleFactory;
import com.redhat.rhn.domain.user.User;
+import com.redhat.rhn.frontend.action.kickstart.KickstartTreeUpdateType;
import com.redhat.rhn.manager.kickstart.KickstartCloneCommand;
-import com.redhat.rhn.manager.kickstart.cobbler.CobblerDistroCreateCommand;
import com.redhat.rhn.manager.kickstart.cobbler.CobblerProfileCreateCommand;
import com.redhat.rhn.manager.kickstart.cobbler.CobblerXMLRPCHelper;
import com.redhat.rhn.testing.BaseTestCaseWithUser;
@@ -42,13 +42,12 @@ public class KickstartRawDataTest extends BaseTestCaseWithUser {
private KickstartableTree tree;
private KickstartRawData ksdata;
- private String fileContents = "test kickstart file\n";
+ private final String fileContents = "test kickstart file\n";
public void setUp() throws Exception {
super.setUp();
user.addRole(RoleFactory.ORG_ADMIN);
tree = KickstartableTreeTest.createTestKickstartableTree();
- CobblerDistroCreateCommand cmd = new CobblerDistroCreateCommand(tree);
ksdata = createRawData(user, "boring" + TestUtils.randomString(),
tree,
fileContents,
KickstartVirtualizationType.XEN_PARAVIRT);
@@ -69,7 +68,7 @@ public class KickstartRawDataTest extends BaseTestCaseWithUser {
long id = ksdata.getId();
KickstartRawData checker = (KickstartRawData) KickstartFactory.
- lookupKickstartDataByIdAndOrg(user.getOrg(), id);
+ lookupKickstartDataByIdAndOrg(user.getOrg(), id);
assertEquals(fileContents, checker.getData());
// Setting to null zeros out in memory but
@@ -114,14 +113,14 @@ public class KickstartRawDataTest extends BaseTestCaseWithUser {
String label,
KickstartableTree tree,
String contents,
- String virtType) {
+ String virtType) {
KickstartBuilder builder = new KickstartBuilder(user);
KickstartRawData data = builder.createRawData(label, tree, contents,
- virtType);
+ virtType, KickstartTreeUpdateType.NONE);
assertNotNull(data);
assertEquals(label, data.getLabel());
assertEquals(virtType,
- data.getKickstartDefaults().getVirtualizationType().getLabel());
+ data.getKickstartDefaults().getVirtualizationType().getLabel());
assertEquals(tree, data.getKickstartDefaults().getKstree());
assertEquals(user.getOrg(), data.getOrg());
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/kickstart/AdvancedModeDetailsAction.java
b/java/code/src/com/redhat/rhn/frontend/action/kickstart/AdvancedModeDetailsAction.java
index 3080a91..4f9046f 100644
---
a/java/code/src/com/redhat/rhn/frontend/action/kickstart/AdvancedModeDetailsAction.java
+++
b/java/code/src/com/redhat/rhn/frontend/action/kickstart/AdvancedModeDetailsAction.java
@@ -61,6 +61,11 @@ public class AdvancedModeDetailsAction extends RhnAction {
private static final String KSTREE_ID_PARAM = "kstreeId";
private static final String VIRTUALIZATION_TYPES_PARAM =
"virtualizationTypes";
private static final String VIRTUALIZATION_TYPE_LABEL_PARAM =
"virtualizationTypeLabel";
+ private static final String UPDATE_ALL_PARAM = "updateAll";
+ private static final String UPDATE_RED_HAT_PARAM = "updateRedHat";
+ private static final String USING_UPDATE_ALL = "usingUpdateAll";
+ private static final String USING_UPDATE_RED_HAT = "usingUpdateRedHat";
+
private static final String CONTENTS = "contents";
private static final String FILE_UPLOAD = "fileUpload";
private static final String ORG_DEFAULT = "org_default";
@@ -71,7 +76,7 @@ public class AdvancedModeDetailsAction extends RhnAction {
private static final String UPLOAD_KEY = "manage.jsp.uploadbutton";
private static final String UPLOAD_KEY_LABEL = "uploadKey";
private static final String VALIDATION_XSD =
-
"/com/redhat/rhn/frontend/action/kickstart/validation/kickstartFileForm.xsd";
+
"/com/redhat/rhn/frontend/action/kickstart/validation/kickstartFileForm.xsd";
public static final String CSRF_TOKEN = "csrfToken";
/**
*
@@ -113,11 +118,11 @@ public class AdvancedModeDetailsAction extends RhnAction {
KickstartBuilder builder = new KickstartBuilder(user);
KickstartWizardHelper cmd = new KickstartWizardHelper(user);
KickstartableTree tree = cmd.getKickstartableTree(
- (Long)form.get(KSTREE_ID_PARAM));
+ (Long)form.get(KSTREE_ID_PARAM));
builder.update(data, data.getLabel(), tree,
data.getKickstartDefaults().getVirtualizationType().getLabel());
return
getStrutsDelegate().forwardParam(mapping.findForward("success"),
- RequestContext.KICKSTART_ID,
data.getId().toString());
+ RequestContext.KICKSTART_ID, data.getId().toString());
}
catch (ValidatorException ve) {
RhnValidationHelper.setFailedValidation(context.getRequest());
@@ -126,7 +131,7 @@ public class AdvancedModeDetailsAction extends RhnAction {
if (!isCreateMode(context.getRequest())) {
KickstartRawData ks = getKsData(context);
return getStrutsDelegate().forwardParam(mapping.
- findForward(RhnHelper.DEFAULT_FORWARD),
+ findForward(RhnHelper.DEFAULT_FORWARD),
RequestContext.KICKSTART_ID,
ks.getId().toString());
}
@@ -135,13 +140,30 @@ public class AdvancedModeDetailsAction extends RhnAction {
}
private ActionForward submit(RequestContext context,
- DynaActionForm form, ActionMapping mapping) {
+ DynaActionForm form, ActionMapping mapping) {
try {
validateInput(form, context);
User user = context.getLoggedInUser();
+ KickstartTreeUpdateType updateType = null;
KickstartWizardHelper cmd = new KickstartWizardHelper(user);
KickstartableTree tree = cmd.getKickstartableTree(
- (Long)form.get(KSTREE_ID_PARAM));
+ (Long)form.get(KSTREE_ID_PARAM));
+
+ if (form.get(UPDATE_ALL_PARAM) != null) {
+ updateType = KickstartTreeUpdateType.ALL;
+ tree = KickstartFactory.getNewestTree(updateType,
+ tree.getChannel().getId(),
+ context.getLoggedInUser().getOrg());
+ }
+ else if (form.get(UPDATE_RED_HAT_PARAM) != null) {
+ updateType = KickstartTreeUpdateType.RED_HAT;
+ tree = KickstartFactory.getNewestTree(updateType,
+ tree.getChannel().getId(),
+ context.getLoggedInUser().getOrg());
+ }
+ else {
+ updateType = KickstartTreeUpdateType.NONE;
+ }
String virtType = form.getString(VIRTUALIZATION_TYPE_LABEL_PARAM);
String label = form.getString(KICKSTART_LABEL_PARAM);
@@ -150,7 +172,8 @@ public class AdvancedModeDetailsAction extends RhnAction {
KickstartRawData ks;
String fileData = getData(context, form);
if (isCreateMode(context.getRequest())) {
- ks = builder.createRawData(label, tree, fileData, virtType);
+ ks = builder.createRawData(label, tree, fileData, virtType,
+ KickstartTreeUpdateType.NONE);
}
else {
ks = getKsData(context);
@@ -159,13 +182,15 @@ public class AdvancedModeDetailsAction extends RhnAction {
ks.setActive(Boolean.TRUE.equals(form.get(ACTIVE)));
ks.setOrgDefault(Boolean.TRUE.equals(form.get(ORG_DEFAULT)));
}
+
+ ks.setRealUpdateType(updateType);
KickstartDetailsEditAction.processCobblerFormValues(ks, form,
context.getLoggedInUser());
return
getStrutsDelegate().forwardParam(mapping.findForward("success"),
- RequestContext.KICKSTART_ID,
- ks.getId().toString());
+ RequestContext.KICKSTART_ID,
+ ks.getId().toString());
}
catch (ValidatorException ve) {
RhnValidationHelper.setFailedValidation(context.getRequest());
@@ -174,7 +199,7 @@ public class AdvancedModeDetailsAction extends RhnAction {
if (!isCreateMode(context.getRequest())) {
KickstartRawData ks = getKsData(context);
return getStrutsDelegate().forwardParam(mapping.
- findForward(RhnHelper.DEFAULT_FORWARD),
+ findForward(RhnHelper.DEFAULT_FORWARD),
RequestContext.KICKSTART_ID,
ks.getId().toString());
}
@@ -191,7 +216,7 @@ public class AdvancedModeDetailsAction extends RhnAction {
KickstartRawData data = getKsData(context);
if (!data.isValid()) {
context.getRequest().setAttribute(KickstartDetailsEditAction.INVALID,
-
Boolean.TRUE);
+ Boolean.TRUE);
return;
}
form.set(KICKSTART_LABEL_PARAM, data.getLabel());
@@ -208,14 +233,14 @@ public class AdvancedModeDetailsAction extends RhnAction {
form.set(ORG_DEFAULT, data.isOrgDefault());
form.set(ACTIVE, data.isActive());
KickstartDetailsEditAction.checkKickstartFile(context, getStrutsDelegate());
- }
+ }
}
private void loadVirtualizationTypes(KickstartWizardHelper cmd, DynaActionForm form,
RequestContext context) {
- List types = cmd.getVirtualizationTypes();
+ List<KickstartVirtualizationType> types = cmd.getVirtualizationTypes();
form.set(VIRTUALIZATION_TYPES_PARAM, types);
if (isCreateMode(context.getRequest())) {
@@ -225,17 +250,17 @@ public class AdvancedModeDetailsAction extends RhnAction {
else {
KickstartRawData data = getKsData(context);
form.set(VIRTUALIZATION_TYPE_LABEL_PARAM, data.getKickstartDefaults().
- getVirtualizationType().getLabel());
+ getVirtualizationType().getLabel());
}
}
private void loadTrees(KickstartWizardHelper cmd, DynaActionForm form,
- RequestContext context) {
+ RequestContext context) {
- List <KickstartableTree> trees = cmd.getKickstartableTrees();
+ List<KickstartableTree> trees = cmd.getKickstartableTrees();
if (trees == null || trees.size() == 0) {
context.getRequest().setAttribute(NOTREES_PARAM, Boolean.TRUE);
- form.set(KSTREE_ID_PARAM, null);
+ form.set(KSTREE_ID_PARAM, null);
}
else {
form.set(KSTREES_PARAM, trees);
@@ -252,6 +277,13 @@ public class AdvancedModeDetailsAction extends RhnAction {
else {
form.set(KSTREE_ID_PARAM, tree.getId());
}
+ KickstartTreeUpdateType updateType = data.getRealUpdateType();
+ if (updateType.equals(KickstartTreeUpdateType.ALL)) {
+ context.getRequest().setAttribute(USING_UPDATE_ALL,
"true");
+ }
+ else if (updateType.equals(KickstartTreeUpdateType.RED_HAT)) {
+ context.getRequest().setAttribute(USING_UPDATE_RED_HAT,
"true");
+ }
}
}
}
@@ -261,7 +293,7 @@ public class AdvancedModeDetailsAction extends RhnAction {
}
private void validateInput(DynaActionForm form,
- RequestContext context) {
+ RequestContext context) {
String label = form.getString(KICKSTART_LABEL_PARAM);
KickstartBuilder builder = new KickstartBuilder(context.getLoggedInUser());
if (isCreateMode(context.getRequest())) {
@@ -274,26 +306,26 @@ public class AdvancedModeDetailsAction extends RhnAction {
}
}
ValidatorResult result = RhnValidationHelper.validate(this.getClass(),
- makeValidationMap(form), null,
- VALIDATION_XSD);
- if (!result.isEmpty()) {
- throw new ValidatorException(result);
- }
-
-
- KickstartableTree tree = KickstartFactory.lookupKickstartTreeByIdAndOrg(
- (Long) form.get(KSTREE_ID_PARAM),
- context.getLoggedInUser().getOrg());
- KickstartVirtualizationType vType =
- KickstartFactory.lookupKickstartVirtualizationTypeByLabel(
- form.getString(VIRTUALIZATION_TYPE_LABEL_PARAM));
-
- Distro distro = CobblerProfileCommand.getCobblerDistroForVirtType(tree, vType,
- context.getLoggedInUser());
- if (distro == null) {
-
ValidatorException.raiseException("kickstart.cobbler.profile.invalidvirt");
- }
- }
+ makeValidationMap(form), null,
+ VALIDATION_XSD);
+ if (!result.isEmpty()) {
+ throw new ValidatorException(result);
+ }
+
+
+ KickstartableTree tree = KickstartFactory.lookupKickstartTreeByIdAndOrg(
+ (Long) form.get(KSTREE_ID_PARAM),
+ context.getLoggedInUser().getOrg());
+ KickstartVirtualizationType vType =
+ KickstartFactory.lookupKickstartVirtualizationTypeByLabel(
+ form.getString(VIRTUALIZATION_TYPE_LABEL_PARAM));
+
+ Distro distro = CobblerProfileCommand.getCobblerDistroForVirtType(tree, vType,
+ context.getLoggedInUser());
+ if (distro == null) {
+
ValidatorException.raiseException("kickstart.cobbler.profile.invalidvirt");
+ }
+ }
private String getData(RequestContext context, DynaActionForm form) {
if (context.wasDispatched(UPLOAD_KEY)) {
@@ -308,8 +340,8 @@ public class AdvancedModeDetailsAction extends RhnAction {
return (KickstartRawData) context.lookupAndBindKickstartData();
}
- private Map makeValidationMap(DynaActionForm form) {
- Map map = new HashMap();
+ private Map<String, Object> makeValidationMap(DynaActionForm form) {
+ Map<String, Object> map = new HashMap<String, Object>();
map.put(KSTREE_ID_PARAM, form.get(KSTREE_ID_PARAM));
map.put(KICKSTART_LABEL_PARAM, form.get(KICKSTART_LABEL_PARAM));
return map;
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/kickstart/CreateProfileWizardAction.java
b/java/code/src/com/redhat/rhn/frontend/action/kickstart/CreateProfileWizardAction.java
index a649472..e2cacf5 100644
---
a/java/code/src/com/redhat/rhn/frontend/action/kickstart/CreateProfileWizardAction.java
+++
b/java/code/src/com/redhat/rhn/frontend/action/kickstart/CreateProfileWizardAction.java
@@ -63,6 +63,11 @@ public class CreateProfileWizardAction extends RhnWizardAction {
private static final String NEXT_STEP_PARAM = "nextStep";
private static final String KICKSTART_LABEL_PARAM = "kickstartLabel";
private static final String KSTREE_ID_PARAM = "kstreeId";
+ private static final String USE_NEWEST_KSTREE_PARAM = "useNewestTree";
+ private static final String USE_NEWEST_RH_KSTREE_PARAM =
"useNewestRHTree";
+ private static final String CURRENT_CHANNEL_ID_PARAM = "currentChannelId";
+ private static final String RED_HAT_TREES_AVAILABLE =
"redHatTreesAvailable";
+ private static final String KSTREE_UPDATE_TYPE = "kstreeUpdateType";
private static final String DEFAULT_DOWNLOAD_PARAM = "defaultDownload";
private static final String USER_DOWNLOAD_PARAM = "userDefinedDownload";
@@ -89,13 +94,12 @@ public class CreateProfileWizardAction extends RhnWizardAction {
HttpServletResponse response) throws Exception {
if (!AclManager.hasAcl("user_role(org_admin) or
user_role(config_admin)",
- request, null)) {
+ request, null)) {
//Throw an exception with a nice error message so the user
//knows what went wrong.
LocalizationService ls = LocalizationService.getInstance();
- PermissionException pex =
- new PermissionException(
- "Only Org Admins or Configuration Admins can modify
kickstarts");
+ PermissionException pex = new PermissionException("Only Org Admins or
" +
+ "Configuration Admins can modify kickstarts");
pex.setLocalizedTitle(ls.getMessage("permission.jsp.summary.acl.header"));
pex.setLocalizedSummary(ls.getMessage("permission.jsp.summary.acl.reason5"));
throw pex;
@@ -160,8 +164,18 @@ public class CreateProfileWizardAction extends RhnWizardAction {
RequestContext ctx, HttpServletResponse response,
WizardStep step) throws Exception {
List<String> fields = new LinkedList<String>();
+ KickstartTreeUpdateType updateType = null;
fields.add(KICKSTART_LABEL_PARAM);
- fields.add(KSTREE_ID_PARAM);
+ if (form.get(USE_NEWEST_KSTREE_PARAM) != null) {
+ updateType = KickstartTreeUpdateType.ALL;
+ }
+ else if (form.get(USE_NEWEST_RH_KSTREE_PARAM) != null) {
+ updateType = KickstartTreeUpdateType.RED_HAT;
+ }
+ else {
+ updateType = KickstartTreeUpdateType.NONE;
+ fields.add(KSTREE_ID_PARAM);
+ }
if (!validateInput(form, fields, ctx)) {
return this.dispatch(step.getPrevious(), mapping, form, ctx, response);
@@ -179,24 +193,36 @@ public class CreateProfileWizardAction extends RhnWizardAction {
return this.dispatch(step.getPrevious(), mapping, form, ctx, response);
}
-
+ Long channelId = (Long) form.get(CURRENT_CHANNEL_ID_PARAM);
KickstartHelper helper = new KickstartHelper(ctx.getRequest());
-
- Long treeId = (Long) form.get(KSTREE_ID_PARAM);
KickstartWizardHelper cmd = new KickstartWizardHelper(ctx.getCurrentUser());
ActionForward retval = null;
+ KickstartableTree tree = null;
+
+ if (updateType == KickstartTreeUpdateType.NONE) {
+ tree = cmd.getKickstartableTree((Long) form
+ .get(KSTREE_ID_PARAM));
+ }
+ else {
+ tree = KickstartFactory.getNewestTree(updateType, channelId,
+ ctx.getLoggedInUser().getOrg());
+ form.set(KSTREE_ID_PARAM, tree.getId());
+ }
+
+ form.set(KSTREE_UPDATE_TYPE, updateType.getType());
form.set(PREV_STEP_PARAM, "first");
form.set(NEXT_STEP_PARAM, "third");
- form.set(DEFAULT_DOWNLOAD_LOCN, getDefaultDisplayDownloadLocation(
- cmd.getKickstartableTree(treeId), helper.getKickstartHost()));
+ form.set(
+ DEFAULT_DOWNLOAD_LOCN,
+ getDefaultDisplayDownloadLocation(tree,
+ helper.getKickstartHost()));
- KickstartableTree tree = cmd.getKickstartableTree(treeId);
ctx.getRequest().setAttribute("selectedTree", tree);
//validate we have a distro for the tree + virt type combination
String typeParam = form.getString(VIRTUALIZATION_TYPE_LABEL_PARAM);
KickstartVirtualizationType vType =
- KickstartFactory.lookupKickstartVirtualizationTypeByLabel(typeParam);
+
KickstartFactory.lookupKickstartVirtualizationTypeByLabel(typeParam);
Distro distro = CobblerProfileCommand.getCobblerDistroForVirtType(tree,
vType, ctx.getLoggedInUser());
if (distro == null) {
@@ -223,10 +249,10 @@ public class CreateProfileWizardAction extends RhnWizardAction {
List<String> fields = new LinkedList<String>();
fields.add(DEFAULT_DOWNLOAD_PARAM);
if (!validateInput(form, fields, ctx)) {
- return this.dispatch(step.getPrevious(), mapping, form, ctx, response);
+ return this.dispatch(step.getPrevious(), mapping, form, ctx, response);
}
Boolean usingDefaultLocation =
- (Boolean) form.get(DEFAULT_DOWNLOAD_PARAM);
+ (Boolean) form.get(DEFAULT_DOWNLOAD_PARAM);
if (usingDefaultLocation != null &&
usingDefaultLocation.equals(Boolean.FALSE)) {
fields.clear();
fields = new LinkedList();
@@ -262,11 +288,13 @@ public class CreateProfileWizardAction extends RhnWizardAction {
fields.add(ROOT_PASSWORD_CONFIRM_PARAM);
if (!validateInput(form, fields, ctx) ||
!passwdsEqual(form.getString(ROOT_PASSWORD_PARAM),
- form.getString(ROOT_PASSWORD_CONFIRM_PARAM), ctx)) {
+ form.getString(ROOT_PASSWORD_CONFIRM_PARAM), ctx)) {
return this.dispatch(step.getPrevious(), mapping, form, ctx, response);
}
- KickstartableTree tree = cmd.getKickstartableTree(
- (Long)form.get(KSTREE_ID_PARAM));
+ KickstartableTree tree = cmd.getKickstartableTree((Long) form
+ .get(KSTREE_ID_PARAM));
+ KickstartTreeUpdateType updateType = KickstartTreeUpdateType
+ .find((String) form.get(KSTREE_UPDATE_TYPE));
Boolean useDefault = (Boolean) form.get(DEFAULT_DOWNLOAD_PARAM);
String downloadUrl = null;
if (useDefault != null && Boolean.TRUE.equals(useDefault)) {
@@ -275,16 +303,16 @@ public class CreateProfileWizardAction extends RhnWizardAction {
else {
downloadUrl = form.getString(USER_DOWNLOAD_PARAM);
}
- log.debug("Using default download location: " + downloadUrl);
+ log.debug("Using download location: " + downloadUrl);
String ksLabel = form.getString(KICKSTART_LABEL_PARAM);
String rootPass = form.getString(ROOT_PASSWORD_PARAM);
String virtType = form.getString(VIRTUALIZATION_TYPE_LABEL_PARAM);
KickstartBuilder builder = new KickstartBuilder(ctx.getCurrentUser());
- KickstartData ksdata = builder.create(ksLabel, tree, virtType, downloadUrl,
- rootPass, helper.getKickstartHost());
+ KickstartData ksdata = builder.create(ksLabel, tree, virtType,
+ downloadUrl, rootPass, helper.getKickstartHost(), updateType);
String url = ctx.getRequest().getContextPath() + "/kickstart/" +
- "KickstartDetailsEdit.do?ksid=" + ksdata.getId();
+ "KickstartDetailsEdit.do?ksid=" + ksdata.getId();
response.sendRedirect(url);
return null;
}
@@ -294,7 +322,13 @@ public class CreateProfileWizardAction extends RhnWizardAction {
Long currentChanId = (Long) form.get(CURR_CHAN_ID);
Long prevChanId = (Long) form.get(PREV_CHAN_ID);
if (currentChanId != null && prevChanId != null) {
- List trees = cmd.getTrees(currentChanId);
+ List<KickstartableTree> trees = cmd.getTrees(currentChanId);
+ for (KickstartableTree tree : trees) {
+ if (tree.getOrg() == null) {
+ request.setAttribute(RED_HAT_TREES_AVAILABLE, "true");
+ break;
+ }
+ }
if (trees == null || trees.size() == 0) {
request.setAttribute(NOTREES_PARAM, "true");
}
@@ -302,8 +336,7 @@ public class CreateProfileWizardAction extends RhnWizardAction {
form.set(KSTREES_PARAM, trees);
if (!currentChanId.equals(prevChanId)) {
form.set(PREV_CHAN_ID, currentChanId);
- KickstartableTree tree = (KickstartableTree)
- trees.get(trees.size() - 1);
+ KickstartableTree tree = trees.get(trees.size() - 1);
form.set(KSTREE_ID_PARAM, tree.getId());
}
}
@@ -318,7 +351,7 @@ public class CreateProfileWizardAction extends RhnWizardAction {
List types = cmd.getVirtualizationTypes();
form.set(VIRTUALIZATION_TYPES_PARAM, types);
form.set(VIRTUALIZATION_TYPE_LABEL_PARAM,
- KickstartVirtualizationType.NONE);
+ KickstartVirtualizationType.NONE);
}
private void setCurrentChannel(DynaActionForm form) {
@@ -340,7 +373,7 @@ public class CreateProfileWizardAction extends RhnWizardAction {
private boolean validateInput(DynaActionForm form, List fieldNames,
RequestContext ctx) {
ActionErrors errs =
- RhnValidationHelper.validateDynaActionForm(this, form, fieldNames);
+ RhnValidationHelper.validateDynaActionForm(this, form, fieldNames);
boolean retval = errs.size() == 0;
if (!retval) {
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/kickstart/KickstartSoftwareEditAction.java
b/java/code/src/com/redhat/rhn/frontend/action/kickstart/KickstartSoftwareEditAction.java
index 3f7f3d5..5e7d953 100644
---
a/java/code/src/com/redhat/rhn/frontend/action/kickstart/KickstartSoftwareEditAction.java
+++
b/java/code/src/com/redhat/rhn/frontend/action/kickstart/KickstartSoftwareEditAction.java
@@ -20,6 +20,7 @@ import com.redhat.rhn.domain.kickstart.KickstartData;
import com.redhat.rhn.domain.kickstart.KickstartFactory;
import com.redhat.rhn.domain.kickstart.KickstartableTree;
import com.redhat.rhn.domain.kickstart.RepoInfo;
+import
com.redhat.rhn.domain.org.Org;
import com.redhat.rhn.frontend.struts.LabelValueEnabledBean;
import com.redhat.rhn.frontend.struts.RequestContext;
import com.redhat.rhn.manager.channel.ChannelManager;
@@ -33,8 +34,8 @@ import org.apache.struts.action.DynaActionForm;
import org.apache.struts.util.LabelValueBean;
import org.cobbler.Distro;
+import java.util.Collection;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@@ -59,6 +60,11 @@ public class KickstartSoftwareEditAction extends
BaseKickstartEditAction {
public static final String STORED_CHILD_CHANNELS =
"stored_child_channels";
public static final String POSSIBLE_REPOS = "possibleRepos";
public static final String SELECTED_REPOS = "selectedRepos";
+ public static final String USE_NEWEST_KSTREE_PARAM = "useNewestTree";
+ public static final String USE_NEWEST_RH_KSTREE_PARAM = "useNewestRHTree";
+ public static final String RED_HAT_TREES_AVAILABLE =
"redHatTreesAvailable";
+ public static final String USING_NEWEST = "usingNewest";
+ public static final String USING_NEWEST_RH = "usingNewestRH";
protected String getSuccessKey() {
return "kickstart.software.success";
}
@@ -71,24 +77,26 @@ public class KickstartSoftwareEditAction extends
BaseKickstartEditAction {
String fieldChanged = form.getString("fieldChanged");
KickstartEditCommand cmd = (KickstartEditCommand) cmdIn;
KickstartableTree tree =
cmd.getKickstartData().getKickstartDefaults().getKstree();
+ KickstartTreeUpdateType updateType = cmd.getKickstartData()
+ .getRealUpdateType();
KickstartableTree selectedTree;
- List trees = null;
+ List<KickstartableTree> trees = null;
Long incomingChannelId = (Long) form.get(CHANNEL);
Long channelId = incomingChannelId;
if (fieldChanged.equals("channel")) {
trees = cmd.getTrees(incomingChannelId, ctx.getCurrentUser().getOrg());
KickstartableTree kstree = null;
if (trees != null && trees.size() > 0) {
- kstree = (KickstartableTree)
- trees.get(trees.size() - 1);
+ kstree = trees.get(trees.size() - 1);
form.set(TREE, kstree.getId());
}
if (kstree == null && (trees != null && trees.size() > 0))
{
kstree = KickstartFactory.lookupKickstartTreeByIdAndOrg(tree.getId(),
- ctx.getCurrentUser().getOrg());
+ ctx.getCurrentUser().getOrg());
}
setupUrl(ctx, form, kstree);
selectedTree = kstree;
+ updateType = KickstartTreeUpdateType.NONE;
}
else {
if (form.get(CHANNEL) != null) {
@@ -102,17 +110,30 @@ public class KickstartSoftwareEditAction extends
BaseKickstartEditAction {
KickstartableTree kstree = null;
if (trees != null && trees.size() > 0) {
kstree = KickstartFactory.lookupKickstartTreeByIdAndOrg(tree.getId(),
- ctx.getCurrentUser().getOrg());
+ ctx.getCurrentUser().getOrg());
}
setupUrl(ctx, form, kstree);
selectedTree = kstree;
}
if (fieldChanged.equals("kstree")) {
KickstartableTree kstree =
- KickstartFactory.lookupKickstartTreeByIdAndOrg((Long) form.get(TREE),
- ctx.getCurrentUser().getOrg());
+ KickstartFactory.lookupKickstartTreeByIdAndOrg((Long)
form.get(TREE),
+ ctx.getCurrentUser().getOrg());
setupUrl(ctx, form, kstree);
selectedTree = kstree;
+ updateType = KickstartTreeUpdateType.NONE;
+ }
+ if (updateType.equals(KickstartTreeUpdateType.ALL)) {
+ ctx.getRequest().setAttribute(USING_NEWEST, "true");
+ }
+ else if (updateType.equals(KickstartTreeUpdateType.RED_HAT)) {
+ ctx.getRequest().setAttribute(USING_NEWEST_RH, "true");
+ }
+ for (KickstartableTree tr : trees) {
+ if (tr.getOrg() == null) {
+ ctx.getRequest().setAttribute(RED_HAT_TREES_AVAILABLE,
"true");
+ break;
+ }
}
ctx.getRequest().setAttribute(TREES, trees);
if (trees == null || trees.size() == 0) {
@@ -123,10 +144,9 @@ public class KickstartSoftwareEditAction extends
BaseKickstartEditAction {
setupChildChannels(ctx, channelId, cmd);
// Setup list of releases and channels
- List channels = new LinkedList();
- Iterator i = cmd.getAvailableChannels().iterator();
- while (i.hasNext()) {
- Channel c = (Channel) i.next();
+ List<LabelValueBean> channels = new LinkedList<LabelValueBean>();
+ Collection<Channel> channelList = cmd.getAvailableChannels();
+ for (Channel c : channelList) {
log.debug("channel : " + c);
LabelValueBean lb = lv(c.getName(), c.getId().toString());
if (!channels.contains(lb)) {
@@ -153,8 +173,9 @@ public class KickstartSoftwareEditAction extends
BaseKickstartEditAction {
KickstartEditCommand cmd) {
log.debug("ChannelId: " + channelId);
// Get all available child channels for this user
- List childchannels = ChannelManager.userAccessibleChildChannels(
- ctx.getCurrentUser().getOrg().getId(), channelId);
+ List<Channel> childchannels = ChannelManager
+ .userAccessibleChildChannels(
+ ctx.getCurrentUser().getOrg().getId(), channelId);
if (childchannels == null || childchannels.size() == 0) {
ctx.getRequest().setAttribute("nochildchannels",
"true");
}
@@ -162,11 +183,10 @@ public class KickstartSoftwareEditAction extends
BaseKickstartEditAction {
ctx.getRequest().setAttribute(AVAIL_CHILD_CHANNELS, childchannels);
// Setup the list of selected child channels
- HashMap selectedChannels = new HashMap();
+ HashMap<Long, Long> selectedChannels = new HashMap<Long, Long>();
if (cmd.getKickstartData().getChildChannels() != null) {
- Iterator i = cmd.getKickstartData().getChildChannels().iterator();
- while (i.hasNext()) {
- Channel c = (Channel) i.next();
+ Set<Channel> channelSet = cmd.getKickstartData().getChildChannels();
+ for (Channel c : channelSet) {
selectedChannels.put(c.getId(), c.getId());
}
}
@@ -182,11 +202,11 @@ public class KickstartSoftwareEditAction extends
BaseKickstartEditAction {
* @param kstree the kickstart tree
*/
private void setupUrl(RequestContext ctx, DynaActionForm form,
- KickstartableTree kstree) {
+ KickstartableTree kstree) {
if (kstree != null) {
KickstartHelper kshelper = new KickstartHelper(ctx.getRequest());
- form.set(URL, kstree.getDefaultDownloadLocation(
- kshelper.getKickstartHost()));
+ form.set(URL, kstree.getDefaultDownloadLocation(kshelper
+ .getKickstartHost()));
}
else {
form.set(URL, "");
@@ -204,34 +224,50 @@ public class KickstartSoftwareEditAction extends
BaseKickstartEditAction {
KickstartData ksdata = cmdIn.getKickstartData();
RequestContext ctx = new RequestContext(request);
+ KickstartTreeUpdateType updateType = null;
+ KickstartableTree tree = null;
+ Long channelId = (Long) form.get(CHANNEL);
+ String url = form.getString(URL);
+ Org org = ctx.getLoggedInUser().getOrg();
+
+ if (form.get(USE_NEWEST_KSTREE_PARAM) != null) {
+ updateType = KickstartTreeUpdateType.ALL;
+ tree = KickstartFactory.getNewestTree(updateType, channelId, org);
+ }
+ else if (form.get(USE_NEWEST_RH_KSTREE_PARAM) != null) {
+ updateType = KickstartTreeUpdateType.RED_HAT;
+ tree = KickstartFactory.getNewestTree(updateType, channelId, org);
+ }
+ else {
+ updateType = KickstartTreeUpdateType.NONE;
+ tree = KickstartFactory.lookupKickstartTreeByIdAndOrg(
+ (Long) form.get(TREE), org);
+ }
- KickstartableTree tree = KickstartFactory.lookupKickstartTreeByIdAndOrg(
- (Long) form.get(TREE),
- ctx.getLoggedInUser().getOrg());
if (tree == null) {
return new ValidatorError("kickstart.softwaredit.tree.required");
}
Distro distro = CobblerProfileCommand.getCobblerDistroForVirtType(tree,
- cmdIn.getKickstartData().getKickstartDefaults().getVirtualizationType(),
+ ksdata.getKickstartDefaults().getVirtualizationType(),
ctx.getLoggedInUser());
if (distro == null) {
return new
ValidatorError("kickstart.cobbler.profile.invalidtreeforvirt");
}
KickstartEditCommand cmd = (KickstartEditCommand) cmdIn;
- ValidatorError ve = cmd.updateKickstartableTree(
- (Long) form.get(CHANNEL), cmdIn.getUser().getOrg().getId(),
- (Long) form.get(TREE),
- form.getString(URL));
+ ValidatorError ve = cmd.updateKickstartableTree(channelId, org.getId(),
+ tree.getId(), url);
if (ve == null) {
String [] repos = form.getStrings(SELECTED_REPOS);
cmd.updateRepos(repos);
}
- CobblerProfileEditCommand cpec = new CobblerProfileEditCommand(
- cmdIn.getKickstartData(), ctx.getLoggedInUser());
+ ksdata.setRealUpdateType(updateType);
+
+ CobblerProfileEditCommand cpec = new CobblerProfileEditCommand(ksdata,
+ ctx.getLoggedInUser());
cpec.store();
// Process the selected child channels
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/kickstart/KickstartTreeUpdateType.java
b/java/code/src/com/redhat/rhn/frontend/action/kickstart/KickstartTreeUpdateType.java
new file mode 100644
index 0000000..fc5462b
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/frontend/action/kickstart/KickstartTreeUpdateType.java
@@ -0,0 +1,60 @@
+package com.redhat.rhn.frontend.action.kickstart;
+
+/**
+ * types of kickstart tree update strategies
+ * @author sherr
+ */
+public enum KickstartTreeUpdateType {
+ ALL("all"), RED_HAT("red_hat"), NONE("none");
+ private String type;
+
+ /**
+ * Create a new KickstartTreeUpdateType
+ * @param updateType
+ */
+ KickstartTreeUpdateType(String updateType) {
+ type = updateType;
+ }
+
+ /**
+ * get the type
+ * @return the registration type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Set the type
+ * @param updateType the update type to set
+ */
+ public void setType(String updateType) {
+ type = updateType;
+ }
+
+ /**
+ * Find the appropriate KTUT for a given string
+ * @param typeIn the string to search for
+ * @return the KTUT
+ */
+ public static KickstartTreeUpdateType find(String typeIn) {
+ if (typeIn.equals(ALL.type)) {
+ return ALL;
+ }
+ else if (typeIn.equals(RED_HAT.type)) {
+ return RED_HAT;
+ }
+ else {
+ return NONE;
+ }
+ }
+
+ /**
+ * Standard toString function
+ * @return the String to return
+ */
+ public String toString() {
+ return getType();
+ }
+
+}
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/kickstart/validation/kickstartCreateWizardForm.xsd
b/java/code/src/com/redhat/rhn/frontend/action/kickstart/validation/kickstartCreateWizardForm.xsd
index 9a79a01..bcc70d4 100644
---
a/java/code/src/com/redhat/rhn/frontend/action/kickstart/validation/kickstartCreateWizardForm.xsd
+++
b/java/code/src/com/redhat/rhn/frontend/action/kickstart/validation/kickstartCreateWizardForm.xsd
@@ -15,6 +15,18 @@
<minInclusive value="1" />
</simpleType>
</attribute>
+ <attribute name="determineNewRH">
+ <simpleType baseType="string">
+ <minLength value="1" />
+ <maxLength value="32" />
+ </simpleType>
+ </attribute>
+ <attribute name="determineNew">
+ <simpleType baseType="string">
+ <minLength value="1" />
+ <maxLength value="32" />
+ </simpleType>
+ </attribute>
<attribute name="defaultDownload">
<simpleType baseType="string">
<minLength value="4" />
@@ -38,4 +50,4 @@
<maxLength value="32" />
</simpleType>
</attribute>
-</schema>
\ No newline at end of file
+</schema>
diff --git a/java/code/src/com/redhat/rhn/frontend/dto/kickstart/KickstartDto.java
b/java/code/src/com/redhat/rhn/frontend/dto/kickstart/KickstartDto.java
index caa4fed..26eb89d 100644
--- a/java/code/src/com/redhat/rhn/frontend/dto/kickstart/KickstartDto.java
+++ b/java/code/src/com/redhat/rhn/frontend/dto/kickstart/KickstartDto.java
@@ -40,6 +40,7 @@ public class KickstartDto extends BaseDto {
private int virtCpus;
private String virtBridge;
private String macAddress;
+ private String updateType;
/**
@@ -273,4 +274,18 @@ public class KickstartDto extends BaseDto {
public void setMacAddress(String macAddressIn) {
this.macAddress = macAddressIn;
}
+
+ /**
+ * @return Returns the update type
+ */
+ public String getUpdateType() {
+ return updateType;
+ }
+
+ /**
+ * @param updateTypeIn the updateType to set
+ */
+ public void setUpdateType(String updateTypeIn) {
+ this.updateType = updateTypeIn;
+ }
}
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 fe8474d..ce1020a 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
@@ -6973,6 +6973,15 @@ Follow this url to see the full list of inactive systems:
<trans-unit id="api.kickstart.invalidkickstartlabel">
<source>Invalid kickstart label: {0}</source>
</trans-unit>
+ <trans-unit id="api.kickstart.invalidUpdateType">
+ <source>Invalid update type: {0}</source>
+ </trans-unit>
+ <trans-unit id="api.kickstart.invalidUpdateTypeAndTree">
+ <source>If update type is red_hat the kickstartable tree you start with
must be provided by Red Hat. This tree is not: {0}</source>
+ </trans-unit>
+ <trans-unit id="api.kickstart.invalidUpdateTypeAndNoBase">
+ <source>The kickstartable tree {0} has no base channel. The only valid
update type with a no-base kickstartable tree is 'none'.</source>
+ </trans-unit>
<trans-unit id="api.package.invalidpackagearch">
<source>The package arch specified ({0}) is invalid.</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 806b832..5f2c1c7 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
@@ -10366,6 +10366,18 @@ the <strong>Red Hat Enterprise Linux System
Administration Guide.</stro
<context
context-type="sourcefile">/rhn/kickstart/CreateProfileWizard.do</context>
</context-group>
</trans-unit>
+ <trans-unit id="kickstart.jsp.create.wizard.kstree.always_new_RH">
+ <source>Always use the newest Red Hat Tree for this base
channel.</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/kickstart/CreateProfileWizard.do</context>
+ </context-group>
+ </trans-unit>
+ <trans-unit id="kickstart.jsp.create.wizard.kstree.always_new">
+ <source>Always use the newest Tree for this base channel.
"Newest" is determined by the date it was last modified.</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/kickstart/CreateProfileWizard.do</context>
+ </context-group>
+ </trans-unit>
<trans-unit id="wizard.jsp.next.step">
<source>Next</source>
<context-group name="ctx">
diff --git
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/InvalidUpdateTypeAndKickstartTreeException.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/InvalidUpdateTypeAndKickstartTreeException.java
new file mode 100644
index 0000000..1bab37a
--- /dev/null
+++
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/InvalidUpdateTypeAndKickstartTreeException.java
@@ -0,0 +1,37 @@
+/**
+ * Copyright (c) 2009--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.xmlrpc.kickstart;
+
+import com.redhat.rhn.FaultException;
+import com.redhat.rhn.common.localization.LocalizationService;
+
+
+/**
+ * InvalidKickstartLabelException
+ * @version $Rev$
+ */
+public class InvalidUpdateTypeAndKickstartTreeException extends FaultException {
+
+ /**
+ * Constructor
+ * @param tree the KickstartableTree label
+ */
+ public InvalidUpdateTypeAndKickstartTreeException(String tree) {
+ super(6134, "invalidKickstartLabel", LocalizationService.getInstance()
+ .getMessage("api.kickstart.invalidUpdateTypeAndTree",
+ new Object[] { tree }));
+ }
+
+}
diff --git
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/InvalidUpdateTypeAndNoBaseTreeException.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/InvalidUpdateTypeAndNoBaseTreeException.java
new file mode 100644
index 0000000..d703c9f
--- /dev/null
+++
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/InvalidUpdateTypeAndNoBaseTreeException.java
@@ -0,0 +1,37 @@
+/**
+ * Copyright (c) 2009--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.xmlrpc.kickstart;
+
+import com.redhat.rhn.FaultException;
+import com.redhat.rhn.common.localization.LocalizationService;
+
+
+/**
+ * InvalidKickstartLabelException
+ * @version $Rev$
+ */
+public class InvalidUpdateTypeAndNoBaseTreeException extends FaultException {
+
+ /**
+ * Constructor
+ * @param tree the KickstartableTree label
+ */
+ public InvalidUpdateTypeAndNoBaseTreeException(String tree) {
+ super(6134, "invalidKickstartLabel", LocalizationService.getInstance()
+ .getMessage("api.kickstart.invalidUpdateTypeAndNoBase",
+ new Object[] { tree }));
+ }
+
+}
diff --git
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/InvalidUpdateTypeException.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/InvalidUpdateTypeException.java
new file mode 100644
index 0000000..eb739c7
--- /dev/null
+++
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/InvalidUpdateTypeException.java
@@ -0,0 +1,37 @@
+/**
+ * Copyright (c) 2009--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.xmlrpc.kickstart;
+
+import com.redhat.rhn.FaultException;
+import com.redhat.rhn.common.localization.LocalizationService;
+
+
+/**
+ * InvalidKickstartLabelException
+ * @version $Rev$
+ */
+public class InvalidUpdateTypeException extends FaultException {
+
+ /**
+ * Constructor
+ * @param updateType the update type label
+ */
+ public InvalidUpdateTypeException(String updateType) {
+ super(6134, "invalidKickstartLabel", LocalizationService.getInstance()
+ .getMessage("api.kickstart.invalidUpdateType",
+ new Object[] { updateType }));
+ }
+
+}
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/KickstartHandler.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/KickstartHandler.java
index 882b8f0..5f0eeed 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/KickstartHandler.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/KickstartHandler.java
@@ -32,6 +32,7 @@ import
com.redhat.rhn.domain.org.Org;
import com.redhat.rhn.domain.role.RoleFactory;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.frontend.action.kickstart.KickstartIpRangeFilter;
+import com.redhat.rhn.frontend.action.kickstart.KickstartTreeUpdateType;
import com.redhat.rhn.frontend.dto.kickstart.KickstartDto;
import com.redhat.rhn.frontend.xmlrpc.BaseHandler;
import com.redhat.rhn.frontend.xmlrpc.PermissionCheckFailureException;
@@ -70,7 +71,7 @@ public class KickstartHandler extends BaseHandler {
public List listKickstartableTrees(String sessionKey,
String channelLabel) {
return new KickstartTreeHandler().
- list(sessionKey, channelLabel);
+ list(sessionKey, channelLabel);
}
/**
@@ -161,6 +162,54 @@ public class KickstartHandler extends BaseHandler {
public int importFile(String sessionKey, String profileLabel,
String virtualizationType, String kickstartableTreeLabel,
String kickstartHost, String kickstartFileContents) {
+ return importFile(sessionKey, profileLabel, virtualizationType,
+ kickstartableTreeLabel, kickstartHost, kickstartFileContents,
+ getDefaultUpdateType());
+ }
+
+ /**
+ * Import a kickstart profile into RHN, overriding the
+ * url/nfs/harddrive/cdrom command in the file and replacing it with the
+ * default URL for the kickstartable tree and kickstart host specified.
+ *
+ * @param sessionKey User's session key.
+ * @param profileLabel Label for the new kickstart profile.
+ * @param virtualizationType Virtualization type, or none.
+ * @param kickstartableTreeLabel Label of a kickstartable tree.
+ * @param kickstartHost Kickstart hostname (of a satellite or proxy) used to
+ * construct the default download URL for the new kickstart profile. Using
+ * this option signifies that this default URL will be used instead of any
+ * url/nfs/cdrom/harddrive commands in the kickstart file itself.
+ * @param kickstartFileContents Contents of a kickstart file.
+ * @param updateType Set the automatic ks tree update strategy
+ * for the profile. Valid choices are "red_hat", "none",
"all".
+ * @return 1 if successful, exception otherwise.
+ *
+ * @xmlrpc.doc Import a kickstart profile into RHN.
+ * @xmlrpc.param #session_key()
+ * @xmlrpc.param #param_desc("string", "profileLabel",
"Label for the new
+ * kickstart profile.")
+ * @xmlrpc.param #param_desc("string", "virtualizationType",
"none, para_host,
+ * qemu, xenfv or xenpv.")
+ * @xmlrpc.param #param_desc("string", "kickstartableTreeLabel",
"Label of a
+ * kickstartable tree to associate the new profile with.")
+ * @xmlrpc.param #param_desc("string", "kickstartHost",
"Kickstart hostname
+ * (of a satellite or proxy) used to construct the default download URL for
+ * the new kickstart profile. Using this option signifies that this default
+ * URL will be used instead of any url/nfs/cdrom/harddrive commands in the
+ * kickstart file itself.")
+ * @xmlrpc.param #param_desc("string", "kickstartFileContents",
"Contents of
+ * the kickstart file to import.")
+ * @xmlrpc.param #param_desc("string", "updateType", "Should
the profile update
+ * itself to use the newest tree available? Possible values are: none (default),
+ * red_hat (only use Kickstart Trees synced from Red Hat), or all (includes
+ * custom Kickstart Trees).")
+ * @xmlrpc.returntype #return_int_success()
+ */
+ public int importFile(String sessionKey, String profileLabel,
+ String virtualizationType, String kickstartableTreeLabel,
+ String kickstartHost, String kickstartFileContents,
+ String updateType) {
User loggedInUser = getLoggedInUser(sessionKey);
@@ -173,9 +222,11 @@ public class KickstartHandler extends BaseHandler {
throw new NoSuchKickstartTreeException(kickstartableTreeLabel);
}
+ KickstartTreeUpdateType updateTree = getUpdateType(updateType, tree);
+
try {
builder.createFromParser(parser, profileLabel, virtualizationType,
- tree, kickstartHost);
+ tree, kickstartHost, updateTree);
}
catch (PermissionException e) {
throw new PermissionCheckFailureException(e);
@@ -198,6 +249,8 @@ public class KickstartHandler extends BaseHandler {
* @param kickstartHost Kickstart hostname (of a satellite or proxy) used to
* construct the default download URL for the new kickstart profile.
* @param rootPassword Root password.
+ * @param updateType Set the automatic ks tree update strategy
+ * for the profile. Valid choices are "red_hat", "none",
"all".
* @return 1 if successful, exception otherwise.
*
* @xmlrpc.doc Import a kickstart profile into RHN.
@@ -212,11 +265,15 @@ public class KickstartHandler extends BaseHandler {
* (of a satellite or proxy) used to construct the default download URL for
* the new kickstart profile.")
* @xmlrpc.param #param_desc("string", "rootPassword", "Root
password.")
+ * @xmlrpc.param #param_desc("string", "updateType", "Should
the profile update
+ * itself to use the newest tree available? Possible values are: none (default),
+ * red_hat (only use Kickstart Trees synced from Red Hat), or all (includes
+ * custom Kickstart Trees).")
* @xmlrpc.returntype #return_int_success()
*/
public int createProfile(String sessionKey, String profileLabel,
String virtualizationType, String kickstartableTreeLabel,
- String kickstartHost, String rootPassword) {
+ String kickstartHost, String rootPassword, String updateType) {
User loggedInUser = getLoggedInUser(sessionKey);
KickstartBuilder builder = new KickstartBuilder(loggedInUser);
@@ -226,11 +283,12 @@ public class KickstartHandler extends BaseHandler {
if (tree == null) {
throw new NoSuchKickstartTreeException(kickstartableTreeLabel);
}
+ KickstartTreeUpdateType updateTree = getUpdateType(updateType, tree);
String downloadUrl = tree.getDefaultDownloadLocation(kickstartHost);
try {
builder.create(profileLabel, tree, virtualizationType, downloadUrl,
- rootPassword, RhnXmlRpcServer.getServerName());
+ rootPassword, RhnXmlRpcServer.getServerName(), updateTree);
}
catch (PermissionException e) {
throw new PermissionCheckFailureException(e);
@@ -243,6 +301,41 @@ public class KickstartHandler extends BaseHandler {
}
/**
+ * Create a new kickstart profile using the default download URL for the
+ * kickstartable tree and kickstart host specified.
+ *
+ * @param sessionKey User's session key.
+ * @param profileLabel Label for the new kickstart profile.
+ * @param virtualizationType Virtualization type, or none.
+ * @param kickstartableTreeLabel Label of a kickstartable tree.
+ * @param kickstartHost Kickstart hostname (of a satellite or proxy) used to
+ * construct the default download URL for the new kickstart profile.
+ * @param rootPassword Root password.
+ * @return 1 if successful, exception otherwise.
+ *
+ * @xmlrpc.doc Import a kickstart profile into RHN.
+ * @xmlrpc.param #session_key()
+ * @xmlrpc.param #param_desc("string", "profileLabel" "Label
for the new
+ * kickstart profile.")
+ * @xmlrpc.param #param_desc("string", "virtualizationType",
"none, para_host,
+ * qemu, xenfv or xenpv.")
+ * @xmlrpc.param #param_desc("string", "kickstartableTreeLabel",
"Label of a
+ * kickstartable tree to associate the new profile with.")
+ * @xmlrpc.param #param_desc("string", "kickstartHost",
"Kickstart hostname
+ * (of a satellite or proxy) used to construct the default download URL for
+ * the new kickstart profile.")
+ * @xmlrpc.param #param_desc("string", "rootPassword", "Root
password.")
+ * @xmlrpc.returntype #return_int_success()
+ */
+ public int createProfile(String sessionKey, String profileLabel,
+ String virtualizationType, String kickstartableTreeLabel,
+ String kickstartHost, String rootPassword) {
+ return createProfile(sessionKey, profileLabel, virtualizationType,
+ kickstartableTreeLabel, kickstartHost, rootPassword,
+ getDefaultUpdateType());
+ }
+
+ /**
* Create a new kickstart profile with a custom download URL.
*
* @param sessionKey User's session key.
@@ -271,6 +364,46 @@ public class KickstartHandler extends BaseHandler {
String profileLabel, String virtualizationType,
String kickstartableTreeLabel, String downloadUrl,
String rootPassword) {
+ return createProfileWithCustomUrl(sessionKey, profileLabel,
+ virtualizationType, kickstartableTreeLabel, downloadUrl,
+ rootPassword, getDefaultUpdateType());
+ }
+
+ /**
+ * Create a new kickstart profile with a custom download URL.
+ *
+ * @param sessionKey User's session key.
+ * @param profileLabel Label for the new kickstart profile.
+ * @param virtualizationType Virtualization type, or none.
+ * @param kickstartableTreeLabel Label of a kickstartable tree.
+ * @param downloadUrl Download URL, or 'default' to use the kickstart
tree's
+ * default URL.
+ * @param rootPassword Root password.
+ * @param updateType Set the automatic ks tree update strategy
+ * for the profile. Valid choices are "red_hat", "none",
"all".
+ * @return 1 if successful, exception otherwise.
+ *
+ * @xmlrpc.doc Import a kickstart profile into RHN.
+ * @xmlrpc.param #session_key()
+ * @xmlrpc.param #param_desc("string", "profileLabel",
"Label for the new
+ * kickstart profile.")
+ * @xmlrpc.param #param_desc("string", "virtualizationType",
"none, para_host,
+ * qemu, xenfv or xenpv.")
+ * @xmlrpc.param #param_desc("string", "kickstartableTreeLabel",
"Label of a
+ * kickstartable tree to associate the new profile with.")
+ * @xmlrpc.param #param_desc("boolean", "downloadUrl",
"Download URL, or
+ * 'default' to use the kickstart tree's default URL.")
+ * @xmlrpc.param #param_desc("string", "rootPassword", "Root
password.")
+ * @xmlrpc.param #param_desc("string", "updateType", "Should
the profile update
+ * itself to use the newest tree available? Possible values are: none (default),
+ * red_hat (only use Kickstart Trees synced from Red Hat), or all (includes
+ * custom Kickstart Trees).")
+ * @xmlrpc.returntype #return_int_success()
+ */
+ public int createProfileWithCustomUrl(String sessionKey,
+ String profileLabel, String virtualizationType,
+ String kickstartableTreeLabel, String downloadUrl,
+ String rootPassword, String updateType) {
User loggedInUser = getLoggedInUser(sessionKey);
KickstartBuilder builder = new KickstartBuilder(loggedInUser);
@@ -281,9 +414,10 @@ public class KickstartHandler extends BaseHandler {
throw new NoSuchKickstartTreeException(kickstartableTreeLabel);
}
+ KickstartTreeUpdateType updateTree = getUpdateType(updateType, tree);
try {
builder.create(profileLabel, tree, virtualizationType, downloadUrl,
- rootPassword, RhnXmlRpcServer.getServerName());
+ rootPassword, RhnXmlRpcServer.getServerName(), updateTree);
}
catch (PermissionException e) {
throw new PermissionCheckFailureException(e);
@@ -501,13 +635,13 @@ public class KickstartHandler extends BaseHandler {
User loggedInUser = getLoggedInUser(sessionKey);
KickstartData toClone = KickstartFactory.lookupKickstartDataByLabelAndOrgId(
- ksLabelToClone, loggedInUser.getOrg().getId());
+ ksLabelToClone, loggedInUser.getOrg().getId());
if (toClone == null) {
throw new InvalidKickstartLabelException(ksLabelToClone);
}
KickstartCloneCommand cmd =
- new KickstartCloneCommand(toClone.getId(), loggedInUser, newKsLabel);
+ new KickstartCloneCommand(toClone.getId(), loggedInUser, newKsLabel);
KickstartBuilder builder = new KickstartBuilder(loggedInUser);
builder.validateNewLabel(newKsLabel);
@@ -543,6 +677,44 @@ public class KickstartHandler extends BaseHandler {
public int importRawFile(String sessionKey, String profileLabel,
String virtualizationType, String kickstartableTreeLabel,
String kickstartFileContents) {
+ return importRawFile(sessionKey, profileLabel, virtualizationType,
+ kickstartableTreeLabel, kickstartFileContents,
+ getDefaultUpdateType());
+ }
+
+ /**
+ * Import a kickstart profile into RHN, overriding the
+ * url/nfs/harddrive/cdrom command in the file and replacing it with the
+ * default URL for the kickstartable tree and kickstart host specified.
+ *
+ * @param sessionKey User's session key.
+ * @param profileLabel Label for the new kickstart profile.
+ * @param virtualizationType Virtualization type, or none.
+ * @param kickstartableTreeLabel Label of a kickstartable tree.
+ * @param kickstartFileContents Contents of a kickstart file.
+ * @param updateType Set the automatic ks tree update strategy
+ * for the profile. Valid choices are "red_hat", "none",
"all".
+ * @return 1 if successful, exception otherwise.
+ *
+ * @xmlrpc.doc Import a raw kickstart file into satellite.
+ * @xmlrpc.param #session_key()
+ * @xmlrpc.param #param_desc("string", "profileLabel",
"Label for the new
+ * kickstart profile.")
+ * @xmlrpc.param #param_desc("string", "virtualizationType",
"none, para_host,
+ * qemu, xenfv or xenpv.")
+ * @xmlrpc.param #param_desc("string", "kickstartableTreeLabel",
"Label of a
+ * kickstartable tree to associate the new profile with.")
+ * @xmlrpc.param #param_desc("string", "kickstartFileContents",
"Contents of
+ * the kickstart file to import.")
+ * @xmlrpc.param #param_desc("string", "updateType", "Should
the profile update
+ * itself to use the newest tree available? Possible values are: none (default),
+ * red_hat (only use Kickstart Trees synced from Red Hat), or all (includes
+ * custom Kickstart Trees).")
+ * @xmlrpc.returntype #return_int_success()
+ */
+ public int importRawFile(String sessionKey, String profileLabel,
+ String virtualizationType, String kickstartableTreeLabel,
+ String kickstartFileContents, String updateType) {
User loggedInUser = getLoggedInUser(sessionKey);
KickstartBuilder builder = new KickstartBuilder(loggedInUser);
@@ -553,10 +725,11 @@ public class KickstartHandler extends BaseHandler {
throw new NoSuchKickstartTreeException(kickstartableTreeLabel);
}
+ KickstartTreeUpdateType updateTree = getUpdateType(updateType, tree);
+
try {
- KickstartRawData data = builder.createRawData(profileLabel,
- tree, kickstartFileContents,
- virtualizationType);
+ KickstartRawData data = builder.createRawData(profileLabel, tree,
+ kickstartFileContents, virtualizationType, updateTree);
}
catch (PermissionException e) {
throw new PermissionCheckFailureException(e);
@@ -567,4 +740,42 @@ public class KickstartHandler extends BaseHandler {
return 1;
}
+
+ /**
+ * Conver string updatetype to a real KickstartTreeUpdateType
+ * @param typeIn the string to try
+ * @return the KickstartTreeUpdateType
+ */
+ private KickstartTreeUpdateType getUpdateType(String typeIn,
+ KickstartableTree tree) {
+ if (typeIn.equals(KickstartTreeUpdateType.ALL.getType())) {
+ if (tree.getChannel() == null) {
+ throw new InvalidUpdateTypeAndNoBaseTreeException(tree.getLabel());
+ }
+ return KickstartTreeUpdateType.ALL;
+ }
+ else if (typeIn.equals(KickstartTreeUpdateType.RED_HAT.getType())) {
+ if (tree.getOrgId() != null) {
+ throw new InvalidUpdateTypeAndKickstartTreeException(tree.getLabel());
+ }
+ if (tree.getChannel() == null) {
+ throw new InvalidUpdateTypeAndNoBaseTreeException(tree.getLabel());
+ }
+ return KickstartTreeUpdateType.RED_HAT;
+ }
+ else if (typeIn.equals(KickstartTreeUpdateType.NONE.getType())) {
+ return KickstartTreeUpdateType.NONE;
+ }
+ else {
+ throw new InvalidUpdateTypeException(typeIn);
+ }
+ }
+
+ /**
+ * Return the default KickstartTreeUpdateType
+ * @return string for the default KickstartTreeUpdateType
+ */
+ private String getDefaultUpdateType() {
+ return KickstartTreeUpdateType.NONE.getType();
+ }
}
diff --git
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/profile/ProfileHandler.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/profile/ProfileHandler.java
index 7b52448..86d1f42 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/profile/ProfileHandler.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/profile/ProfileHandler.java
@@ -35,6 +35,7 @@ import com.redhat.rhn.domain.role.RoleFactory;
import com.redhat.rhn.domain.token.ActivationKey;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.frontend.action.kickstart.KickstartIpRangeFilter;
+import com.redhat.rhn.frontend.action.kickstart.KickstartTreeUpdateType;
import com.redhat.rhn.frontend.dto.kickstart.KickstartOptionValue;
import com.redhat.rhn.frontend.xmlrpc.BaseHandler;
import com.redhat.rhn.frontend.xmlrpc.InvalidChannelLabelException;
@@ -43,6 +44,9 @@ import com.redhat.rhn.frontend.xmlrpc.InvalidScriptTypeException;
import com.redhat.rhn.frontend.xmlrpc.IpRangeConflictException;
import com.redhat.rhn.frontend.xmlrpc.PermissionCheckFailureException;
import com.redhat.rhn.frontend.xmlrpc.ValidationException;
+import
com.redhat.rhn.frontend.xmlrpc.kickstart.InvalidUpdateTypeAndKickstartTreeException;
+import com.redhat.rhn.frontend.xmlrpc.kickstart.InvalidUpdateTypeAndNoBaseTreeException;
+import com.redhat.rhn.frontend.xmlrpc.kickstart.InvalidUpdateTypeException;
import com.redhat.rhn.frontend.xmlrpc.kickstart.NoSuchKickstartTreeException;
import com.redhat.rhn.frontend.xmlrpc.kickstart.XmlRpcKickstartHelper;
import com.redhat.rhn.frontend.xmlrpc.kickstart.profile.keys.KeysHandler;
@@ -105,6 +109,32 @@ public class ProfileHandler extends BaseHandler {
return ksdefault.getKstree().getLabel();
}
+ /**
+ * Get the update type for a kickstart profile.
+ * @param sessionKey User's session key.
+ * @param kslabel label of the kickstart profile to be changed.
+ * @return kickstart tree label
+ *
+ * @xmlrpc.doc Get the update type for a kickstart profile.
+ * @xmlrpc.param #session_key()
+ * @xmlrpc.param #param_desc("string", "kslabel", "Label of
kickstart
+ * profile.")
+ * @xmlrpc.returntype
+ * #param_desc("string", "update_type", "Update type for
this Kickstart Profile.")
+ */
+ public String getUpdateType(String sessionKey, String kslabel) {
+
+ User loggedInUser = getLoggedInUser(sessionKey);
+ KickstartData ksdata = KickstartFactory
+ .lookupKickstartDataByLabelAndOrgId(kslabel, loggedInUser
+ .getOrg().getId());
+ if (ksdata == null) {
+ throw new FaultException(-3, "kickstartProfileNotFound",
+ "No Kickstart Profile found with label: " + kslabel);
+ }
+
+ return ksdata.getUpdateType();
+ }
/**
* Get the option to perserve ks.cfg.
@@ -226,6 +256,61 @@ public class ProfileHandler extends BaseHandler {
}
/**
+ * Set the update type for a kickstart profile.
+ * @param sessionKey User's session key.
+ * @param kslabel label of the kickstart profile to be changed.
+ * @param updateType the new update type.
+ * @return 1 if successful, exception otherwise.
+ *
+ * @xmlrpc.doc Set the update typefor a kickstart profile.
+ * @xmlrpc.param #session_key()
+ * @xmlrpc.param #param_desc("string", "kslabel", "Label of
kickstart
+ * profile to be changed.")
+ * @xmlrpc.param #param_desc("string", "updateType", "The
new update type
+ * to set. Possible values are 'red_hat', 'all', and
'none'.")
+ * @xmlrpc.returntype #return_int_success()
+ */
+ public int setUpdateType(String sessionKey, String kslabel,
+ String updateType) {
+
+ User loggedInUser = getLoggedInUser(sessionKey);
+ KickstartData ksdata = KickstartFactory
+ .lookupKickstartDataByLabelAndOrgId(kslabel, loggedInUser
+ .getOrg().getId());
+ if (ksdata == null) {
+ throw new FaultException(-3, "kickstartProfileNotFound",
+ "No Kickstart Profile found with label: " + kslabel);
+ }
+
+ KickstartableTree tree = ksdata.getTree();
+ KickstartTreeUpdateType realUT = null;
+ if (updateType.equals(KickstartTreeUpdateType.ALL.getType())) {
+ if (tree.getChannel() == null) {
+ throw new InvalidUpdateTypeAndNoBaseTreeException(tree.getLabel());
+ }
+ realUT = KickstartTreeUpdateType.ALL;
+ }
+ else if (updateType.equals(KickstartTreeUpdateType.RED_HAT.getType())) {
+ if (tree.getOrgId() != null) {
+ throw new InvalidUpdateTypeAndKickstartTreeException(tree.getLabel());
+ }
+ if (tree.getChannel() == null) {
+ throw new InvalidUpdateTypeAndNoBaseTreeException(tree.getLabel());
+ }
+ realUT = KickstartTreeUpdateType.RED_HAT;
+ }
+ else if (updateType.equals(KickstartTreeUpdateType.NONE.getType())) {
+ realUT = KickstartTreeUpdateType.NONE;
+ }
+ else {
+ throw new InvalidUpdateTypeException(updateType);
+ }
+
+ ksdata.setRealUpdateType(realUT);
+ return 1;
+ }
+
+ /**
* Get the child channels for a kickstart profile.
* @param sessionKey User's session key.
* @param kslabel label of the kickstart profile to be updated.
diff --git
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/KickstartDtoSerializer.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/KickstartDtoSerializer.java
index 9233b5c..2491971 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/KickstartDtoSerializer.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/KickstartDtoSerializer.java
@@ -37,6 +37,7 @@ import redstone.xmlrpc.XmlRpcSerializer;
* #prop("boolean", "advanced_mode")
* #prop("boolean", "org_default")
* #prop("boolean", "active")
+ * #prop("string", "update_type")
* #struct_end()
*/
public class KickstartDtoSerializer implements XmlRpcCustomSerializer {
@@ -50,7 +51,7 @@ public class KickstartDtoSerializer implements XmlRpcCustomSerializer {
/** {@inheritDoc} */
public void serialize(Object value, Writer output, XmlRpcSerializer
builtInSerializer)
- throws XmlRpcException, IOException {
+ throws XmlRpcException, IOException {
KickstartDto ks = (KickstartDto)value;
SerializerHelper helper = new SerializerHelper(builtInSerializer);
@@ -65,6 +66,7 @@ public class KickstartDtoSerializer implements XmlRpcCustomSerializer {
else {
helper.add("org_default", false);
}
+ helper.add("update_type", ks.getUpdateType());
helper.writeTo(output);
diff --git a/java/code/src/com/redhat/rhn/manager/kickstart/KickstartEditCommand.java
b/java/code/src/com/redhat/rhn/manager/kickstart/KickstartEditCommand.java
index 5a136e9..85910a6 100644
--- a/java/code/src/com/redhat/rhn/manager/kickstart/KickstartEditCommand.java
+++ b/java/code/src/com/redhat/rhn/manager/kickstart/KickstartEditCommand.java
@@ -16,7 +16,9 @@ package com.redhat.rhn.manager.kickstart;
import com.redhat.rhn.common.validator.ValidatorError;
import com.redhat.rhn.domain.channel.Channel;
+import com.redhat.rhn.domain.channel.ChannelArch;
import com.redhat.rhn.domain.channel.ChannelFactory;
+import com.redhat.rhn.domain.channel.ChannelFamily;
import com.redhat.rhn.domain.kickstart.KickstartCommand;
import com.redhat.rhn.domain.kickstart.KickstartData;
import com.redhat.rhn.domain.kickstart.KickstartFactory;
@@ -37,7 +39,6 @@ import org.apache.log4j.Logger;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -191,21 +192,14 @@ public class KickstartEditCommand extends BaseKickstartCommand {
* @param url the url of the channel.
* @return ValidatorError if we couldn't find a KickstartableTree to update to
*/
- public ValidatorError updateKickstartableTree(Long channelId,
- Long orgId,
- Long treeId,
- String url) {
-
-
-
+ public ValidatorError updateKickstartableTree(Long channelId, Long orgId,
+ Long treeId, String url) {
if (!KickstartFactory.verifyTreeAssignment(channelId, orgId, treeId)) {
ValidatorError ve = new
ValidatorError("kickstart.software.notree");
return ve;
}
KickstartableTree tree = KickstartFactory.findTreeById(treeId, orgId);
- KickstartWizardHelper helper = new KickstartWizardHelper(getUser());
-
for (Token token : ksdata.getDefaultRegTokens()) {
ActivationKey key = ActivationKeyFactory.lookupByToken(token);
@@ -271,14 +265,13 @@ public class KickstartEditCommand extends BaseKickstartCommand {
* @return Set of ChannelArch objects that are available
* to this Kickstart.
*/
- public Set getAvailableArches() {
+ public Set<ChannelArch> getAvailableArches() {
logger.debug("getAvailableArches() - start");
- List ksc = ChannelFactory.getKickstartableChannels(user.getOrg());
- Set retval = new HashSet();
- Iterator i = ksc.iterator();
- while (i.hasNext()) {
- Channel ca = (Channel) i.next();
- retval.add(ca.getChannelArch());
+ List<Channel> ksc = ChannelFactory.getKickstartableChannels(user
+ .getOrg());
+ Set<ChannelArch> retval = new HashSet<ChannelArch>();
+ for (Channel c : ksc) {
+ retval.add(c.getChannelArch());
}
logger.debug("getAvailableArches() - end - return value=" + retval);
return retval;
@@ -288,9 +281,9 @@ public class KickstartEditCommand extends BaseKickstartCommand {
* Get list of available Channels for Kickstarting.
* @return Collection of Channels.
*/
- public Collection getAvailableChannels() {
+ public Collection<Channel> getAvailableChannels() {
logger.debug("getAvailableChannels() - start");
- Collection returnCollection = ChannelFactory
+ Collection<Channel> returnCollection = ChannelFactory
.getKickstartableChannels(user.getOrg());
logger.debug("getAvailableChannels() - end - return value=" +
returnCollection);
return returnCollection;
@@ -302,22 +295,20 @@ public class KickstartEditCommand extends BaseKickstartCommand {
* @param org caller's org
* @return list of KickstartableTree instances
*/
- public List getTrees(Long channelId, Org org) {
+ public List<KickstartableTree> getTrees(Long channelId, Org org) {
return KickstartManager.getInstance().
- removeInvalid(KickstartFactory.lookupKickstartableTrees(channelId, org));
+ removeInvalid(KickstartFactory.lookupKickstartableTrees(channelId,
org));
}
/**
* Get the Set of ChannelFamily objects available to be Kickstarted.
* @return Set of ChannelFamily objects.
*/
- public Set getAvailableChannelFamilies() {
+ public Set<ChannelFamily> getAvailableChannelFamilies() {
logger.debug("getAvailableChannelFamilies() - start");
- Collection channels = getAvailableChannels();
- Set retval = new HashSet();
- Iterator i = channels.iterator();
- while (i.hasNext()) {
- Channel c = (Channel) i.next();
+ Collection<Channel> channels = getAvailableChannels();
+ Set<ChannelFamily> retval = new HashSet<ChannelFamily>();
+ for (Channel c : channels) {
retval.add(c.getChannelFamily());
}
logger.debug("getAvailableChannelFamilies() - end - return value=" +
retval);
@@ -328,11 +319,11 @@ public class KickstartEditCommand extends BaseKickstartCommand {
* Get the Set of available u1, u2, u3 .. for the current tree.
* @return Set of String values.
*/
- public Set getAvailableUpdates() {
+ public Set<String> getAvailableUpdates() {
// TODO: Take out this hard coded list!
String[] updates = {"", "u1", "u2", "u3",
"u4", "u5", "u6", "u7", "u8",
"u9"};
- Set retval = new TreeSet();
+ Set<String> retval = new TreeSet<String>();
retval.addAll(Arrays.asList(updates));
logger.debug("getAvailableUpdates() - end - return value=" + retval);
diff --git a/java/code/src/com/redhat/rhn/manager/kickstart/KickstartWizardHelper.java
b/java/code/src/com/redhat/rhn/manager/kickstart/KickstartWizardHelper.java
index 36d0bcc..051c067 100644
--- a/java/code/src/com/redhat/rhn/manager/kickstart/KickstartWizardHelper.java
+++ b/java/code/src/com/redhat/rhn/manager/kickstart/KickstartWizardHelper.java
@@ -14,6 +14,7 @@
*/
package com.redhat.rhn.manager.kickstart;
+import com.redhat.rhn.domain.channel.Channel;
import com.redhat.rhn.domain.channel.ChannelFactory;
import com.redhat.rhn.domain.kickstart.KickstartCommand;
import com.redhat.rhn.domain.kickstart.KickstartData;
@@ -32,7 +33,6 @@ import org.apache.log4j.Logger;
import java.util.Date;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@@ -59,7 +59,7 @@ public class KickstartWizardHelper {
* Retrieve a list of trees based on the user's Org
* @return list of KickstartableTrees
*/
- public List getKickstartableTrees() {
+ public List<KickstartableTree> getKickstartableTrees() {
return KickstartManager.getInstance().
removeInvalid(KickstartFactory.
lookupAccessibleTreesByOrg(currentUser.getOrg()));
@@ -71,7 +71,7 @@ public class KickstartWizardHelper {
*/
public List<KickstartVirtualizationType> getVirtualizationTypes() {
List <KickstartVirtualizationType> types =
- new LinkedList<KickstartVirtualizationType>();
+ new LinkedList<KickstartVirtualizationType>();
types.add(KickstartVirtualizationType.none());
types.add(KickstartVirtualizationType.kvmGuest());
types.add(KickstartVirtualizationType.paraHost());
@@ -117,8 +117,8 @@ public class KickstartWizardHelper {
* Get list of available Channels for Kickstarting.
* @return Collection of Channels.
*/
- public List getAvailableChannels() {
- List returnCollection = ChannelFactory
+ public List<Channel> getAvailableChannels() {
+ List<Channel> returnCollection = ChannelFactory
.getKickstartableChannels(currentUser.getOrg());
return returnCollection;
}
@@ -130,9 +130,9 @@ public class KickstartWizardHelper {
*/
public List<KickstartableTree> getTrees(Long channelId) {
return KickstartManager.getInstance().
- removeInvalid(KickstartFactory.
- lookupKickstartableTrees(channelId,
- currentUser.getOrg()));
+ removeInvalid(KickstartFactory.
+ lookupKickstartableTrees(channelId,
+ currentUser.getOrg()));
}
/**
@@ -149,14 +149,13 @@ public class KickstartWizardHelper {
if (ksdata.getCryptoKeys() != null) {
// Setup the default CryptoKeys
- List keys = KickstartFactory.lookupCryptoKeys(this.currentUser.getOrg());
+ List<CryptoKey> keys = KickstartFactory
+ .lookupCryptoKeys(this.currentUser.getOrg());
if (keys != null && keys.size() > 0) {
if (ksdata.getCryptoKeys() == null) {
ksdata.setCryptoKeys(new HashSet());
}
- Iterator i = keys.iterator();
- while (i.hasNext()) {
- CryptoKey key = (CryptoKey) i.next();
+ for (CryptoKey key : keys) {
if (key.getCryptoKeyType().equals(
KickstartFactory.KEY_TYPE_SSL)) {
ksdata.getCryptoKeys().add(key);
@@ -183,13 +182,13 @@ public class KickstartWizardHelper {
kcmd.store();
KickstartSession ksess =
- KickstartFactory.lookupDefaultKickstartSessionForKickstartData(ksdata);
+ KickstartFactory.lookupDefaultKickstartSessionForKickstartData(ksdata);
log.debug("Did we create the default session OK? : " + ksess);
KickstartFactory.saveKickstartData(ksdata);
log.debug("KSData stored. Calling cobbler.");
CobblerProfileCreateCommand cmd =
- new CobblerProfileCreateCommand(ksdata, currentUser);
+ new CobblerProfileCreateCommand(ksdata, currentUser);
cmd.store();
log.debug("store() - done.");
}
diff --git a/java/code/src/com/redhat/rhn/taskomatic/task/CobblerSyncTask.java
b/java/code/src/com/redhat/rhn/taskomatic/task/CobblerSyncTask.java
index 63a42bc..a4c9b0e 100644
--- a/java/code/src/com/redhat/rhn/taskomatic/task/CobblerSyncTask.java
+++ b/java/code/src/com/redhat/rhn/taskomatic/task/CobblerSyncTask.java
@@ -16,17 +16,24 @@ package com.redhat.rhn.taskomatic.task;
import com.redhat.rhn.common.util.MethodUtil;
import com.redhat.rhn.common.validator.ValidatorError;
+import com.redhat.rhn.domain.kickstart.KickstartData;
+import com.redhat.rhn.domain.kickstart.KickstartFactory;
+import com.redhat.rhn.domain.kickstart.KickstartableTree;
import com.redhat.rhn.frontend.xmlrpc.util.XMLRPCInvoker;
+import com.redhat.rhn.manager.kickstart.KickstartEditCommand;
import com.redhat.rhn.manager.kickstart.cobbler.CobblerDistroSyncCommand;
+import com.redhat.rhn.manager.kickstart.cobbler.CobblerProfileEditCommand;
import com.redhat.rhn.manager.kickstart.cobbler.CobblerProfileSyncCommand;
import com.redhat.rhn.manager.kickstart.cobbler.CobblerSystemSyncCommand;
import com.redhat.rhn.manager.kickstart.cobbler.CobblerXMLRPCHelper;
+import org.apache.commons.lang.StringUtils;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
import redstone.xmlrpc.XmlRpcFault;
@@ -54,11 +61,11 @@ public class CobblerSyncTask extends RhnJavaJob {
* {@inheritDoc}
*/
public void execute(JobExecutionContext ctxIn)
- throws JobExecutionException {
+ throws JobExecutionException {
try {
XMLRPCInvoker invoker = (XMLRPCInvoker)
- MethodUtil.getClassFromConfig(CobblerXMLRPCHelper.class.getName());
+ MethodUtil.getClassFromConfig(CobblerXMLRPCHelper.class.getName());
Double mtime = null;
try {
@@ -76,9 +83,30 @@ public class CobblerSyncTask extends RhnJavaJob {
distroWarnCount++;
}
+ // if we need to update a profile's kickstart tree, do that now
+ List<KickstartData> profiles = KickstartFactory
+ .lookupKickstartDataByUpdateable();
+ for (KickstartData profile : profiles) {
+ KickstartableTree tree = KickstartFactory.getNewestTree(
+ profile.getRealUpdateType(), profile.getChannel()
+ .getId(), profile.getOrg());
+ if (tree != null && !tree.equals(profile.getTree())) {
+ KickstartEditCommand cmd = new KickstartEditCommand(
+ profile, null);
+ cmd.updateKickstartableTree(profile.getChannel()
+ .getId(), profile.getOrg().getId(), tree
+ .getId(), tree.getDefaultDownloadLocation(""));
+ if (StringUtils.isNotEmpty(profile.getCobblerId())) {
+ CobblerProfileEditCommand cpec = new CobblerProfileEditCommand(
+ profile);
+ cpec.store();
+ }
+ }
+ }
+
log.debug("mtime: " + mtime.longValue() + ", last modified:
" +
- LAST_UPDATED.get());
+ LAST_UPDATED.get());
//If we got an mtime from cobbler and that mtime is before our last update
// Then don't update anything
if (mtime.longValue() < CobblerSyncTask.LAST_UPDATED.get()) {
diff --git
a/java/code/webapp/WEB-INF/pages/common/fragments/kickstart/advanced/details.jspf
b/java/code/webapp/WEB-INF/pages/common/fragments/kickstart/advanced/details.jspf
index 7e2e5c8..a3bf1e4 100644
--- a/java/code/webapp/WEB-INF/pages/common/fragments/kickstart/advanced/details.jspf
+++ b/java/code/webapp/WEB-INF/pages/common/fragments/kickstart/advanced/details.jspf
@@ -25,6 +25,17 @@
<html:select property="kstreeId">
<html:optionsCollection property="kstrees"
label="label" value="id" />
</html:select>
+ <br />
+ <input type="checkbox" name="updateRedHat"
id="updateRedHat" value="0"
+ onclick="clickNewestRHTree(this)"
+ <c:if test="${param.usingUpdateRedHat ==
true}">checked=1</c:if> />
+ <bean:message
key="kickstart.jsp.create.wizard.kstree.always_new_RH"/>
+ <br />
+ <input type="checkbox" name="updateAll"
id="updateAll" value="0"
+ onclick="clickNewestTree(this)"
+ <c:if test="${param.usingUpdateAll ==
true}">checked=1</c:if> />
+ <bean:message
key="kickstart.jsp.create.wizard.kstree.always_new"/>
+
</c:when>
<c:otherwise>
<b><bean:message
key="kickstart.edit.software.notrees.jsp" /></b>
diff --git a/java/code/webapp/WEB-INF/pages/kickstart/softwareedit.jsp
b/java/code/webapp/WEB-INF/pages/kickstart/softwareedit.jsp
index a6bd26b..ece1f48 100644
--- a/java/code/webapp/WEB-INF/pages/kickstart/softwareedit.jsp
+++ b/java/code/webapp/WEB-INF/pages/kickstart/softwareedit.jsp
@@ -15,6 +15,29 @@ function reloadForm(ctl) {
var form = document.getElementById("kickstartSoftwareForm");
form.submit();
}
+
+function toggleKSTree(what) {
+ var form = document.getElementById("kickstartSoftwareForm");
+ if(what.checked) {
+ form.tree.disabled=1;
+ } else {
+ form.tree.disabled=0;
+ }
+}
+
+function clickNewestRHTree() {
+ var form = document.getElementById("kickstartSoftwareForm");
+ if(form.useNewestRHTree.checked) {
+ form.useNewestTree.checked = false;
+ }
+}
+
+function clickNewestTree() {
+ var form = document.getElementById("kickstartSoftwareForm");
+ if(form.useNewestTree.checked) {
+ form.useNewestRHTree.checked = false;
+ }
+}
//-->
</script>
</head>
@@ -73,11 +96,32 @@ function reloadForm(ctl) {
<td>
<c:choose>
<c:when test="${notrees == null}">
- <html:select property="tree"
onchange="reloadForm(this);" styleId="kstree">
- <html:options collection="trees"
- property="id"
- labelProperty="label" />
- </html:select>
+ <c:if test="${usingNewest == true or usingNewestRH ==
true}">
+ <html:select property="tree"
onchange="reloadForm(this);" styleId="kstree"
disabled="true">
+ <html:options collection="trees"
+ property="id"
+ labelProperty="label" />
+ </html:select>
+ </c:if>
+ <c:if test="${not (usingNewest == true or usingNewestRH ==
true)}">
+ <html:select property="tree"
onchange="reloadForm(this);" styleId="kstree">
+ <html:options collection="trees"
+ property="id"
+ labelProperty="label" />
+ </html:select>
+ </c:if>
+ <c:if test="${redHatTreesAvailable != null}">
+ <br />
+ <input type="checkbox"
name="useNewestRHTree" value="0"
+ onclick="toggleKSTree(this);
clickNewestRHTree()"
+ <c:if test="${usingNewestRH ==
true}">checked=1</c:if> />
+ <bean:message
key="kickstart.jsp.create.wizard.kstree.always_new_RH"/>
+ </c:if>
+ <br />
+ <input type="checkbox" name="useNewestTree"
value="0"
+ onclick="toggleKSTree(this); clickNewestTree()"
+ <c:if test="${usingNewest ==
true}">checked=1</c:if> />
+ <bean:message
key="kickstart.jsp.create.wizard.kstree.always_new"/>
</c:when>
<c:otherwise>
<b><bean:message
key="kickstart.edit.software.notrees.jsp" /></b>
diff --git a/java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/advanced/create.jsp
b/java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/advanced/create.jsp
index 0ba90f9..192271b 100644
--- a/java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/advanced/create.jsp
+++ b/java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/advanced/create.jsp
@@ -5,6 +5,19 @@
<html:html xhtml="true">
<head>
<meta http-equiv="Pragma" content="no-cache" />
+<script language="javascript" type="text/javascript">
+function clickNewestRHTree(obj) {
+ if (obj.checked == true) {
+ document.getElementById("updateAll").checked = false;
+ }
+}
+
+function clickNewestTree(obj) {
+ if (obj.checked == true) {
+ document.getElementById("updateRedHat").checked = false;
+ }
+}
+</script>
</head>
<body>
<rhn:toolbar base="h1" img="/img/rhn-kickstart_profile.gif"
@@ -18,4 +31,4 @@
<c:param name = "url"
value="/kickstart/AdvancedModeCreate.do"/>
</c:import>
</body>
-</html:html>
\ No newline at end of file
+</html:html>
diff --git a/java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/advanced/edit.jsp
b/java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/advanced/edit.jsp
index ff82ad0..cc6fc95 100644
--- a/java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/advanced/edit.jsp
+++ b/java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/advanced/edit.jsp
@@ -4,6 +4,19 @@
<html:html xhtml="true">
<head>
<meta http-equiv="Pragma" content="no-cache" />
+<script language="javascript" type="text/javascript">
+function clickNewestRHTree(obj) {
+ if (obj.checked == true) {
+ document.getElementById("updateAll").checked = false;
+ }
+}
+
+function clickNewestTree(obj) {
+ if (obj.checked == true) {
+ document.getElementById("updateRedHat").checked = false;
+ }
+}
+</script>
</head>
<body>
@@ -14,6 +27,8 @@
<c:param name = "action_key" value="message.Update"/>
<c:param name = "url"
value="/kickstart/AdvancedModeEdit.do"/>
<c:param name = "ksurl" value="${requestScope.ksurl}"/>
+ <c:param name = "usingUpdateAll"
value="${requestScope.usingUpdateAll}"/>
+ <c:param name = "usingUpdateRedHat"
value="${requestScope.usingUpdateRedHat}"/>
</c:import>
</body>
-</html:html>
\ No newline at end of file
+</html:html>
diff --git a/java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/first.jsp
b/java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/first.jsp
index 2637eba..1308d2b 100644
--- a/java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/first.jsp
+++ b/java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/first.jsp
@@ -25,6 +25,29 @@ function refresh() {
var form = document.getElementById("kickstartCreateWizardForm");
form.submit();
}
+
+function toggleKSTree(what) {
+ var form = document.getElementById("kickstartCreateWizardForm");
+ if(what.checked) {
+ form.kstreeId.disabled=1;
+ } else {
+ form.kstreeId.disabled=0;
+ }
+}
+
+function clickNewestRHTree() {
+ var form = document.getElementById("kickstartCreateWizardForm");
+ if(form.useNewestRHTree.checked) {
+ form.useNewestTree.checked = false;
+ }
+}
+
+function clickNewestTree() {
+ var form = document.getElementById("kickstartCreateWizardForm");
+ if(form.useNewestTree.checked) {
+ form.useNewestRHTree.checked = false;
+ }
+}
</script>
</head>
@@ -67,8 +90,19 @@ function refresh() {
<c:choose>
<c:when test="${notrees == null}">
<html:select property="kstreeId">
- <html:optionsCollection property="kstrees"
label="label" value="id" />
+ <html:optionsCollection property="kstrees"
label="label" value="id" />
</html:select>
+
+ <c:if test="${redHatTreesAvailable != null}">
+ <br />
+ <input type="checkbox"
name="useNewestRHTree" value="0"
+ onclick="toggleKSTree(this); clickNewestRHTree()"
/>
+ <bean:message
key="kickstart.jsp.create.wizard.kstree.always_new_RH"/>
+ </c:if>
+ <br />
+ <input type="checkbox" name="useNewestTree"
value="0"
+ onclick="toggleKSTree(this); clickNewestTree()"
/>
+ <bean:message
key="kickstart.jsp.create.wizard.kstree.always_new"/>
</c:when>
<c:otherwise>
<b><bean:message
key="kickstart.edit.software.notrees.jsp" /></b>
diff --git a/java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/second.jsp
b/java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/second.jsp
index edaa97b..3cea42c 100644
--- a/java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/second.jsp
+++ b/java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/second.jsp
@@ -59,6 +59,7 @@ function movePrevious() {
<html:hidden property="kickstartLabel" />
<html:hidden property="virtualizationTypeLabel" />
<html:hidden property="kstreeId" />
+ <html:hidden property="kstreeUpdateType" />
<h1><bean:message
key="kickstart.jsp.create.wizard.step.two"/></h1>
<table class="details" width="80%">
<tr>
diff --git a/java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/third.jsp
b/java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/third.jsp
index 406b4e8..e4b4f8f 100644
--- a/java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/third.jsp
+++ b/java/code/webapp/WEB-INF/pages/kickstart/wizard/profile/third.jsp
@@ -45,6 +45,7 @@ function movePrevious() {
<html:hidden property="kstreeId" />
<html:hidden property="defaultDownload" />
<html:hidden property="userDefinedDownload" />
+ <html:hidden property="kstreeUpdateType" />
<h1><bean:message
key="kickstart.jsp.create.wizard.step.three"/></h1>
<table class="details" width="80%">
<tr>
diff --git a/java/code/webapp/WEB-INF/struts-config.xml
b/java/code/webapp/WEB-INF/struts-config.xml
index a490f3a..0109798 100644
--- a/java/code/webapp/WEB-INF/struts-config.xml
+++ b/java/code/webapp/WEB-INF/struts-config.xml
@@ -666,6 +666,8 @@
type="com.redhat.rhn.frontend.struts.ScrubbingDynaActionForm">
<form-property name="channel"
type="java.lang.Long"/>
<form-property name="tree" type="java.lang.Long"
/>
+ <form-property name="useNewestTree"
type="java.lang.Boolean" />
+ <form-property name="useNewestRHTree"
type="java.lang.Boolean" />
<form-property name="url" type="java.lang.String"
/>
<form-property name="submitted"
type="java.lang.Boolean"/>
<form-property name="fieldChanged"
type="java.lang.String" />
@@ -768,20 +770,22 @@
<form-property name="kstrees" type="java.util.List"
/>
<form-property name="kstreeId" type="java.lang.Long"
/>
<form-property name="virtualizationTypes"
type="java.util.List" />
- <form-property name="virtualizationTypeLabel"
type="java.lang.String" />
- <form-property name="fileUpload"
type="org.apache.struts.upload.FormFile" />
- <form-property name="contents" type="java.lang.String" />
+ <form-property name="virtualizationTypeLabel"
type="java.lang.String" />
+ <form-property name="updateAll" type="java.lang.Boolean"
/>
+ <form-property name="updateRedHat" type="java.lang.Boolean"
/>
+ <form-property name="fileUpload"
type="org.apache.struts.upload.FormFile" />
+ <form-property name="contents" type="java.lang.String"
/>
<form-property name="org_default"
type="java.lang.Boolean" />
<form-property name="comments" type="java.lang.String"
/>
<form-property name="active" type="java.lang.Boolean"
/>
<form-property name="kernel_options"
type="java.lang.String"/>
<form-property name="post_kernel_options"
type="java.lang.String"/>
- <form-property name="virt_disk_path"
type="java.lang.String"/>
- <form-property name="virt_mem_mb"
type="java.lang.Integer"/>
- <form-property name="virt_cpus"
type="java.lang.Integer"/>
- <form-property name="virt_disk_size"
type="java.lang.Integer"/>
- <form-property name="virt_bridge" type="java.lang.String"/>
- <form-property name="no_scrub" type="java.lang.String"
initial="contents"/>
+ <form-property name="virt_disk_path"
type="java.lang.String"/>
+ <form-property name="virt_mem_mb"
type="java.lang.Integer"/>
+ <form-property name="virt_cpus"
type="java.lang.Integer"/>
+ <form-property name="virt_disk_size"
type="java.lang.Integer"/>
+ <form-property name="virt_bridge"
type="java.lang.String"/>
+ <form-property name="no_scrub" type="java.lang.String"
initial="contents"/>
</form-bean>
<form-bean name="kickstartCreateWizardForm"
@@ -790,6 +794,9 @@
<form-property name="prevStep" type="java.lang.String"
/>
<form-property name="nextStep" type="java.lang.String"
/>
<form-property name="kickstartLabel"
type="java.lang.String" />
+ <form-property name="useNewestRHTree"
type="java.lang.Boolean" />
+ <form-property name="useNewestTree"
type="java.lang.Boolean" />
+ <form-property name="kstreeUpdateType"
type="java.lang.String" />
<form-property name="channels"
type="java.util.Collection" />
<form-property name="currentChannelId"
type="java.lang.Long" />
<form-property name="previousChannelId"
type="java.lang.Long" />
diff --git a/schema/spacewalk/common/tables/rhnKSData.sql
b/schema/spacewalk/common/tables/rhnKSData.sql
index 259ccfa..7e5d93b 100644
--- a/schema/spacewalk/common/tables/rhnKSData.sql
+++ b/schema/spacewalk/common/tables/rhnKSData.sql
@@ -73,6 +73,9 @@ CREATE TABLE rhnKSData
DEFAULT (current_timestamp) NOT NULL,
modified timestamp with local time zone
DEFAULT (current_timestamp) NOT NULL,
+ update_type VARCHAR2(7) NOT NULL DEFAULT 'none'
+ CONSTRAINT rhn_ks_update_type
+ CHECK (update_type in ('all', 'red_hat', 'none')),
CONSTRAINT rhn_ks_type_ck
CHECK (ks_type in ('wizard','raw'))
)
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.8-to-spacewalk-schema-1.9/023-rhnKsData.sql
b/schema/spacewalk/upgrade/spacewalk-schema-1.8-to-spacewalk-schema-1.9/023-rhnKsData.sql
new file mode 100644
index 0000000..a4cf2da
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.8-to-spacewalk-schema-1.9/023-rhnKsData.sql
@@ -0,0 +1,2 @@
+alter table rhnksdata add update_type varchar(7) not null default 'none';
+alter table rhnksdata add constraint rhn_ks_update_type check (update_type in
('all', 'red_hat', 'none'));