Search in sources :

Example 21 with VdsActionParameters

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

the class ActivateDeactivateVmNicCommand method plugNic.

private void plugNic() {
    clearAddressIfPciSlotIsDuplicated(vmDevice);
    // HotPlug in the host is called only if the Vm is UP
    if (hotPlugVmNicRequired(getVm().getStatus())) {
        boolean externalNetworkIsPlugged = getNetwork() != null && getNetwork().isExternal();
        if (externalNetworkIsPlugged) {
            plugToExternalNetwork();
        }
        String vfToUse = null;
        try {
            if (isPassthrough()) {
                String preallocatedVfForNic = getVfPreallocatedForNic();
                boolean preallocatedVfExist = preallocatedVfForNic != null;
                if (preallocatedVfExist) {
                    vfToUse = preallocatedVfForNic;
                } else {
                    vfToUse = acquireVF();
                    if (vfToUse == null) {
                        failValidationCannotPlugPassthroughVnicNoSuitableVf();
                        return;
                    }
                    networkDeviceHelper.setVmIdOnVfs(getVdsId(), getVmId(), Collections.singleton(vfToUse));
                }
                vmDevice.setHostDevice(vfToUse);
            }
            if (executePlugOrUnplug(PlugAction.PLUG)) {
                if (isPassthrough()) {
                    runInternalAction(ActionType.RefreshHost, new VdsActionParameters(getVdsId()));
                }
            } else {
                clearPassthroughData(vfToUse);
            }
        } catch (EngineException e) {
            if (externalNetworkIsPlugged && getParameters().isNewNic()) {
                unplugFromExternalNetwork();
            }
            clearPassthroughData(vfToUse);
            throw e;
        }
    }
}
Also used : VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) EngineException(org.ovirt.engine.core.common.errors.EngineException)

Example 22 with VdsActionParameters

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

the class ActivateDeactivateVmNicCommand method unplugNic.

private void unplugNic() {
    if (hotPlugVmNicRequired(getVm().getStatus())) {
        if (executePlugOrUnplug(PlugAction.UNPLUG)) {
            if (isPassthrough()) {
                clearPassthroughData(vmDevice.getHostDevice());
                runInternalAction(ActionType.RefreshHost, new VdsActionParameters(getVdsId()));
            }
        }
    }
}
Also used : VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters)

Aggregations

VdsActionParameters (org.ovirt.engine.core.common.action.VdsActionParameters)22 VDS (org.ovirt.engine.core.common.businessentities.VDS)11 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)9 ArrayList (java.util.ArrayList)7 AddVdsActionParameters (org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters)7 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)6 FenceVdsActionParameters (org.ovirt.engine.core.common.action.FenceVdsActionParameters)5 UpdateVdsActionParameters (org.ovirt.engine.core.common.action.hostdeploy.UpdateVdsActionParameters)4 Guid (org.ovirt.engine.core.compat.Guid)4 EngineException (org.ovirt.engine.core.common.errors.EngineException)3 Timer (com.google.gwt.user.client.Timer)2 ChangeVDSClusterParameters (org.ovirt.engine.core.common.action.ChangeVDSClusterParameters)2 ApproveVdsParameters (org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters)2 InstallVdsParameters (org.ovirt.engine.core.common.action.hostdeploy.InstallVdsParameters)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2 JsSingleValueStringObject (org.ovirt.engine.ui.frontend.utils.JsSingleValueStringObject)2 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)2 MoveHost (org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHost)2 MoveHostData (org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHostData)2 HashMap (java.util.HashMap)1