Long maxTemplateSizeInBytes = getMaxTemplateSizeInBytes();
if (vmTemplateStore != null) {
start();
VirtualMachineTemplate tmpl = _templateDao.findById(template.getId());
DownloadCommand dcmd = new DownloadCommand((TemplateObjectTO)(template.getTO()), maxTemplateSizeInBytes);
dcmd.setProxy(getHttpProxy());
if (downloadJobExists) {
dcmd = new DownloadProgressCommand(dcmd, vmTemplateStore.getJobId(), RequestType.GET_OR_RESTART);
}
if (vmTemplateStore.isCopy()) {
dcmd.setCreds(TemplateConstants.DEFAULT_HTTP_AUTH_USER, _copyAuthPasswd);
}
EndPoint ep = _epSelector.select(template);
if (ep == null) {
String errMsg = "There is no secondary storage VM for downloading template to image store " + store.getName();
s_logger.warn(errMsg);