use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class ImportValidator method validateStorageExistsForMemoryDisks.
public ValidationResult validateStorageExistsForMemoryDisks(List<Snapshot> snapshots, boolean allowPartial, Map<Guid, String> failedDisksToImport) {
for (Snapshot snap : snapshots) {
if (snap.containsMemory()) {
DiskImage memoryDump = (DiskImage) getDiskDao().get(snap.getMemoryDiskId());
StorageDomain dumpSd = getStorageDomainDao().getForStoragePool(memoryDump.getStorageIds().get(0), params.getStoragePoolId());
ValidationResult dumpSdResult = new StorageDomainValidator(dumpSd).isDomainExistAndActive();
if (!handleStorageValidationResult(dumpSdResult, memoryDump, snap, failedDisksToImport) && !allowPartial) {
return dumpSdResult;
}
DiskImage memoryConf = (DiskImage) getDiskDao().get(snap.getMetadataDiskId());
StorageDomain confSd = getStorageDomainDao().getForStoragePool(memoryConf.getStorageIds().get(0), params.getStoragePoolId());
ValidationResult confSdResult = new StorageDomainValidator(confSd).isDomainExistAndActive();
if (!handleStorageValidationResult(confSdResult, memoryConf, snap, failedDisksToImport) && !allowPartial) {
return confSdResult;
}
}
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class DiskImagesValidator method diskImagesSnapshotsAttachedToVm.
public ValidationResult diskImagesSnapshotsAttachedToVm(Guid vmId) {
LinkedList<String> diskSnapshotInfo = new LinkedList<>();
VM vm = getVmDao().get(vmId);
for (DiskImage diskImage : diskImages) {
List<VmDevice> devices = getVmDeviceDao().getVmDevicesByDeviceId(diskImage.getId(), vmId);
if (devices.isEmpty()) {
// The specified disk image does not belong to the vm
Snapshot snapshot = getSnapshotDao().get(diskImage.getSnapshotId());
Disk disk = getDbFacade().getDiskDao().get(diskImage.getId());
diskSnapshotInfo.add(String.format("%s ,%s", disk.getDiskAlias(), snapshot.getDescription()));
}
}
if (!diskSnapshotInfo.isEmpty()) {
EngineMessage message = EngineMessage.ACTION_TYPE_FAILED_VM_DISK_SNAPSHOT_NOT_ATTACHED_TO_VM;
return new ValidationResult(message, String.format("$disksInfo %s", String.format(StringUtils.join(diskSnapshotInfo, "%n"))), String.format("$vmName %s", vm.getName()));
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class GetAllVmSnapshotsByVmIdQueryTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
vmId = Guid.newGuid();
snapshot = new Snapshot(Guid.newGuid(), SnapshotStatus.OK, vmId, null, SnapshotType.REGULAR, "", new Date(), "");
setUpDaoMocks();
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class GetAllVmSnapshotsWithLeasesFromConfigurationByVmIdQueryTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
vmId = Guid.newGuid();
snapshot = new Snapshot(Guid.newGuid(), SnapshotStatus.OK, vmId, null, SnapshotType.REGULAR, "", new Date(), "");
disk1 = new DiskImage();
disk2 = new DiskImage();
snapshotVmConfigurationHelper = spy(new SnapshotVmConfigurationHelper());
when(getQuery().getSnapshotVmConfigurationHelper()).thenReturn(snapshotVmConfigurationHelper);
setUpDaoMocks();
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class RemoveSnapshotCommandTest method mockSnapshot.
private void mockSnapshot(SnapshotType snapshotType) {
Snapshot snapshot = new Snapshot();
snapshot.setId(cmd.getParameters().getSnapshotId());
snapshot.setType(snapshotType);
doReturn(snapshot).when(snapshotDao).get(snapshot.getId());
}
Aggregations