Pearl1594 commented on a change in pull request #4748:
URL: https://github.com/apache/cloudstack/pull/4748#discussion_r597695132
##########
File path:
server/src/main/java/com/cloud/template/HypervisorTemplateAdapter.java
##########
@@ -585,6 +595,7 @@ public boolean delete(TemplateProfile profile) {
if (iStores == null || iStores.size() == 0) {
// Mark template as Inactive.
template.setState(VirtualMachineTemplate.State.Inactive);
+ templateDao.remove(template.getId());
Review comment:
Done @DaanHoogland
##########
File path: server/src/main/java/com/cloud/storage/StorageManagerImpl.java
##########
@@ -1324,6 +1324,11 @@ public void cleanupStorage(boolean recurring) {
s_logger.warn("Unable to destroy uploaded template
" + template.getUuid() + ". Error details: " + th.getMessage());
}
}
+ List<VMTemplateVO> vmTemplateVOS =
_templateDao.listUnRemovedTemplatesByStates(VirtualMachineTemplate.State.Inactive);
+ for (VMTemplateVO template: vmTemplateVOS) {
+ template.setRemoved(new Date());
+ _templateDao.update(template.getId(), template);
+ }
Review comment:
done @DaanHoogland
##########
File path:
server/src/main/java/com/cloud/template/HypervisorTemplateAdapter.java
##########
@@ -570,6 +572,14 @@ public boolean delete(TemplateProfile profile) {
if (success) {
if ((imageStores != null && imageStores.size() > 1) &&
(profile.getZoneIdList() != null)) {
//if template is stored in more than one image stores, and the
zone id is not null, then don't delete other templates.
+ List<VMTemplateZoneVO> templateZones =
templateZoneDao.listByTemplateId(template.getId());
+ List<Long> zoneIds =
templateZones.stream().map(VMTemplateZoneVO::getZoneId).collect(Collectors.toList());
+ if (zoneIds.size() > 0) {
+ return success;
+ }
+ template.setRemoved(new Date());
+ template.setState(State.Inactive);
+ templateDao.update(template.getId(), template);
Review comment:
done @DaanHoogland
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]