diff --git a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java index 194d97349f01..91a06428be11 100755 --- a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java @@ -476,7 +476,7 @@ public DataStore getImageStore(String storeUuid, Long zoneId, VolumeVO volume) { } if (imageStore == null) { - throw new CloudRuntimeException(String.format("Cannot find an image store for zone [%s].", zoneId)); + throwExceptionForImageStoreRetrievalFailure(zoneId, "upload volume"); } return imageStore; @@ -1702,7 +1702,7 @@ public VirtualMachineTemplate createPrivateTemplate(CreateTemplateCmd command) t } DataStore store = _dataStoreMgr.getImageStoreWithFreeCapacity(zoneId); if (store == null) { - throw new CloudRuntimeException("cannot find an image store for zone " + zoneId); + throwExceptionForImageStoreRetrievalFailure(zoneId, "create template"); } AsyncCallFuture future = null; @@ -2479,4 +2479,9 @@ public VirtualMachineTemplate linkUserDataToTemplate(LinkUserDataToTemplateCmd c return _tmpltDao.findById(template.getId()); } + + private void throwExceptionForImageStoreRetrievalFailure(Long zoneId, String operation) { + logger.error("Could not find an available image store to %s in zone [{}].", operation, zoneId); + throw new CloudRuntimeException(String.format("Failed to %s in zone %d because there was no available image storage.", operation, zoneId)); + } }