From 79ebffe4f3ce38340754b1954f1ec3f913cedb7c Mon Sep 17 00:00:00 2001 From: Nitin Mehta Date: Wed, 29 Aug 2012 15:01:31 +0530 Subject: [PATCH] CS-13594: Download template is unable to handle multiple SSVMs per zone Reviewed-by: Kishan --- .../storage/upload/UploadMonitorImpl.java | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/server/src/com/cloud/storage/upload/UploadMonitorImpl.java b/server/src/com/cloud/storage/upload/UploadMonitorImpl.java index 7166504020f..4231be81ff6 100755 --- a/server/src/com/cloud/storage/upload/UploadMonitorImpl.java +++ b/server/src/com/cloud/storage/upload/UploadMonitorImpl.java @@ -234,25 +234,14 @@ public class UploadMonitorImpl implements UploadMonitor { } //Construct actual URL locally now that the symlink exists at SSVM - List ssVms = _secStorageVmDao.getSecStorageVmListInStates(SecondaryStorageVm.Role.templateProcessor, dataCenterId, State.Running); - if (ssVms.size() > 0) { - SecondaryStorageVmVO ssVm = ssVms.get(0); - if (ssVm.getPublicIpAddress() == null) { - errorString = "A running secondary storage vm has a null public ip?"; - s_logger.error(errorString); - throw new CloudRuntimeException(errorString); - } - String extractURL = generateCopyUrl(ssVm.getPublicIpAddress(), uuid); - UploadVO vo = _uploadDao.createForUpdate(); - vo.setLastUpdated(new Date()); - vo.setUploadUrl(extractURL); - vo.setUploadState(Status.DOWNLOAD_URL_CREATED); - _uploadDao.update(uploadTemplateObj.getId(), vo); - success = true; - return _uploadDao.findById(uploadTemplateObj.getId(), true); - } - errorString = "Couldnt find a running SSVM in the zone" + dataCenterId+ ". Couldnt create the extraction URL."; - throw new CloudRuntimeException(errorString); + String extractURL = generateCopyUrl(ssvm.getPublicIpAddress(), uuid); + UploadVO vo = _uploadDao.createForUpdate(); + vo.setLastUpdated(new Date()); + vo.setUploadUrl(extractURL); + vo.setUploadState(Status.DOWNLOAD_URL_CREATED); + _uploadDao.update(uploadTemplateObj.getId(), vo); + success = true; + return _uploadDao.findById(uploadTemplateObj.getId(), true); }finally{ if(!success){ UploadVO uploadJob = _uploadDao.createForUpdate(uploadTemplateObj.getId());