Search in sources :

Example 1 with ActivateDeactivateVmNicParameters

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

the class AbstractVmInterfaceCommand method activateOrDeactivateNic.

protected boolean activateOrDeactivateNic(VmNic nic, PlugAction plugAction, boolean newNic) {
    ActivateDeactivateVmNicParameters parameters = new ActivateDeactivateVmNicParameters(nic, plugAction, newNic);
    parameters.setVmId(getParameters().getVmId());
    ActionReturnValue returnValue = runInternalAction(ActionType.ActivateDeactivateVmNic, parameters, cloneContextAndDetachFromParent());
    if (!returnValue.getSucceeded()) {
        propagateFailure(returnValue);
    }
    return returnValue.getSucceeded();
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ActivateDeactivateVmNicParameters(org.ovirt.engine.core.common.action.ActivateDeactivateVmNicParameters)

Example 2 with ActivateDeactivateVmNicParameters

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

the class MigrateVmCommand method unplugPassthroughNics.

/**
 * When unplugging fails for any nic, we stop immediately. In that case we won't proceed with migration, and thus
 * it makes sense to stop asap to create minimum problems which needs to be fixed manually.
 *
 * @return false if unplugging failed.
 */
private boolean unplugPassthroughNics() {
    if (passthroughNicsUnplugged) {
        // no need to unplug more than once
        return true;
    }
    List<ActivateDeactivateVmNicParameters> parametersList = createActivateDeactivateVmNicParameters(getAllVmPassthroughNics(), PlugAction.UNPLUG);
    log.debug("About to call {} with parameters: {}", ActionType.ActivateDeactivateVmNic, Arrays.toString(parametersList.toArray()));
    for (ActivateDeactivateVmNicParameters parameter : parametersList) {
        ActionReturnValue returnValue = runInternalAction(ActionType.ActivateDeactivateVmNic, parameter);
        if (!returnValue.getSucceeded()) {
            returnValue.getValidationMessages().forEach(this::addValidationMessage);
            return false;
        }
    }
    passthroughNicsUnplugged = true;
    return true;
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ActivateDeactivateVmNicParameters(org.ovirt.engine.core.common.action.ActivateDeactivateVmNicParameters)

Example 3 with ActivateDeactivateVmNicParameters

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

the class MigrateVmCommand method createActivateDeactivateVmNicParameters.

private ActivateDeactivateVmNicParameters createActivateDeactivateVmNicParameters(VmNic nic, PlugAction plugAction) {
    ActivateDeactivateVmNicParameters parameters = new ActivateDeactivateVmNicParameters(nic, plugAction, false);
    parameters.setVmId(getParameters().getVmId());
    return parameters;
}
Also used : ActivateDeactivateVmNicParameters(org.ovirt.engine.core.common.action.ActivateDeactivateVmNicParameters)

Example 4 with ActivateDeactivateVmNicParameters

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

the class MigrateVmCommand method replugNics.

private List<VmNic> replugNics(List<ActivateDeactivateVmNicParameters> parametersList) {
    log.debug("About to call {} with parameters: {}", ActionType.ActivateDeactivateVmNic, Arrays.toString(parametersList.toArray()));
    List<VmNic> notRepluggedNics = new ArrayList<>();
    for (ActivateDeactivateVmNicParameters parameter : parametersList) {
        ActionReturnValue returnValue = runInternalAction(ActionType.ActivateDeactivateVmNic, parameter);
        boolean nicPlugSucceeded = returnValue.getSucceeded();
        if (!nicPlugSucceeded) {
            notRepluggedNics.add(parameter.getNic());
        }
    }
    return notRepluggedNics;
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ArrayList(java.util.ArrayList) ActivateDeactivateVmNicParameters(org.ovirt.engine.core.common.action.ActivateDeactivateVmNicParameters) VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic)

Aggregations

ActivateDeactivateVmNicParameters (org.ovirt.engine.core.common.action.ActivateDeactivateVmNicParameters)4 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)3 ArrayList (java.util.ArrayList)1 VmNic (org.ovirt.engine.core.common.businessentities.network.VmNic)1