From d39664a382772babceb456440eb8ea2fde4bcb6d Mon Sep 17 00:00:00 2001 From: nvazquez Date: Thu, 18 Jan 2018 01:29:35 -0300 Subject: [PATCH] CLOUDSTACK-10238: Fix for metalink support on SSVM agents --- .../template/MetalinkTemplateDownloader.java | 2 +- utils/src/com/cloud/utils/UriUtils.java | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/core/src/com/cloud/storage/template/MetalinkTemplateDownloader.java b/core/src/com/cloud/storage/template/MetalinkTemplateDownloader.java index 38ad776ef39..75580e0b1a9 100644 --- a/core/src/com/cloud/storage/template/MetalinkTemplateDownloader.java +++ b/core/src/com/cloud/storage/template/MetalinkTemplateDownloader.java @@ -92,4 +92,4 @@ public class MetalinkTemplateDownloader extends TemplateDownloaderBase implement public void setStatus(Status status) { this.status = status; } -} \ No newline at end of file +} diff --git a/utils/src/com/cloud/utils/UriUtils.java b/utils/src/com/cloud/utils/UriUtils.java index 5ec2a626c6a..31637a8a8c2 100644 --- a/utils/src/com/cloud/utils/UriUtils.java +++ b/utils/src/com/cloud/utils/UriUtils.java @@ -395,23 +395,20 @@ public class UriUtils { } /** - * Get list of urls on metalink ordered by ascending priority (for those which priority tag is not defined, highest priority value is assumed) + * Get list of urls on metalink ordered by ascending priority (for those which priority tag is not defined, + * highest priority value is assumed) + * + * @param metalinkUrl the url of the metalink file + * @return a list of Strings containg the URLs of the target locations */ public static List getMetalinkUrls(String metalinkUrl) { HttpClient httpClient = new HttpClient(new MultiThreadedHttpConnectionManager()); GetMethod getMethod = new GetMethod(metalinkUrl); List urls = new ArrayList<>(); - int status; - try { - status = httpClient.executeMethod(getMethod); - } catch (IOException e) { - s_logger.error("Error retrieving urls form metalink: " + metalinkUrl); - return null; - } try ( InputStream is = getMethod.getResponseBodyAsStream() ) { - if (status == HttpStatus.SC_OK) { + if (httpClient.executeMethod(getMethod) == HttpStatus.SC_OK) { Map> metalinkUrlsMap = getMultipleValuesFromXML(is, new String[] {"url"}); if (metalinkUrlsMap.containsKey("url")) { List metalinkUrls = metalinkUrlsMap.get("url");