Skip to content

Commit d2229b5

Browse files
erikbocksLocharla, Sandeep
authored andcommitted
Changes to the error message displayed during the removal of public templates that are used (apache#12373)
1 parent a527ec9 commit d2229b5

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@
221221
import com.cloud.vm.VmDetailConstants;
222222
import com.cloud.vm.dao.UserVmDao;
223223
import com.cloud.vm.dao.VMInstanceDao;
224-
import com.google.common.base.Joiner;
225224
import com.google.gson.Gson;
226225
import com.google.gson.GsonBuilder;
227226

@@ -1395,9 +1394,16 @@ public boolean deleteTemplate(DeleteTemplateCmd cmd) {
13951394
else {
13961395
vmInstanceVOList = _vmInstanceDao.listNonExpungedByTemplate(templateId);
13971396
}
1398-
if(!cmd.isForced() && CollectionUtils.isNotEmpty(vmInstanceVOList)) {
1399-
final String message = String.format("Unable to delete Template: %s because Instance: [%s] are using it.", template, Joiner.on(",").join(vmInstanceVOList));
1400-
logger.warn(message);
1397+
if (!cmd.isForced() && CollectionUtils.isNotEmpty(vmInstanceVOList)) {
1398+
String message = String.format("Unable to delete template [%s] because there are [%d] VM instances using it.", template, vmInstanceVOList.size());
1399+
String instancesListMessage = String.format(" Instances list: [%s].", StringUtils.join(vmInstanceVOList, ","));
1400+
1401+
logger.warn("{}{}", message, instancesListMessage);
1402+
1403+
if (_accountMgr.isRootAdmin(caller.getAccountId())) {
1404+
message += instancesListMessage;
1405+
}
1406+
14011407
throw new InvalidParameterValueException(message);
14021408
}
14031409

0 commit comments

Comments
 (0)