Skip to content

Commit 2862b36

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

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

@@ -1384,8 +1383,15 @@ public boolean deleteTemplate(DeleteTemplateCmd cmd) {
13841383
vmInstanceVOList = _vmInstanceDao.listNonExpungedByTemplate(templateId);
13851384
}
13861385
if(!cmd.isForced() && CollectionUtils.isNotEmpty(vmInstanceVOList)) {
1387-
final String message = String.format("Unable to delete Template: %s because Instance: [%s] are using it.", template, Joiner.on(",").join(vmInstanceVOList));
1388-
logger.warn(message);
1386+
String message = String.format("Unable to delete template with ID %s, because there are VM instances using it.", templateId);
1387+
String instancesListMessage = String.format(" Instances list: [%s].", StringUtils.join(vmInstanceVOList, ","));
1388+
1389+
logger.warn("{}{}", message, instancesListMessage);
1390+
1391+
if (_accountMgr.isRootAdmin(caller.getAccountId())) {
1392+
message += instancesListMessage;
1393+
}
1394+
13891395
throw new InvalidParameterValueException(message);
13901396
}
13911397

0 commit comments

Comments
 (0)