mirror of https://github.com/apache/cloudstack.git
Changes to the error message displayed during the removal of public templates that are used (#12373)
This commit is contained in:
parent
da7ac80dc4
commit
d0543449a6
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue