Search in sources :

Example 1 with WatchdogParameters

use of org.ovirt.engine.core.common.action.WatchdogParameters in project ovirt-engine by oVirt.

the class AddVmCommand method buildWatchdogParameters.

private WatchdogParameters buildWatchdogParameters(VmWatchdog vmWatchdog) {
    WatchdogParameters parameters = new WatchdogParameters();
    parameters.setId(getParameters().getVmId());
    parameters.setAction(vmWatchdog.getAction());
    parameters.setModel(vmWatchdog.getModel());
    return parameters;
}
Also used : WatchdogParameters(org.ovirt.engine.core.common.action.WatchdogParameters)

Example 2 with WatchdogParameters

use of org.ovirt.engine.core.common.action.WatchdogParameters in project ovirt-engine by oVirt.

the class UpdateVmCommand method updateWatchdog.

private void updateWatchdog() {
    // do not update if this flag is not set
    if (getParameters().isUpdateWatchdog()) {
        QueryReturnValue query = runInternalQuery(QueryType.GetWatchdog, new IdQueryParameters(getParameters().getVmId()));
        List<VmWatchdog> watchdogs = query.getReturnValue();
        if (watchdogs.isEmpty()) {
            if (getParameters().getWatchdog() == null) {
            // nothing to do, no watchdog and no watchdog to create
            } else {
                WatchdogParameters parameters = new WatchdogParameters();
                parameters.setId(getParameters().getVmId());
                parameters.setAction(getParameters().getWatchdog().getAction());
                parameters.setModel(getParameters().getWatchdog().getModel());
                runInternalAction(ActionType.AddWatchdog, parameters, cloneContextAndDetachFromParent());
            }
        } else {
            WatchdogParameters watchdogParameters = new WatchdogParameters();
            watchdogParameters.setId(getParameters().getVmId());
            if (getParameters().getWatchdog() == null) {
                // there is a watchdog in the vm, there should not be any, so let's delete
                runInternalAction(ActionType.RemoveWatchdog, watchdogParameters, cloneContextAndDetachFromParent());
            } else {
                // there is a watchdog in the vm, we have to update.
                watchdogParameters.setAction(getParameters().getWatchdog().getAction());
                watchdogParameters.setModel(getParameters().getWatchdog().getModel());
                runInternalAction(ActionType.UpdateWatchdog, watchdogParameters, cloneContextAndDetachFromParent());
            }
        }
    }
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) WatchdogParameters(org.ovirt.engine.core.common.action.WatchdogParameters) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog)

Example 3 with WatchdogParameters

use of org.ovirt.engine.core.common.action.WatchdogParameters in project ovirt-engine by oVirt.

the class BackendInstanceTypeWatchdogResource method remove.

@Override
public Response remove() {
    get();
    WatchdogParameters parameters = new WatchdogParameters();
    parameters.setId(instanceTypeId);
    parameters.setVm(false);
    return performAction(ActionType.RemoveWatchdog, parameters);
}
Also used : WatchdogParameters(org.ovirt.engine.core.common.action.WatchdogParameters)

Example 4 with WatchdogParameters

use of org.ovirt.engine.core.common.action.WatchdogParameters in project ovirt-engine by oVirt.

the class BackendVmWatchdogResource method remove.

@Override
public Response remove() {
    get();
    WatchdogParameters parameters = new WatchdogParameters();
    parameters.setId(vmId);
    parameters.setVm(true);
    return performAction(ActionType.RemoveWatchdog, parameters);
}
Also used : WatchdogParameters(org.ovirt.engine.core.common.action.WatchdogParameters)

Example 5 with WatchdogParameters

use of org.ovirt.engine.core.common.action.WatchdogParameters in project ovirt-engine by oVirt.

the class BackendVmWatchdogsResource method add.

public Response add(Watchdog watchdog) {
    validateParameters(watchdog, "action", "model");
    WatchdogParameters parameters = new WatchdogParameters();
    if (watchdog.isSetAction()) {
        parameters.setAction(WatchdogMapper.map(watchdog.getAction()));
    }
    if (watchdog.isSetModel()) {
        parameters.setModel(WatchdogMapper.map(watchdog.getModel()));
    }
    parameters.setId(vmId);
    parameters.setVm(true);
    return performCreate(ActionType.AddWatchdog, parameters, new WatchdogResolver());
}
Also used : WatchdogParameters(org.ovirt.engine.core.common.action.WatchdogParameters)

Aggregations

WatchdogParameters (org.ovirt.engine.core.common.action.WatchdogParameters)9 VmWatchdog (org.ovirt.engine.core.common.businessentities.VmWatchdog)2 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)2 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)2