Search in sources :

Example 11 with VmWatchdog

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

the class CloneVmCommand method setupParameters.

private void setupParameters() {
    setVmId(Guid.newGuid());
    VM vmToClone = getVm();
    getParameters().setNewVmGuid(getVmId());
    getParameters().setVm(vmToClone);
    List<VmDevice> devices = vmDeviceDao.getVmDeviceByVmId(oldVmId);
    getParameters().setSoundDeviceEnabled(containsDeviceWithType(devices, VmDeviceGeneralType.SOUND));
    getParameters().setConsoleEnabled(containsDeviceWithType(devices, VmDeviceGeneralType.CONSOLE));
    getParameters().setVirtioScsiEnabled(containsDeviceWithType(devices, VmDeviceGeneralType.CONTROLLER, VmDeviceType.VIRTIOSCSI));
    getParameters().setBalloonEnabled(containsDeviceWithType(devices, VmDeviceGeneralType.BALLOON));
    setGraphicsDevices(devices);
    QueryReturnValue watchdogs = runInternalQuery(QueryType.GetWatchdog, new IdQueryParameters(oldVmId));
    if (!((List<VmWatchdog>) watchdogs.getReturnValue()).isEmpty()) {
        VmWatchdog watchdog = ((List<VmWatchdog>) watchdogs.getReturnValue()).iterator().next();
        getParameters().setUpdateWatchdog(true);
        getParameters().setWatchdog(watchdog);
    }
    fillDisksToParameters();
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VM(org.ovirt.engine.core.common.businessentities.VM) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog)

Example 12 with VmWatchdog

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

the class BackendVmWatchdogResourceTest method getEntity.

private VmWatchdog getEntity() {
    VmWatchdog watchdog = new VmWatchdog();
    watchdog.setId(WATCHDOG_ID);
    watchdog.setAction(VmWatchdogAction.RESET);
    watchdog.setModel(VmWatchdogType.i6300esb);
    return watchdog;
}
Also used : VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog)

Example 13 with VmWatchdog

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

the class BackendVmWatchdogsResourceTest method getEntity.

private VmWatchdog getEntity() {
    VmWatchdog watchdog = new VmWatchdog();
    watchdog.setId(WATCHDOG_ID);
    watchdog.setAction(VmWatchdogAction.RESET);
    watchdog.setModel(VmWatchdogType.i6300esb);
    return watchdog;
}
Also used : VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog)

Example 14 with VmWatchdog

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

the class VmHandler method addDeviceUpdateOnNextRun.

private boolean addDeviceUpdateOnNextRun(Guid vmId, VmDeviceGeneralType generalType, VmDeviceType type, boolean readOnly, String name, Object key, Object value, List<VmDeviceUpdate> updates) {
    if (key != null) {
        VmDeviceGeneralType keyGeneralType = VmDeviceGeneralType.UNKNOWN;
        VmDeviceType keyType = VmDeviceType.UNKNOWN;
        if (key instanceof VmDeviceGeneralType) {
            keyGeneralType = (VmDeviceGeneralType) key;
        } else if (key instanceof VmDeviceType) {
            keyType = (VmDeviceType) key;
        } else if (key instanceof GraphicsType) {
            keyType = ((GraphicsType) key).getCorrespondingDeviceType();
        } else {
            log.warn("addDeviceUpdateOnNextRun: Unsupported map key type: " + key.getClass().getName());
            return false;
        }
        if (keyGeneralType != VmDeviceGeneralType.UNKNOWN) {
            generalType = keyGeneralType;
        }
        if (keyType != VmDeviceType.UNKNOWN) {
            type = keyType;
        }
    }
    // if device type is set to unknown, search by general type only
    // because some devices have more than one type, like sound can be ac97/ich6
    String typeName = type != VmDeviceType.UNKNOWN ? type.getName() : null;
    if (value == null) {
        if (vmDeviceUtils.vmDeviceChanged(vmId, generalType, typeName, false)) {
            updates.add(new VmDeviceUpdate(generalType, type, readOnly, name, false));
        }
    } else if (value instanceof Boolean) {
        if (vmDeviceUtils.vmDeviceChanged(vmId, generalType, typeName, (Boolean) value)) {
            updates.add(new VmDeviceUpdate(generalType, type, readOnly, name, (Boolean) value));
        }
    } else if (value instanceof VmDevice) {
        if (vmDeviceUtils.vmDeviceChanged(vmId, generalType, typeName, (VmDevice) value)) {
            updates.add(new VmDeviceUpdate(generalType, type, readOnly, name, (VmDevice) value));
        }
    } else if (value instanceof VmWatchdog) {
        if (vmDeviceUtils.vmDeviceChanged(vmId, generalType, typeName, ((VmWatchdog) value).getVmDevice())) {
            updates.add(new VmDeviceUpdate(generalType, type, readOnly, name, ((VmWatchdog) value).getVmDevice()));
        }
    } else {
        log.warn("addDeviceUpdateOnNextRun: Unsupported value type: " + value.getClass().getName());
        return false;
    }
    return true;
}
Also used : GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VmDeviceUpdate(org.ovirt.engine.core.common.utils.VmDeviceUpdate) VmDeviceType(org.ovirt.engine.core.common.utils.VmDeviceType) VmDeviceGeneralType(org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog)

Example 15 with VmWatchdog

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

the class UpdateWatchdogCommandTest method testValidate.

@Test
public void testValidate() {
    Guid vmGuid = new Guid("a09f57b1-5739-4352-bf88-a6f834ed46db");
    command.getParameters().setId(vmGuid);
    command.getParameters().setAction(VmWatchdogAction.PAUSE);
    command.getParameters().setModel(vmWatchdogType);
    when(vmDaoMock.get(vmGuid)).thenReturn(new VM());
    when(vmDeviceDaoMock.getVmDeviceByVmIdAndType(vmGuid, VmDeviceGeneralType.WATCHDOG)).thenReturn(Collections.singletonList(new VmDevice()));
    VmWatchdog vmWatchdog = spy(new VmWatchdog());
    when(vmWatchdog.getModel()).thenReturn(vmWatchdogType);
    assertTrue(command.validate());
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VM(org.ovirt.engine.core.common.businessentities.VM) Guid(org.ovirt.engine.core.compat.Guid) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) Test(org.junit.Test)

Aggregations

VmWatchdog (org.ovirt.engine.core.common.businessentities.VmWatchdog)27 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)7 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)7 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)6 Guid (org.ovirt.engine.core.compat.Guid)5 Test (org.junit.Test)4 GraphicsType (org.ovirt.engine.core.common.businessentities.GraphicsType)4 Arrays (java.util.Arrays)3 Collection (java.util.Collection)3 List (java.util.List)3 Watchdog (org.ovirt.engine.api.model.Watchdog)3 GraphicsDevice (org.ovirt.engine.core.common.businessentities.GraphicsDevice)3 VmBase (org.ovirt.engine.core.common.businessentities.VmBase)3 VmRngDevice (org.ovirt.engine.core.common.businessentities.VmRngDevice)3 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)3 VmWatchdogType (org.ovirt.engine.core.common.businessentities.VmWatchdogType)3 QueryType (org.ovirt.engine.core.common.queries.QueryType)3 AsyncQuery (org.ovirt.engine.ui.frontend.AsyncQuery)3 Frontend (org.ovirt.engine.ui.frontend.Frontend)3 BuilderExecutor (org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor)3