use of org.ovirt.engine.core.common.businessentities.StorageDomainOvfInfo in project ovirt-engine by oVirt.
the class ProcessOvfUpdateForStorageDomainCommand method updateOvfStoreContent.
protected boolean updateOvfStoreContent() {
if (domainOvfStoresInfoForUpdate.isEmpty()) {
return true;
}
updateDate = new Date();
List<Guid> vmAndTemplatesIds = storageDomainDao.getVmAndTemplatesIdsByStorageDomainId(getParameters().getStorageDomainId(), false, false);
vmAndTemplatesIds.addAll(vmStaticDao.getVmAndTemplatesIdsWithoutAttachedImageDisks(getParameters().getStoragePoolId(), false));
byte[] bytes = buildOvfInfoFileByteArray(vmAndTemplatesIds);
Pair<StorageDomainOvfInfo, DiskImage> lastOvfStoreForUpdate = domainOvfStoresInfoForUpdate.getLast();
// possibly have some ovf data on storage)
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);
}
// backup (if we did)
if (shouldUpdateLastOvfStore && lastOvfStoreForUpdate != null) {
performOvfUpdateForDomain(bytes, lastOvfStoreForUpdate.getFirst(), lastOvfStoreForUpdate.getSecond(), vmAndTemplatesIds);
}
if (!failedOvfDisks.isEmpty()) {
addCustomValue("DataCenterName", getStoragePool().getName());
addCustomValue("StorageDomainName", getStorageDomain().getName());
addCustomValue("DisksIds", StringUtils.join(failedOvfDisks, ", "));
auditLogDirector.log(this, AuditLogType.UPDATE_FOR_OVF_STORES_FAILED);
return false;
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.StorageDomainOvfInfo in project ovirt-engine by oVirt.
the class StorageDomainOvfInfoDaoTest method updateOvfUpdatedInfoWithRelevantExceptStatus.
@Test
public void updateOvfUpdatedInfoWithRelevantExceptStatus() {
StorageDomainOvfInfo ovfInfo = dao.get(getExistingEntityId());
ovfInfo.setStatus(StorageDomainOvfInfoStatus.DISABLED);
dao.update(ovfInfo);
StorageDomainOvfInfo ovfInfo1 = dao.getAllForDomain(FixturesTool.STORAGE_DOMAIN_NFS2_2).get(0);
assertNotSame("domain shouldn't be ovf updated prior to test", StorageDomainOvfInfoStatus.UPDATED, ovfInfo1.getStatus());
dao.updateOvfUpdatedInfo(Arrays.asList(ovfInfo.getStorageDomainId(), ovfInfo1.getStorageDomainId()), StorageDomainOvfInfoStatus.UPDATED, StorageDomainOvfInfoStatus.DISABLED);
ovfInfo = dao.get(ovfInfo.getOvfDiskId());
ovfInfo1 = dao.get(ovfInfo1.getOvfDiskId());
assertEquals(StorageDomainOvfInfoStatus.DISABLED, ovfInfo.getStatus());
assertEquals(StorageDomainOvfInfoStatus.UPDATED, ovfInfo1.getStatus());
}
use of org.ovirt.engine.core.common.businessentities.StorageDomainOvfInfo in project ovirt-engine by oVirt.
the class StorageDomainOvfInfoDaoTest method loadStorageDomainIdsForOvfIds.
@Test
public void loadStorageDomainIdsForOvfIds() {
StorageDomainOvfInfo ovfInfo = dao.get(getExistingEntityId());
assertTrue("domain shouldn't have stored ovfs prior to test", ovfInfo.getStoredOvfIds().isEmpty());
Guid ovfId1 = Guid.newGuid();
Guid ovfId2 = Guid.newGuid();
List<Guid> ovfIds = Arrays.asList(ovfId1, ovfId2);
ovfInfo.setStoredOvfIds(ovfIds);
dao.update(ovfInfo);
ovfInfo = dao.get(ovfInfo.getOvfDiskId());
assertEquals(ovfIds.size(), ovfInfo.getStoredOvfIds().size());
assertTrue(ovfInfo.getStoredOvfIds().containsAll(ovfIds));
List<Guid> loadedStorageDomainIds = dao.loadStorageDomainIdsForOvfIds(ovfIds);
assertEquals(1, loadedStorageDomainIds.size());
assertEquals(ovfInfo.getStorageDomainId(), loadedStorageDomainIds.get(0));
}
Aggregations