Search in sources :

Example 66 with VmDeviceId

use of org.ovirt.engine.core.common.businessentities.VmDeviceId in project ovirt-engine by oVirt.

the class VmDeviceCommonUtils method addVirtIoScsiDevice.

public static void addVirtIoScsiDevice(VmBase vmBase) {
    VmDevice vmDevice = new VmDevice();
    vmDevice.setId(new VmDeviceId(Guid.newGuid(), vmBase.getId()));
    vmDevice.setType(VmDeviceGeneralType.CONTROLLER);
    vmDevice.setDevice(VmDeviceType.VIRTIOSCSI.getName());
    vmDevice.setManaged(true);
    vmDevice.setPlugged(true);
    vmDevice.setReadOnly(false);
    vmDevice.setAddress("");
    vmBase.getManagedDeviceMap().put(vmDevice.getDeviceId(), vmDevice);
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Example 67 with VmDeviceId

use of org.ovirt.engine.core.common.businessentities.VmDeviceId in project ovirt-engine by oVirt.

the class UpdateVmCommand method updateVmPayload.

protected void updateVmPayload() {
    VmPayload payload = getParameters().getVmPayload();
    if (payload != null || getParameters().isClearPayload()) {
        List<VmDevice> disks = vmDeviceDao.getVmDeviceByVmIdAndType(getVmId(), VmDeviceGeneralType.DISK);
        VmDevice oldPayload = null;
        for (VmDevice disk : disks) {
            if (VmPayload.isPayload(disk.getSpecParams())) {
                oldPayload = disk;
                break;
            }
        }
        if (oldPayload != null) {
            List<VmDeviceId> devs = new ArrayList<>();
            devs.add(oldPayload.getId());
            vmDeviceDao.removeAll(devs);
        }
        if (!getParameters().isClearPayload()) {
            getVmDeviceUtils().addManagedDevice(new VmDeviceId(Guid.newGuid(), getVmId()), VmDeviceGeneralType.DISK, payload.getDeviceType(), payload.getSpecParams(), true, true);
        }
    }
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VmPayload(org.ovirt.engine.core.common.businessentities.VmPayload) ArrayList(java.util.ArrayList) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Example 68 with VmDeviceId

use of org.ovirt.engine.core.common.businessentities.VmDeviceId in project ovirt-engine by oVirt.

the class VmTemplateManagementCommand method removeNetwork.

protected void removeNetwork() {
    List<VmNic> list = vmNicDao.getAllForTemplate(getVmTemplateId());
    for (VmNic iface : list) {
        vmDeviceDao.remove(new VmDeviceId(iface.getId(), getVmTemplateId()));
        vmNicDao.remove(iface.getId());
    }
}
Also used : VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId) VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic)

Example 69 with VmDeviceId

use of org.ovirt.engine.core.common.businessentities.VmDeviceId in project ovirt-engine by oVirt.

the class AddVmTemplateCommand method addTemplateDiskVmElement.

private void addTemplateDiskVmElement(Guid newDiskId, Guid oldDiskId) {
    DiskVmElement oldDve = diskVmElementDao.get(new VmDeviceId(oldDiskId, getVmId()));
    DiskVmElement newDve = DiskVmElement.copyOf(oldDve);
    newDve.setId(new VmDeviceId(newDiskId, getVmTemplateId()));
    diskVmElementDao.save(newDve);
}
Also used : DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Example 70 with VmDeviceId

use of org.ovirt.engine.core.common.businessentities.VmDeviceId in project ovirt-engine by oVirt.

the class HotSetAmountOfMemoryCommand method createMemoryDevice.

private VmDevice createMemoryDevice() {
    Map<String, Object> specParams = new HashMap<>();
    specParams.put(DEVICE_SIZE_FIELD_KEY, String.valueOf(getParameters().getMemoryDeviceSizeMb()));
    specParams.put(DEVICE_NODE_FIELD_KEY, String.valueOf(getParameters().getNumaNode()));
    return new VmDevice(new VmDeviceId(Guid.newGuid(), getVmId()), VmDeviceGeneralType.MEMORY, VmDeviceType.MEMORY.getName(), "", specParams, true, true, false, "", null, null, null);
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) HashMap(java.util.HashMap) 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