shwstppr commented on pull request #5826:
URL: https://github.com/apache/cloudstack/pull/5826#issuecomment-1020929718
@GabrielBrascher doing something like following works,
```
diff --git
a/server/src/main/java/com/cloud/template/HypervisorTemplateAdapter.java
b/server/src/main/java/com/cloud/template/HypervisorTemplateAdapter.java
index 00dfee244c..1cf058d565 100644
--- a/server/src/main/java/com/cloud/template/HypervisorTemplateAdapter.java
+++ b/server/src/main/java/com/cloud/template/HypervisorTemplateAdapter.java
@@ -216,7 +216,7 @@ public class HypervisorTemplateAdapter extends
TemplateAdapterBase {
public TemplateProfile prepare(RegisterTemplateCmd cmd) throws
ResourceAllocationException {
TemplateProfile profile = super.prepare(cmd);
String url = profile.getUrl();
- UriUtils.validateUrl(cmd.getFormat(), url);
+ UriUtils.validateUrl(cmd.getFormat(), url, cmd.isDirectDownload());
if (cmd.isDirectDownload()) {
DigestHelper.validateChecksumString(cmd.getChecksum());
Long templateSize =
performDirectDownloadUrlValidation(cmd.getFormat(), url, cmd.getZoneIds());
diff --git a/utils/src/main/java/com/cloud/utils/UriUtils.java
b/utils/src/main/java/com/cloud/utils/UriUtils.java
index 6b222289b6..eb84d4555f 100644
--- a/utils/src/main/java/com/cloud/utils/UriUtils.java
+++ b/utils/src/main/java/com/cloud/utils/UriUtils.java
@@ -262,7 +262,7 @@ public class UriUtils {
return validateUrl(null, url);
}
- public static Pair<String, Integer> validateUrl(String format, String
url) throws IllegalArgumentException {
+ public static Pair<String, Integer> validateUrl(String format, String
url, boolean skipIpv6Check) throws IllegalArgumentException {
try {
URI uri = new URI(url);
if ((uri.getScheme() == null) ||
@@ -283,7 +283,7 @@ public class UriUtils {
if (hostAddr.isAnyLocalAddress() ||
hostAddr.isLinkLocalAddress() || hostAddr.isLoopbackAddress() ||
hostAddr.isMulticastAddress()) {
throw new IllegalArgumentException("Illegal host
specified in url");
}
- if (hostAddr instanceof Inet6Address) {
+ if (!skipIpv6Check && hostAddr instanceof Inet6Address) {
throw new IllegalArgumentException("IPV6 addresses not
supported (" + hostAddr.getHostAddress() + ")");
}
} catch (UnknownHostException uhe) {
@@ -301,6 +301,10 @@ public class UriUtils {
}
}
+ public static Pair<String, Integer> validateUrl(String format, String
url) throws IllegalArgumentException {
+ return validateUrl(format, url, false);
+ }
+
/**
* Add element to priority list examining node attributes: priority
(for urls) and type (for checksums)
*/
```
Normal template:

Direct download:

--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]