Maor Lipchuk has uploaded a new change for review. Change subject: core: Override unregistered entity on deatch. ......................................................................
core: Override unregistered entity on deatch. Override unregistered entity when there is an existing entity which already exists as an unregistered entity. This can happen when a domain with an unregistered entity, is attached and a VM with disks on multiple storage domains exists in the setup and also as an unregistered VM. Once the VM will be created with disk on the attached Storage Domain, the unregistered entity should be overriden with the existing one, on detach process. Change-Id: Id22390ae392e95bbc73a5976fc886ed21da4989b Bug-Url: https://bugzilla.redhat.com/1132568 Signed-off-by: Maor Lipchuk <mlipc...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBase.java 1 file changed, 12 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/00/33100/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBase.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBase.java index 4d00352..8a8af8d 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBase.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBase.java @@ -225,6 +225,16 @@ removeEntitiesFromStorageDomain(vmsForStorageDomain, vmTemplatesForStorageDomain, disksForStorageDomain, storageDomain.getId()); } + private void removeEntityLeftOver(Guid entityId, String entityName, Guid storageDomainId) { + OvfEntityData ovfEntityData = getUnregisteredOVFDataDao().getByEntityIdAndStorageDomain(entityId, storageDomainId); + if (ovfEntityData != null) { + log.infoFormat("Entity {0} with id {1}, already exists as unregistered entity. override it with the new entity from the engine", + entityName, + entityId); + getUnregisteredOVFDataDao().removeEntity(entityId, storageDomainId); + } + } + /** * Remove all related entities of the Storage Domain from the DB. */ @@ -237,6 +247,7 @@ @Override public Object runInTransaction() { for (VM vm : vmsForStorageDomain) { + removeEntityLeftOver(vm.getId(), vm.getName(), storageDomainId); getUnregisteredOVFDataDao().saveOVFData(new OvfEntityData( vm.getId(), vm.getName(), @@ -249,6 +260,7 @@ } for (VmTemplate vmTemplate : vmTemplatesForStorageDomain) { + removeEntityLeftOver(vmTemplate.getId(), vmTemplate.getName(), storageDomainId); getUnregisteredOVFDataDao().saveOVFData(new OvfEntityData( vmTemplate.getId(), vmTemplate.getName(), -- To view, visit http://gerrit.ovirt.org/33100 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id22390ae392e95bbc73a5976fc886ed21da4989b Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5 Gerrit-Owner: Maor Lipchuk <mlipc...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches