Maor Lipchuk has uploaded a new change for review. Change subject: core: Add unregistered entities to the ovf tar file ......................................................................
core: Add unregistered entities to the ovf tar file Sync the unregistered entities with the existing entities in the setup to be stored in the OVF_STORE disk. Change-Id: Icc5fc1c1b704ecbb49fe3d4c2561ec1836093369 Related to Bug-Url: https://bugzilla.redhat.com/1138114 Signed-off-by: Maor Lipchuk <mlipc...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ProcessOvfUpdateForStorageDomainCommand.java 1 file changed, 26 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/01/33101/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ProcessOvfUpdateForStorageDomainCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ProcessOvfUpdateForStorageDomainCommand.java index 2b102d6..03c45f6 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ProcessOvfUpdateForStorageDomainCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ProcessOvfUpdateForStorageDomainCommand.java @@ -8,9 +8,11 @@ import java.util.Comparator; import java.util.Date; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Set; import org.apache.commons.lang.ObjectUtils; import org.ovirt.engine.core.bll.storage.StorageDomainCommandBase; @@ -23,6 +25,7 @@ import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.action.VdcReturnValueBase; import org.ovirt.engine.core.common.businessentities.DiskImage; +import org.ovirt.engine.core.common.businessentities.OvfEntityData; import org.ovirt.engine.core.common.businessentities.StorageDomain; import org.ovirt.engine.core.common.businessentities.StorageDomainOvfInfo; import org.ovirt.engine.core.common.businessentities.StorageDomainOvfInfoStatus; @@ -153,6 +156,7 @@ private byte[] buildOvfInfoFileByteArray(List<Guid> vmAndTemplatesIds) { ByteArrayOutputStream bufferedOutputStream = new ByteArrayOutputStream(); + Set<Guid> processedIds = new HashSet<>(); try (InMemoryTar inMemoryTar = new InMemoryTar(bufferedOutputStream)) { inMemoryTar.addTarEntry(generateInfoFileData().getBytes(), @@ -167,15 +171,32 @@ List<Pair<Guid, String>> ovfs = getVmAndTemplatesGenerationsDao().loadOvfDataForIds(idsToProcess); if (!ovfs.isEmpty()) { - buildFilesForOvfs(ovfs, inMemoryTar); + processedIds.addAll(buildFilesForOvfs(ovfs, inMemoryTar)); } } + + List<Pair<Guid, String>> unprocessedOvfData = retrieveUnprocessedUnregisteredOvfData(processedIds); + buildFilesForOvfs(unprocessedOvfData, inMemoryTar); } catch (Exception e) { throw new RuntimeException(String.format("Exception while building in memory tar of the OVFs of domain %s", getParameters().getStorageDomainId()), e); } return bufferedOutputStream.toByteArray(); + } + + private List<Pair<Guid, String>> retrieveUnprocessedUnregisteredOvfData(Set<Guid> processedIds) { + List<OvfEntityData> ovfList = getUnregisteredOVFDataDao().getAllForStorageDomainByEntityType( + getParameters().getStorageDomainId(), null); + List<Pair<Guid, String>> ovfData = new LinkedList<>(); + for (OvfEntityData ovfEntityData : ovfList) { + if (!processedIds.contains(ovfEntityData.getEntityId())) { + Pair<Guid, String> data = new Pair<>(ovfEntityData.getEntityId(), ovfEntityData.getOvfData()); + ovfData.add(data); + } + } + + return ovfData; } protected void updateOvfStoreContent() { @@ -310,12 +331,15 @@ setSucceeded(true); } - protected void buildFilesForOvfs(List<Pair<Guid, String>> ovfs, InMemoryTar inMemoryTar) throws Exception { + protected Set<Guid> buildFilesForOvfs(List<Pair<Guid, String>> ovfs, InMemoryTar inMemoryTar) throws Exception { + Set<Guid> addedOvfIds = new HashSet<>(); for (Pair<Guid, String> pair : ovfs) { if (pair.getSecond() != null) { inMemoryTar.addTarEntry(pair.getSecond().getBytes(), pair.getFirst() + ".ovf"); + addedOvfIds.add(pair.getFirst()); } } + return addedOvfIds; } protected VmAndTemplatesGenerationsDAO getVmAndTemplatesGenerationsDao() { -- To view, visit http://gerrit.ovirt.org/33101 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icc5fc1c1b704ecbb49fe3d4c2561ec1836093369 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