java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java | 40 +++++++---
java/code/src/com/redhat/rhn/manager/download/DownloadManager.java | 1
java/code/src/com/redhat/rhn/manager/kickstart/KickstartManager.java | 28 ++++++-
proxy/installer/configure-proxy.sh | 1
web/html/applications/rhn-proxy/5.3/httpd/cobbler-proxy.conf | 2
5 files changed, 58 insertions(+), 14 deletions(-)
New commits:
commit a11267710081ed3d70f41d67b631e8dc053ce625
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Wed Jan 20 17:42:24 2010 -0500
543879 - adding support to the proxy side to redirect to a url that will rewrite
kickstarts with the proxy name for /cblr urls
diff --git a/proxy/installer/configure-proxy.sh b/proxy/installer/configure-proxy.sh
index c37a530..2418b33 100755
--- a/proxy/installer/configure-proxy.sh
+++ b/proxy/installer/configure-proxy.sh
@@ -381,6 +381,7 @@ if [ $USE_SSL -eq 1 ]; then
fi
echo "ProxyPass /cobbler_api $PROTO://$RHN_PARENT/cobbler_api" >
$HTTPDCONFD_DIR/cobbler-proxy.conf
echo "ProxyPassReverse /cobbler_api $PROTO://$RHN_PARENT/cobbler_api" >>
$HTTPDCONFD_DIR/cobbler-proxy.conf
+echo "RewriteRule ^/cblr/svc/op/ks/(.*)$ /download/$0 [P,L]" >>
$HTTPDCONFD_DIR/cobbler-proxy.conf
echo "ProxyPass /cblr $PROTO://$RHN_PARENT/cblr" >>
$HTTPDCONFD_DIR/cobbler-proxy.conf
echo "ProxyPassReverse /cblr $PROTO://$RHN_PARENT/cblr" >>
$HTTPDCONFD_DIR/cobbler-proxy.conf
echo "ProxyPass /cobbler $PROTO://$RHN_PARENT/cobbler" >>
$HTTPDCONFD_DIR/cobbler-proxy.conf
diff --git a/web/html/applications/rhn-proxy/5.3/httpd/cobbler-proxy.conf
b/web/html/applications/rhn-proxy/5.3/httpd/cobbler-proxy.conf
index 79fb06d..2e16519 100644
--- a/web/html/applications/rhn-proxy/5.3/httpd/cobbler-proxy.conf
+++ b/web/html/applications/rhn-proxy/5.3/httpd/cobbler-proxy.conf
@@ -1,6 +1,8 @@
ProxyPass /cobbler_api https://${session.rhn_parent}/cobbler_api
ProxyPassReverse /cobbler_api https://${session.rhn_parent}/cobbler_api
+RewriteRule ^/cblr/svc/op/ks/(.*)$ /download/$0 [P,L]
+
ProxyPass /cblr https://${session.rhn_parent}/cblr
ProxyPassReverse /cblr https://${session.rhn_parent}/cblr
commit 4020f83a33f6a4ecb332b0af67f956810ba9fab3
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Wed Jan 20 17:22:05 2010 -0500
543879 - adding support for downloading kickstart profiles through the /cblr handler
through a proxy
diff --git a/java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java
b/java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java
index f57ccc6..e31f447 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java
@@ -35,10 +35,12 @@ import com.redhat.rhn.domain.rhnpackage.Patch;
import com.redhat.rhn.domain.rhnpackage.PatchSet;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.domain.user.UserFactory;
+import com.redhat.rhn.frontend.action.kickstart.KickstartHelper;
import com.redhat.rhn.frontend.struts.RhnHelper;
import com.redhat.rhn.manager.channel.ChannelManager;
import com.redhat.rhn.manager.download.DownloadManager;
import com.redhat.rhn.manager.download.UnknownDownloadTypeException;
+import com.redhat.rhn.manager.kickstart.KickstartManager;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
@@ -86,6 +88,7 @@ public class DownloadFile extends DownloadAction {
private static final String TREE = "tree";
private static final String PATH = "path";
private static final String SESSION = "session";
+ private static final String URL = "url";
/** {@inheritDoc} */
public ActionForward execute(ActionMapping mapping,
@@ -98,21 +101,22 @@ public class DownloadFile extends DownloadAction {
log.debug("url : [" + url + "]");
}
if (url.startsWith("/ks/dist")) {
- if (log.isDebugEnabled()) {
- log.debug("URL is ks dist..");
- }
+ log.debug("URL is ks dist..");
ActionForward error = handleKickstartDownload(request, response,
url, mapping);
- if (log.isDebugEnabled()) {
- log.debug("Done handling ks download");
- }
+ log.debug("Done handling ks download");
if (error != null) {
- if (log.isDebugEnabled()) {
- log.debug("returning null");
- }
+ log.debug("returning null");
return null;
}
}
+ else if (url.startsWith("/cblr/svc/op/ks/")) {
+ Map params = new HashMap();
+ params.put(TYPE, DownloadManager.DOWNLOAD_TYPE_COBBLER);
+ params.put(URL, url);
+ request.setAttribute(PARAMS, params);
+ return super.execute(mapping, formIn, request, response);
+ }
else {
ActionForward error = handleUserDownload(request, url, mapping);
if (error != null) {
@@ -120,9 +124,7 @@ public class DownloadFile extends DownloadAction {
}
}
try {
- if (log.isDebugEnabled()) {
- log.debug("Calling super.execute");
- }
+ log.debug("Calling super.execute");
super.execute(mapping, formIn, request, response);
}
catch (Exception e) {
@@ -317,6 +319,20 @@ public class DownloadFile extends DownloadAction {
if (type.equals(DownloadManager.DOWNLOAD_TYPE_KICKSTART)) {
return getStreamInfoKickstart(mapping, form, request, response, path);
}
+ else if (type.equals(DownloadManager.DOWNLOAD_TYPE_COBBLER)) {
+ String url = ConfigDefaults.get().getCobblerServerUrl() +
+ (String) params.get(URL);
+ KickstartHelper helper = new KickstartHelper(request);
+ String data = "";
+ if (helper.isProxyRequest()) {
+ data = KickstartManager.getInstance().renderKickstart(
+ helper.getKickstartHost(), url);
+ }
+ else {
+ data = KickstartManager.getInstance().renderKickstart(url);
+ }
+ return getStreamForText(data.getBytes());
+ }
else {
Long fileId = (Long) params.get(FILEID);
Long userid = (Long) params.get(USERID);
diff --git a/java/code/src/com/redhat/rhn/manager/download/DownloadManager.java
b/java/code/src/com/redhat/rhn/manager/download/DownloadManager.java
index 12e469d..372effb 100644
--- a/java/code/src/com/redhat/rhn/manager/download/DownloadManager.java
+++ b/java/code/src/com/redhat/rhn/manager/download/DownloadManager.java
@@ -39,6 +39,7 @@ import java.util.List;
public class DownloadManager extends BaseManager {
public static final String DOWNLOAD_TYPE_KICKSTART = "kickstart";
+ public static final String DOWNLOAD_TYPE_COBBLER = "cobbler";
public static final String DOWNLOAD_TYPE_PACKAGE = "package";
public static final String DOWNLOAD_TYPE_SOURCE = "srpm";
public static final String DOWNLOAD_TYPE_ISO = "iso";
diff --git a/java/code/src/com/redhat/rhn/manager/kickstart/KickstartManager.java
b/java/code/src/com/redhat/rhn/manager/kickstart/KickstartManager.java
index e78edba..31657cb 100644
--- a/java/code/src/com/redhat/rhn/manager/kickstart/KickstartManager.java
+++ b/java/code/src/com/redhat/rhn/manager/kickstart/KickstartManager.java
@@ -66,7 +66,20 @@ public class KickstartManager extends BaseManager {
* @return the rendered kickstart contents
*/
public String renderKickstart(String host, KickstartData data) {
- String retval = renderKickstart(data);
+ return renderKickstart(host, KickstartUrlHelper.getCobblerProfileUrl(data));
+ }
+
+ /**
+ * Render the kickstart using cobbler and return the contents with the Cobbler host
+ * search/replaced.
+ *
+ * @param host the host to force into the ks file. searches and replaces all
+ * instances of the Cobbler Host with whatever you pass in. Use with Proxies.
+ * @param url The url to fetch
+ * @return the rendered kickstart contents
+ */
+ public String renderKickstart(String host, String url) {
+ String retval = renderKickstart(url);
// Search/replacing all instances of cobbler host with host
// we pass in, for use with rhn proxy.
retval = retval.replaceAll(ConfigDefaults.get().getCobblerHost(), host);
@@ -79,8 +92,19 @@ public class KickstartManager extends BaseManager {
* @return the rendered kickstart contents
*/
public String renderKickstart(KickstartData data) {
- return DownloadUtils.downloadUrl(KickstartUrlHelper.getCobblerProfileUrl(data));
+ return renderKickstart(KickstartUrlHelper.getCobblerProfileUrl(data));
}
+
+
+ /**
+ * Render the kickstart using cobbler and return the contents
+ * @param url the url to fetch
+ * @return the rendered kickstart contents
+ */
+ public String renderKickstart(String url) {
+ return DownloadUtils.downloadUrl(url);
+ }
+
/**
* Simple method to validate a generated kickstart