This is an automated email from the ASF dual-hosted git repository.
dahn pushed a commit to branch 4.20
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.20 by this push:
new d0543449a66 Changes to the error message displayed during the removal
of public templates that are used (#12373)
d0543449a66 is described below
commit d0543449a66714dc37c754d57a6072f5a3ae84dd
Author: Erik Böck <[email protected]>
AuthorDate: Mon Feb 23 07:21:04 2026 -0300
Changes to the error message displayed during the removal of public
templates that are used (#12373)
---
.../main/java/com/cloud/template/TemplateManagerImpl.java | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java
b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java
index 194d97349f0..bf470205107 100755
--- a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java
@@ -219,7 +219,6 @@ import com.cloud.vm.VirtualMachineProfileImpl;
import com.cloud.vm.VmDetailConstants;
import com.cloud.vm.dao.UserVmDao;
import com.cloud.vm.dao.VMInstanceDao;
-import com.google.common.base.Joiner;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -1375,9 +1374,16 @@ public class TemplateManagerImpl extends ManagerBase
implements TemplateManager,
else {
vmInstanceVOList =
_vmInstanceDao.listNonExpungedByTemplate(templateId);
}
- if(!cmd.isForced() && CollectionUtils.isNotEmpty(vmInstanceVOList)) {
- final String message = String.format("Unable to delete Template:
%s because Instance: [%s] are using it.", template,
Joiner.on(",").join(vmInstanceVOList));
- logger.warn(message);
+ if (!cmd.isForced() && CollectionUtils.isNotEmpty(vmInstanceVOList)) {
+ String message = String.format("Unable to delete template [%s]
because there are [%d] VM instances using it.", template,
vmInstanceVOList.size());
+ String instancesListMessage = String.format(" Instances list:
[%s].", StringUtils.join(vmInstanceVOList, ","));
+
+ logger.warn("{}{}", message, instancesListMessage);
+
+ if (_accountMgr.isRootAdmin(caller.getAccountId())) {
+ message += instancesListMessage;
+ }
+
throw new InvalidParameterValueException(message);
}