mirror of https://github.com/apache/cloudstack.git
Fix metalink urls issue
This commit is contained in:
parent
cd3a72c1f9
commit
e8e4cd70af
|
|
@ -111,6 +111,7 @@ public class HttpDirectTemplateDownloader extends DirectTemplateDownloaderImpl {
|
|||
}
|
||||
|
||||
protected boolean performDownload() {
|
||||
s_logger.info("Downloading template " + getTemplateId() + " from " + getUrl() + " to: " + getDownloadedFilePath());
|
||||
try (
|
||||
InputStream in = request.getResponseBodyAsStream();
|
||||
OutputStream out = new FileOutputStream(getDownloadedFilePath());
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ public class HttpsDirectTemplateDownloader extends HttpDirectTemplateDownloader
|
|||
* Consume response and persist it on getDownloadedFilePath() file
|
||||
*/
|
||||
protected boolean consumeResponse(CloseableHttpResponse response) {
|
||||
s_logger.info("Downloading template " + getTemplateId() + " from " + getUrl() + " to: " + getDownloadedFilePath());
|
||||
if (response.getStatusLine().getStatusCode() != 200) {
|
||||
throw new CloudRuntimeException("Error on HTTPS response");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1311,16 +1311,20 @@ public class KVMStorageProcessor implements StorageProcessor {
|
|||
KVMStoragePool destPool = storagePoolMgr.getStoragePool(pool.getPoolType(), pool.getUuid());
|
||||
DirectTemplateDownloader downloader;
|
||||
|
||||
if (cmd instanceof HttpDirectDownloadCommand) {
|
||||
downloader = new HttpDirectTemplateDownloader(cmd.getUrl(), cmd.getTemplateId(), destPool.getLocalPath(), cmd.getChecksum(), cmd.getHeaders());
|
||||
} else if (cmd instanceof HttpsDirectDownloadCommand) {
|
||||
downloader = new HttpsDirectTemplateDownloader(cmd.getUrl(), cmd.getTemplateId(), destPool.getLocalPath(), cmd.getChecksum(), cmd.getHeaders());
|
||||
} else if (cmd instanceof NfsDirectDownloadCommand) {
|
||||
downloader = new NfsDirectTemplateDownloader(cmd.getUrl(), destPool.getLocalPath(), cmd.getTemplateId(), cmd.getChecksum());
|
||||
} else if (cmd instanceof MetalinkDirectDownloadCommand) {
|
||||
downloader = new MetalinkDirectTemplateDownloader(cmd.getUrl(), destPool.getLocalPath(), cmd.getTemplateId(), cmd.getChecksum(), cmd.getHeaders());
|
||||
} else {
|
||||
return new DirectDownloadAnswer(false, "Unsupported protocol, please provide HTTP(S), NFS or a metalink");
|
||||
try {
|
||||
if (cmd instanceof HttpDirectDownloadCommand) {
|
||||
downloader = new HttpDirectTemplateDownloader(cmd.getUrl(), cmd.getTemplateId(), destPool.getLocalPath(), cmd.getChecksum(), cmd.getHeaders());
|
||||
} else if (cmd instanceof HttpsDirectDownloadCommand) {
|
||||
downloader = new HttpsDirectTemplateDownloader(cmd.getUrl(), cmd.getTemplateId(), destPool.getLocalPath(), cmd.getChecksum(), cmd.getHeaders());
|
||||
} else if (cmd instanceof NfsDirectDownloadCommand) {
|
||||
downloader = new NfsDirectTemplateDownloader(cmd.getUrl(), destPool.getLocalPath(), cmd.getTemplateId(), cmd.getChecksum());
|
||||
} else if (cmd instanceof MetalinkDirectDownloadCommand) {
|
||||
downloader = new MetalinkDirectTemplateDownloader(cmd.getUrl(), destPool.getLocalPath(), cmd.getTemplateId(), cmd.getChecksum(), cmd.getHeaders());
|
||||
} else {
|
||||
return new DirectDownloadAnswer(false, "Unsupported protocol, please provide HTTP(S), NFS or a metalink");
|
||||
}
|
||||
} catch (CloudRuntimeException e) {
|
||||
return new DirectDownloadAnswer(false, "Unable to create direct downloader: " + e.getMessage());
|
||||
}
|
||||
|
||||
if (!downloader.downloadTemplate()) {
|
||||
|
|
|
|||
|
|
@ -435,9 +435,8 @@ public class UriUtils {
|
|||
HttpClient httpClient = getHttpClient();
|
||||
GetMethod getMethod = new GetMethod(metalinkUrl);
|
||||
List<String> urls = new ArrayList<>();
|
||||
try (
|
||||
InputStream is = getMethod.getResponseBodyAsStream()
|
||||
) {
|
||||
try {
|
||||
InputStream is = getMethod.getResponseBodyAsStream();
|
||||
if (httpClient.executeMethod(getMethod) == HttpStatus.SC_OK) {
|
||||
Map<String, List<String>> metalinkUrlsMap = getMultipleValuesFromXML(is, new String[] {"url"});
|
||||
if (metalinkUrlsMap.containsKey("url")) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue