Search in sources :

Example 1 with VmWatchdog

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

the class InstanceTypeListModel method setVmWatchdogToParams.

private void setVmWatchdogToParams(final UnitVmModel model, VmTemplateManagementParameters updateVmParams) {
    VmWatchdogType wdModel = model.getWatchdogModel().getSelectedItem();
    updateVmParams.setUpdateWatchdog(true);
    if (wdModel != null) {
        VmWatchdog vmWatchdog = new VmWatchdog();
        vmWatchdog.setAction(model.getWatchdogAction().getSelectedItem());
        vmWatchdog.setModel(wdModel);
        updateVmParams.setWatchdog(vmWatchdog);
    }
}
Also used : VmWatchdogType(org.ovirt.engine.core.common.businessentities.VmWatchdogType) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog)

Example 2 with VmWatchdog

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

the class ExistingNonClusterModelBehavior method doBuild.

public void doBuild() {
    buildModel(entity, (source, destination) -> {
        Frontend.getInstance().runQuery(QueryType.IsBalloonEnabled, new IdQueryParameters(entity.getId()), new AsyncQuery<>((QueryReturnValue returnValue) -> getModel().getMemoryBalloonDeviceEnabled().setEntity((Boolean) returnValue.getReturnValue())));
        getInstance().isVirtioScsiEnabledForVm(new AsyncQuery<>(returnValue -> getModel().getIsVirtioScsiEnabled().setEntity(returnValue)), entity.getId());
        getInstance().getWatchdogByVmId(new AsyncQuery<QueryReturnValue>(returnValue -> {
            @SuppressWarnings("unchecked") Collection<VmWatchdog> watchdogs = returnValue.getReturnValue();
            for (VmWatchdog watchdog : watchdogs) {
                getModel().getWatchdogAction().setSelectedItem(watchdog.getAction());
                getModel().getWatchdogModel().setSelectedItem(watchdog.getModel());
            }
        }), entity.getId());
        Frontend.getInstance().runQuery(QueryType.GetRngDevice, new IdQueryParameters(entity.getId()), new AsyncQuery<QueryReturnValue>(returnValue -> {
            List<VmDevice> rngDevices = returnValue.getReturnValue();
            getModel().getIsRngEnabled().setEntity(!rngDevices.isEmpty());
            if (!rngDevices.isEmpty()) {
                VmRngDevice rngDevice = new VmRngDevice(rngDevices.get(0));
                getModel().setRngDevice(rngDevice);
            }
        }));
        getModel().getEmulatedMachine().setSelectedItem(entity.getCustomEmulatedMachine());
        getModel().getCustomCpu().setSelectedItem(entity.getCustomCpuName());
        getModel().getMigrationMode().setSelectedItem(entity.getMigrationSupport());
        postBuild();
    });
}
Also used : UsbPolicy(org.ovirt.engine.core.common.businessentities.UsbPolicy) QueryType(org.ovirt.engine.core.common.queries.QueryType) AsyncDataProvider.getInstance(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider.getInstance) Arrays(java.util.Arrays) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) NameAndDescriptionVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.NameAndDescriptionVmBaseToUnitBuilder) Guid(org.ovirt.engine.core.compat.Guid) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Set(java.util.Set) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) HashSet(java.util.HashSet) HwOnlyVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.HwOnlyVmBaseToUnitBuilder) Frontend(org.ovirt.engine.ui.frontend.Frontend) List(java.util.List) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Collection(java.util.Collection) List(java.util.List) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice)

Example 3 with VmWatchdog

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

the class AddVmCommand method addVmWatchdog.

private void addVmWatchdog() {
    VmWatchdog vmWatchdog = getParameters().getWatchdog();
    if (vmWatchdog != null) {
        ActionType actionType = getVmDeviceUtils().hasWatchdog(getVmTemplateId()) ? ActionType.UpdateWatchdog : ActionType.AddWatchdog;
        runInternalAction(actionType, buildWatchdogParameters(vmWatchdog), cloneContextAndDetachFromParent());
    }
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog)

Example 4 with VmWatchdog

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

the class GetWatchdogQueryTest method executeQueryCommandWithWatchdog.

@Test
public void executeQueryCommandWithWatchdog() {
    Map<String, Object> watchdogSpecParams = new HashMap<>();
    watchdogSpecParams.put("model", "i6300esb");
    watchdogSpecParams.put("action", "reset");
    VmDevice vmDevice = new VmDevice(new VmDeviceId(new Guid("6f86b8a4-e721-4149-b2df-056eb621b16a"), TEST_VM_ID), VmDeviceGeneralType.WATCHDOG, VmDeviceType.WATCHDOG.getName(), "", watchdogSpecParams, true, true, true, "", null, null, null);
    when(vmDeviceDao.getVmDeviceByVmIdAndType(TEST_VM_ID, VmDeviceGeneralType.WATCHDOG)).thenReturn(Collections.singletonList(vmDevice));
    getQuery().executeQueryCommand();
    List<VmWatchdog> result = getQuery().getQueryReturnValue().getReturnValue();
    assertNotNull(result);
    assertFalse(result.isEmpty());
    VmWatchdog watchdog = result.get(0);
    assertEquals("reset", watchdog.getAction().name().toLowerCase());
    assertEquals("i6300esb", watchdog.getModel().name().toLowerCase());
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) HashMap(java.util.HashMap) Guid(org.ovirt.engine.core.compat.Guid) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId) Test(org.junit.Test)

Example 5 with VmWatchdog

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

the class TemplateListModel method setVmWatchdogToParams.

private void setVmWatchdogToParams(final UnitVmModel model, UpdateVmTemplateParameters updateVmParams) {
    VmWatchdogType wdModel = model.getWatchdogModel().getSelectedItem();
    updateVmParams.setUpdateWatchdog(true);
    if (wdModel != null) {
        VmWatchdog vmWatchdog = new VmWatchdog();
        vmWatchdog.setAction(model.getWatchdogAction().getSelectedItem());
        vmWatchdog.setModel(wdModel);
        updateVmParams.setWatchdog(vmWatchdog);
    }
}
Also used : VmWatchdogType(org.ovirt.engine.core.common.businessentities.VmWatchdogType) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog)

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