Search in sources :

Example 16 with VmDeviceId

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());
}
Also used : ArrayList(java.util.ArrayList) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Example 17 with VmDeviceId

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;
}
Also used : ArrayList(java.util.ArrayList) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) Guid(org.ovirt.engine.core.compat.Guid) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Example 18 with VmDeviceId

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);
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Example 19 with VmDeviceId

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;
}
Also used : DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Example 20 with VmDeviceId

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());
    }
}
Also used : DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Aggregations

VmDeviceId (org.ovirt.engine.core.common.businessentities.VmDeviceId)75 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)40 DiskVmElement (org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)21 Guid (org.ovirt.engine.core.compat.Guid)19 HashMap (java.util.HashMap)13 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)12 Test (org.junit.Test)10 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)9 ArrayList (java.util.ArrayList)7 Map (java.util.Map)5 GraphicsType (org.ovirt.engine.core.common.businessentities.GraphicsType)5 VM (org.ovirt.engine.core.common.businessentities.VM)5 VmPayload (org.ovirt.engine.core.common.businessentities.VmPayload)4 VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)4 VmNic (org.ovirt.engine.core.common.businessentities.network.VmNic)4 Collection (java.util.Collection)3 HashSet (java.util.HashSet)3 DisplayType (org.ovirt.engine.core.common.businessentities.DisplayType)3 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)3 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)3