Daniel Erez has uploaded a new change for review. Change subject: core: remove dead code of template deletion by SD ......................................................................
core: remove dead code of template deletion by SD Deleting a template by a storage domain is deprecated (and not functional) since introduction of MSD feature. Hence, removing all relevant dead code. Change-Id: Iea08a582e5887a5458efef0870f18af83046f4fc Signed-off-by: Daniel Erez <de...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveAllVmTemplateImageTemplatesCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmTemplateCommand.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmTemplateParametersBase.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties M frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java M frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties M frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties 8 files changed, 13 insertions(+), 72 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/07/37907/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveAllVmTemplateImageTemplatesCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveAllVmTemplateImageTemplatesCommand.java index b774668..9023aa5 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveAllVmTemplateImageTemplatesCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveAllVmTemplateImageTemplatesCommand.java @@ -71,17 +71,14 @@ noImagesRemovedYet = false; } - // remove images from db only if removing template completely - if (getParameters().isRemoveTemplateFromDb()) { - DiskImage diskImage = DbFacade.getInstance().getDiskImageDao().get(template.getImageId()); - if (diskImage != null) { - DbFacade.getInstance().getBaseDiskDao().remove(template.getId()); - DbFacade.getInstance() - .getVmDeviceDao() - .remove(new VmDeviceId(diskImage.getImageId(), getVmTemplateId())); - DbFacade.getInstance().getImageStorageDomainMapDao().remove(diskImage.getImageId()); - DbFacade.getInstance().getImageDao().remove(template.getImageId()); - } + DiskImage diskImage = DbFacade.getInstance().getDiskImageDao().get(template.getImageId()); + if (diskImage != null) { + DbFacade.getInstance().getBaseDiskDao().remove(template.getId()); + DbFacade.getInstance() + .getVmDeviceDao() + .remove(new VmDeviceId(diskImage.getImageId(), getVmTemplateId())); + DbFacade.getInstance().getImageStorageDomainMapDao().remove(diskImage.getImageId()); + DbFacade.getInstance().getImageDao().remove(template.getImageId()); } } setSucceeded(true); diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmTemplateCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmTemplateCommand.java index b52caec..92366aa 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmTemplateCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmTemplateCommand.java @@ -23,7 +23,6 @@ import org.ovirt.engine.core.common.action.VmTemplateParametersBase; import org.ovirt.engine.core.common.asynctasks.EntityInfo; import org.ovirt.engine.core.common.businessentities.DiskImage; -import org.ovirt.engine.core.common.businessentities.StorageDomainStatic; import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VmEntityType; import org.ovirt.engine.core.common.businessentities.VmTemplate; @@ -107,29 +106,9 @@ fetchImageTemplates(); } - List<Guid> storageDomainsList = getParameters().getStorageDomainsList(); Set<Guid> allDomainsList = getStorageDomainsByDisks(imageTemplates, true); - - // if null or empty list sent, get all template domains for deletion - if (storageDomainsList == null || storageDomainsList.isEmpty()) { - // populate all the domains of the template - getParameters().setStorageDomainsList(new ArrayList<Guid>(allDomainsList)); - getParameters().setRemoveTemplateFromDb(true); - } else { - // if some domains sent, check that the sent domains are part of all domains - List<String> problematicDomains = new ArrayList<String>(); - for (Guid domainId : storageDomainsList) { - if (!allDomainsList.contains(domainId)) { - StorageDomainStatic domain = getDbFacade().getStorageDomainStaticDao().get(domainId); - problematicDomains.add(domain == null ? domainId.toString() : domain.getStorageName()); - } - } - if (!problematicDomains.isEmpty()) { - return failCanDoAction(VdcBllMessages.VMT_CANNOT_REMOVE_DOMAINS_LIST_MISMATCH, - String.format("$domainsList %1$s", StringUtils.join(problematicDomains, ","))); - } - getParameters().setRemoveTemplateFromDb(allDomainsList.size() == storageDomainsList.size()); - } + // populate all the domains of the template + getParameters().setStorageDomainsList(new ArrayList<Guid>(allDomainsList)); // check template images for selected domains ArrayList<String> canDoActionMessages = getReturnValue().getCanDoActionMessages(); @@ -150,21 +129,7 @@ List<VM> vms = getVmDAO().getAllWithTemplate(vmTemplateId); List<String> problematicVmNames = new ArrayList<String>(); for (VM vm : vms) { - if (getParameters().isRemoveTemplateFromDb()) { - problematicVmNames.add(vm.getName()); - } else { - List<DiskImage> vmDIsks = - ImagesHandler.filterImageDisks(getDbFacade().getDiskDao().getAllForVm(vm.getId()), - false, - false, - true); - Set<Guid> domainsIds = getStorageDomainsByDisks(vmDIsks, false); - for (Guid domainId : domainsIds) { - if (!getParameters().getStorageDomainsList().contains(domainId)) { - problematicVmNames.add(vm.getName()); - } - } - } + problematicVmNames.add(vm.getName()); } if (!problematicVmNames.isEmpty()) { @@ -173,7 +138,7 @@ } // for base templates, make sure it has no versions that need to be removed first - if (getParameters().isRemoveTemplateFromDb() && vmTemplateId.equals(template.getBaseTemplateId())) { + if (vmTemplateId.equals(template.getBaseTemplateId())) { List<VmTemplate> templateVersions = getVmTemplateDAO().getTemplateVersionsForBaseTemplate(vmTemplateId); if (!templateVersions.isEmpty()) { List<String> templateVersionsNames = new ArrayList<>(); @@ -310,12 +275,7 @@ private void HandleEndAction() { try { - if (getParameters().isRemoveTemplateFromDb()) { - removeTemplateFromDb(); - } else { - // unlock template - VmTemplateHandler.unlockVmTemplate(getVmTemplateId()); - } + removeTemplateFromDb(); setSucceeded(true); } catch (RuntimeException e) { // Set the try again of task to false, to prevent log spam and audit log spam. diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmTemplateParametersBase.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmTemplateParametersBase.java index b3b83e5..22e7ff7 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmTemplateParametersBase.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmTemplateParametersBase.java @@ -13,7 +13,6 @@ public class VmTemplateParametersBase extends VdcActionParametersBase implements Serializable, HasGraphicsDevices { private static final long serialVersionUID = -8930994274659598061L; - private boolean removeTemplateFromDb; private Guid vmTemplateId; private Guid quotaId; private boolean privateCheckDisksExists; @@ -72,14 +71,6 @@ public VmTemplateParametersBase() { this(Guid.Empty); - } - - public void setRemoveTemplateFromDb(boolean removeTemplateFromDb) { - this.removeTemplateFromDb = removeTemplateFromDb; - } - - public boolean isRemoveTemplateFromDb() { - return removeTemplateFromDb; } public Guid getQuotaId() { diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java index fe40f45..8b33a5e 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java @@ -439,7 +439,6 @@ VMT_CLUSTER_IS_NOT_VALID(ErrorType.BAD_PARAMETERS), VMT_CANNOT_IMPORT_TEMPLATE_EXISTS(ErrorType.CONFLICT), VMT_CANNOT_IMPORT_TEMPLATE_VERSION_MISSING_BASE(ErrorType.BAD_PARAMETERS), - VMT_CANNOT_REMOVE_DOMAINS_LIST_MISMATCH(ErrorType.CONFLICT), VM_CANNOT_IMPORT_TEMPLATE_NAME_EXISTS(ErrorType.CONFLICT), ACTION_TYPE_FAILED_NETWORK_INTERFACE_MAC_INVALID(ErrorType.BAD_PARAMETERS), USER_CANNOT_REMOVE_HIMSELF(ErrorType.CONFLICT), diff --git a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties index d6980fe..5797579 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -20,7 +20,6 @@ VMT_CANNOT_REMOVE_BASE_WITH_VERSIONS=Cannot delete Base Template that has Template Versions, please first remove all Template Versions for this Template: ${versionsList}. ACTION_TYPE_FAILED_DETECTED_DERIVED_DISKS=Cannot ${action} ${type}. The following Disk(s) are based on it: \n ${disksInfo}. ACTION_TYPE_FAILED_DISKS_SNAPSHOTS_DONT_BELONG_TO_SAME_DISK=Cannot ${action} ${type}. The specified disk snapshots don't belong to the same Disk. -VMT_CANNOT_REMOVE_DOMAINS_LIST_MISMATCH=Cannot delete Template. The Template does not exist on the following Storage Domains: ${domainsList}.\nEither verify that Template exists on all Storage Domains listed on the domains list,\nor do not send domains list in order to delete all instances of the Template from the system. ACTION_TYPE_FAILED_VM_IMAGE_DOES_NOT_EXIST=Cannot ${action} ${type}. VM's Image does not exist. ACTION_TYPE_FAILED_VM_SNAPSHOT_DOES_NOT_EXIST=Cannot ${action} ${type}. VM's Snapshot does not exist. ACTION_TYPE_FAILED_VM_SNAPSHOT_TYPE_NOT_ALLOWED=Cannot ${action} ${type}. The Snapshot type is ${snapshotType} while the operation is supported for Snapshots of the following type(s): ${supportedSnapshotTypes}. diff --git a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java index df810da..cfb5828 100644 --- a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java +++ b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java @@ -70,9 +70,6 @@ @DefaultStringValue("Cannot ${action} ${type}. The specified disk snapshots don't belong to the same Disk.") String ACTION_TYPE_FAILED_DISKS_SNAPSHOTS_DONT_BELONG_TO_SAME_DISK(); - @DefaultStringValue("Cannot delete Template. The Template does not exist on the following Storage Domains: ${domainsList}.\nEither verify that Template exists on all Storage Domains listed on the domains list,\nor do not send domains list in order to delete all instances of the Template from the system.") - String VMT_CANNOT_REMOVE_DOMAINS_LIST_MISMATCH(); - @DefaultStringValue("Cannot ${action} ${type}. VM's Image does not exist.") String ACTION_TYPE_FAILED_VM_IMAGE_DOES_NOT_EXIST(); diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index 3452a0a..b341460 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -13,7 +13,6 @@ VMT_CANNOT_REMOVE_BASE_WITH_VERSIONS=Cannot delete Base Template that has Template Versions, please first remove all Template Versions for this Template: ${versionsList}. ACTION_TYPE_FAILED_DETECTED_DERIVED_DISKS=Cannot ${action} ${type}. The following Disk(s) are based on it: \n ${disksInfo}. ACTION_TYPE_FAILED_DISKS_SNAPSHOTS_DONT_BELONG_TO_SAME_DISK=Cannot ${action} ${type}. The specified disk snapshots don't belong to the same Disk. -VMT_CANNOT_REMOVE_DOMAINS_LIST_MISMATCH=Cannot delete Template. The Template does not exist on the following Storage Domains: ${domainsList}.\nEither verify that Template exists on all Storage Domains listed on the domains list,\nor do not send domains list in order to delete all instances of the Template from the system. ACTION_TYPE_FAILED_VM_IMAGE_DOES_NOT_EXIST=Cannot ${action} ${type}. VM's Image does not exist. ACTION_TYPE_FAILED_VM_SNAPSHOT_DOES_NOT_EXIST=Cannot ${action} ${type}. VM's Snapshot does not exist. ACTION_TYPE_FAILED_VM_SNAPSHOT_TYPE_NOT_ALLOWED=Cannot ${action} ${type}. The Snapshot type is ${snapshotType} while the operation is supported for Snapshots of the following type(s): ${supportedSnapshotTypes}. diff --git a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index bc1b606..1b1fd6c 100644 --- a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -20,7 +20,6 @@ VMT_CANNOT_REMOVE_BASE_WITH_VERSIONS=Cannot delete Base Template that has Template Versions, please first remove all Template Versions for this Template: ${versionsList}. ACTION_TYPE_FAILED_DETECTED_DERIVED_DISKS=Cannot ${action} ${type}. The following Disk(s) are based on it: \n ${disksInfo}. ACTION_TYPE_FAILED_DISKS_SNAPSHOTS_DONT_BELONG_TO_SAME_DISK=Cannot ${action} ${type}. The specified disk snapshots don't belong to the same Disk. -VMT_CANNOT_REMOVE_DOMAINS_LIST_MISMATCH=Cannot delete Template. The Template does not exist on the following Storage Domains: ${domainsList}.\nEither verify that Template exists on all Storage Domains listed on the domains list,\nor do not send domains list in order to delete all instances of the Template from the system. ACTION_TYPE_FAILED_VM_IMAGE_DOES_NOT_EXIST=Cannot ${action} ${type}. VM's Image does not exist. ACTION_TYPE_FAILED_VM_SNAPSHOT_DOES_NOT_EXIST=Cannot ${action} ${type}. VM's Snapshot does not exist. ACTION_TYPE_FAILED_VM_SNAPSHOT_TYPE_NOT_ALLOWED=Cannot ${action} ${type}. The Snapshot type is ${snapshotType} while the operation is supported for Snapshots of the following type(s): ${supportedSnapshotTypes}. -- To view, visit http://gerrit.ovirt.org/37907 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iea08a582e5887a5458efef0870f18af83046f4fc Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Daniel Erez <de...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches