diff --git a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java index 86bcb8a76d79..32b465e8eaeb 100755 --- a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java @@ -565,7 +565,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; @@ -2060,7 +2060,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; @@ -2917,4 +2917,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 {} in zone [{}].", operation, zoneId); + throw new CloudRuntimeException(String.format("Failed to %s. Please contact the cloud administrator.", operation)); + } }