Skip to content

Commit f9e815e

Browse files
committed
Changes to the error message displayed during the removal of public templates that are used
1 parent ce42ce5 commit f9e815e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@
219219
import com.cloud.vm.VmDetailConstants;
220220
import com.cloud.vm.dao.UserVmDao;
221221
import com.cloud.vm.dao.VMInstanceDao;
222-
import com.google.common.base.Joiner;
223222
import com.google.gson.Gson;
224223
import com.google.gson.GsonBuilder;
225224

@@ -1376,8 +1375,15 @@ public boolean deleteTemplate(DeleteTemplateCmd cmd) {
13761375
vmInstanceVOList = _vmInstanceDao.listNonExpungedByTemplate(templateId);
13771376
}
13781377
if(!cmd.isForced() && CollectionUtils.isNotEmpty(vmInstanceVOList)) {
1379-
final String message = String.format("Unable to delete Template: %s because Instance: [%s] are using it.", template, Joiner.on(",").join(vmInstanceVOList));
1380-
logger.warn(message);
1378+
String message = String.format("Unable to delete template with ID %s, because there are VM instances using it.", template);
1379+
String instancesListMessage = String.format(" Instances list: [%s].", StringUtils.join(vmInstanceVOList, ","));
1380+
1381+
logger.warn("{}{}", message, instancesListMessage);
1382+
1383+
if (_accountMgr.isRootAdmin(caller.getAccountId())) {
1384+
message += instancesListMessage;
1385+
}
1386+
13811387
throw new InvalidParameterValueException(message);
13821388
}
13831389

0 commit comments

Comments
 (0)