Skip to content

Commit 4ac7f0c

Browse files
committed
Address copilot's review for message change
1 parent daa3813 commit 4ac7f0c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

server/src/main/java/com/cloud/template/TemplateManagerImpl.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,7 @@ public DataStore getImageStore(String storeUuid, Long zoneId, VolumeVO volume) {
476476
}
477477

478478
if (imageStore == null) {
479-
logger.error("Cannot find an image store for zone [{}].", zoneId);
480-
throw new CloudRuntimeException("Failed to create template. Please contact the cloud administrator.");
479+
throwExceptionForImageStoreObtentionFailure(zoneId, "upload volume");
481480
}
482481

483482
return imageStore;
@@ -1397,7 +1396,7 @@ public boolean deleteTemplate(DeleteTemplateCmd cmd) {
13971396

13981397
@Override
13991398
@ActionEvent(eventType = EventTypes.EVENT_ISO_DELETE, eventDescription = "Deleting ISO", async = true)
1400-
public boolean deleteIso(DeleteIsoCmd cmd) {
1399+
public boolean deleteIso (DeleteIsoCmd cmd) {
14011400
Long templateId = cmd.getId();
14021401
Account caller = CallContext.current().getCallingAccount();
14031402
Long zoneId = cmd.getZoneId();
@@ -1703,8 +1702,7 @@ public VirtualMachineTemplate createPrivateTemplate(CreateTemplateCmd command) t
17031702
}
17041703
DataStore store = _dataStoreMgr.getImageStoreWithFreeCapacity(zoneId);
17051704
if (store == null) {
1706-
logger.error("Cannot find an image store for zone [{}].", zoneId);
1707-
throw new CloudRuntimeException("Failed to create template. Please contact the cloud administrator.");
1705+
throwExceptionForImageStoreObtentionFailure(zoneId, "create template");
17081706
}
17091707
AsyncCallFuture<TemplateApiResult> future = null;
17101708

@@ -2481,4 +2479,9 @@ public VirtualMachineTemplate linkUserDataToTemplate(LinkUserDataToTemplateCmd c
24812479

24822480
return _tmpltDao.findById(template.getId());
24832481
}
2482+
2483+
private void throwExceptionForImageStoreObtentionFailure(Long zoneId, String operation) {
2484+
logger.error("Cannot find an image store for zone [{}].", zoneId);
2485+
throw new CloudRuntimeException(String.format("Failed to %s. Please contact the cloud administrator.", operation));
2486+
}
24842487
}

0 commit comments

Comments
 (0)