use of org.ovirt.engine.core.common.businessentities.VmDeviceId in project ovirt-engine by oVirt.
the class GetAllDisksByVmIdQueryTest method setUpDaoMocks.
private void setUpDaoMocks() {
// Disk Image Dao
List<Disk> returnArray = new ArrayList<>();
returnArray.add(pluggedDisk);
returnArray.add(unpluggedDisk);
returnArray.add(pluggedDiskSnapshot);
returnArray.add(unpluggedDiskSnapshot);
when(diskDaoMock.getAllForVm(vmID, getUser().getId(), getQueryParameters().isFiltered())).thenReturn(returnArray);
when(diskVmElementDao.get(any())).thenReturn(new DiskVmElement(new VmDeviceId()));
// Snapshots
doReturn(new ArrayList<>(Collections.nCopies(NUM_DISKS_OF_EACH_KIND, createDiskSnapshot(pluggedDisk.getId())))).when(diskImageDao).getAllSnapshotsForLeaf(pluggedDisk.getImageId());
doReturn(Collections.nCopies(NUM_DISKS_OF_EACH_KIND, createDiskSnapshot(unpluggedDisk.getId()))).when(diskImageDao).getAllSnapshotsForLeaf(unpluggedDisk.getImageId());
doReturn(new ArrayList<>(Collections.nCopies(NUM_DISKS_OF_EACH_KIND, createDiskSnapshot(pluggedDiskSnapshot.getId())))).when(diskImageDao).getAllSnapshotsForLeaf(pluggedDiskSnapshot.getImageId());
doReturn(Collections.nCopies(NUM_DISKS_OF_EACH_KIND, createDiskSnapshot(unpluggedDiskSnapshot.getId()))).when(diskImageDao).getAllSnapshotsForLeaf(unpluggedDiskSnapshot.getImageId());
}
use of org.ovirt.engine.core.common.businessentities.VmDeviceId in project ovirt-engine by oVirt.
the class HotPlugDiskToVmCommandTest method mockDiskImage.
private DiskImage mockDiskImage(DiskInterface iface) {
disk.setImageId(diskImageGuid);
ArrayList<Guid> storageIdList = new ArrayList<>();
storageIdList.add(storageDomainId);
disk.setStorageIds(storageIdList);
disk.setStoragePoolId(storagePoolId);
disk.setActive(true);
disk.setId(Guid.newGuid());
when(diskDao.get(diskImageGuid)).thenReturn(disk);
DiskVmElement dve = new DiskVmElement(disk.getId(), vmId);
dve.setDiskInterface(iface);
when(diskVmElementDao.get(new VmDeviceId(disk.getId(), vmId))).thenReturn(dve);
return disk;
}
use of org.ovirt.engine.core.common.businessentities.VmDeviceId in project ovirt-engine by oVirt.
the class HotPlugDiskToVmCommandTest method mockVmDevice.
protected void mockVmDevice(boolean plugged) {
vmDevice = new VmDevice();
vmDevice.setId(new VmDeviceId());
vmDevice.setPlugged(plugged);
when(vmDeviceDao.get(any())).thenReturn(vmDevice);
}
use of org.ovirt.engine.core.common.businessentities.VmDeviceId in project ovirt-engine by oVirt.
the class MoveDiskCommandTest method createMockDiskVmElement.
private DiskVmElement createMockDiskVmElement(Guid vmId, boolean plugged) {
DiskVmElement diskVmElement = new DiskVmElement();
diskVmElement.setId(new VmDeviceId(Guid.newGuid(), vmId));
diskVmElement.setPlugged(plugged);
return diskVmElement;
}
use of org.ovirt.engine.core.common.businessentities.VmDeviceId in project ovirt-engine by oVirt.
the class OvfReader method fixDiskVmElements.
private void fixDiskVmElements() {
// the wrong VM ID this part sets them to the correct VM ID
for (DiskImage disk : _images) {
disk.getDiskVmElements().forEach(dve -> dve.setId(new VmDeviceId(disk.getId(), vmBase.getId())));
disk.setDiskVmElements(disk.getDiskVmElements());
}
for (LunDisk lunDisk : luns) {
lunDisk.getDiskVmElements().forEach(dve -> dve.setId(new VmDeviceId(lunDisk.getId(), vmBase.getId())));
lunDisk.setDiskVmElements(lunDisk.getDiskVmElements());
}
}
Aggregations