Source:
<code>protected void updateOvfStoreContent() { if (domainOvfStoresInfoForUpdate.isEmpty()) { return; } updateDate = new Date(); List<Guid> vmAndTemplatesIds = getStorageDomainDAO().getVmAndTemplatesIdsByStorageDomainId(getParameters().getStorageDomainId(), false, false); <START> vmAndTemplatesIds.addAll(getVmStaticDAO().getVmAndTemplatesIdsWithoutAttachedImageDisks(false, false)); <END> byte[] bytes = buildOvfInfoFileByteArray(vmAndTemplatesIds); Pair<StorageDomainOvfInfo, DiskImage> lastOvfStoreForUpdate = domainOvfStoresInfoForUpdate.getLast(); if (lastOvfStoreForUpdate.getFirst().getLastUpdated() != null) { domainOvfStoresInfoForUpdate.removeLast(); } else { lastOvfStoreForUpdate = null; } boolean shouldUpdateLastOvfStore = false; failedOvfDisks = new ArrayList<>(); for (Pair<StorageDomainOvfInfo, DiskImage> pair : domainOvfStoresInfoForUpdate) { shouldUpdateLastOvfStore |= performOvfUpdateForDomain(bytes, pair.getFirst(), pair.getSecond(), vmAndTemplatesIds); } if (shouldUpdateLastOvfStore && lastOvfStoreForUpdate != null) { performOvfUpdateForDomain(bytes, lastOvfStoreForUpdate.getFirst(), lastOvfStoreForUpdate.getSecond(), vmAndTemplatesIds); } if (!failedOvfDisks.isEmpty()) { AuditLogableBase auditLogableBase = new AuditLogableBase(); auditLogableBase.addCustomValue("DataCenterName", getStoragePool().getName()); auditLogableBase.addCustomValue("StorageDomainName", storageDomain.getName()); auditLogableBase.addCustomValue("DisksIds", StringUtils.join(failedOvfDisks, ", ")); AuditLogDirector.log(auditLogableBase, AuditLogType.UPDATE_FOR_OVF_STORES_FAILED); } }</code><technical_language>Consider re-extract line 198-204 a method called "getEntitiesIdsForOvfStore"</technical_language>

Target:
protected void updateOvfStoreContent() { if (domainOvfStoresInfoForUpdate.isEmpty()) { return; } updateDate = new Date(); List<Guid> vmAndTemplatesIds = getStorageDomainDAO().getVmAndTemplatesIdsByStorageDomainId(getParameters().getStorageDomainId(), false, false); vmAndTemplatesIds.addAll(getVmStaticDAO().getVmAndTemplatesIdsWithoutAttachedImageDisks(false)); byte[] bytes = buildOvfInfoFileByteArray(vmAndTemplatesIds); Pair<StorageDomainOvfInfo, DiskImage> lastOvfStoreForUpdate = domainOvfStoresInfoForUpdate.getLast(); if (lastOvfStoreForUpdate.getFirst().getLastUpdated() != null) { domainOvfStoresInfoForUpdate.removeLast(); } else { lastOvfStoreForUpdate = null; } boolean shouldUpdateLastOvfStore = false; failedOvfDisks = new ArrayList<>(); for (Pair<StorageDomainOvfInfo, DiskImage> pair : domainOvfStoresInfoForUpdate) { shouldUpdateLastOvfStore |= performOvfUpdateForDomain(bytes, pair.getFirst(), pair.getSecond(), vmAndTemplatesIds); } if (shouldUpdateLastOvfStore && lastOvfStoreForUpdate != null) { performOvfUpdateForDomain(bytes, lastOvfStoreForUpdate.getFirst(), lastOvfStoreForUpdate.getSecond(), vmAndTemplatesIds); } if (!failedOvfDisks.isEmpty()) { AuditLogableBase auditLogableBase = new AuditLogableBase(); auditLogableBase.addCustomValue("DataCenterName", getStoragePool().getName()); auditLogableBase.addCustomValue("StorageDomainName", storageDomain.getName()); auditLogableBase.addCustomValue("DisksIds", StringUtils.join(failedOvfDisks, ", ")); AuditLogDirector.log(auditLogableBase, AuditLogType.UPDATE_FOR_OVF_STORES_FAILED); } }