CLOUDSTACK-10238: Fix for metalink support on SSVM agents

This commit is contained in:
nvazquez 2018-01-18 01:29:35 -03:00 committed by Daan Hoogland
parent 8e4cec1d87
commit d39664a382
2 changed files with 7 additions and 10 deletions

View File

@ -92,4 +92,4 @@ public class MetalinkTemplateDownloader extends TemplateDownloaderBase implement
public void setStatus(Status status) {
this.status = status;
}
}
}

View File

@ -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<String> getMetalinkUrls(String metalinkUrl) {
HttpClient httpClient = new HttpClient(new MultiThreadedHttpConnectionManager());
GetMethod getMethod = new GetMethod(metalinkUrl);
List<String> 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<String, List<String>> metalinkUrlsMap = getMultipleValuesFromXML(is, new String[] {"url"});
if (metalinkUrlsMap.containsKey("url")) {
List<String> metalinkUrls = metalinkUrlsMap.get("url");