Search in sources :

Example 11 with VdsActionParameters

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

the class SaveNetworkConfigAction method execute.

public void execute() {
    Frontend.getInstance().runAction(ActionType.CommitNetworkChanges, new VdsActionParameters(host.getId()), result -> {
        ActionReturnValue returnValueBase = result.getReturnValue();
        if (returnValueBase != null && returnValueBase.getSucceeded()) {
            if (windowModel != null) {
                windowModel.stopProgress();
                listModel.setWindow(null);
                listModel.setConfirmWindow(null);
                listModel.search();
            }
        }
    }, null);
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters)

Example 12 with VdsActionParameters

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

the class UpgradeHostInternalCommand method executeCommand.

@Override
protected void executeCommand() {
    getCompensationContext().snapshotEntityStatus(getVds().getDynamicData(), getParameters().getInitialStatus());
    getCompensationContext().stateChanged();
    VDSType vdsType = getVds().getVdsType();
    if (vdsType == VDSType.VDS || vdsType == VDSType.oVirtNode) {
        try {
            setVdsStatus(VDSStatus.Installing);
            upgradeManager.update(getVds());
            if (vdsType == VDSType.oVirtNode || getParameters().isReboot()) {
                VdsActionParameters params = new VdsActionParameters(getVds().getId());
                params.setPrevVdsStatus(getParameters().getInitialStatus());
                ActionReturnValue returnValue = runInternalAction(ActionType.SshHostReboot, params, ExecutionHandler.createInternalJobContext());
                if (!returnValue.getSucceeded()) {
                    setVdsStatus(VDSStatus.InstallFailed);
                    log.error("Engine failed to restart via ssh host '{}' ('{}') after upgrade", getVds().getName(), getVds().getId());
                    return;
                }
            } else {
                // letting the host a chance to recover from restarting the VDSM service after the upgrade
                if (!new HostConnectivityChecker().check(getVds())) {
                    log.warn("Engine failed to communicate with VDSM agent on host '{}' with address '{}' ('{}') " + "after upgrade", getVds().getName(), getVds().getHostName(), getVds().getId());
                }
            }
        } catch (Exception e) {
            setVdsStatus(VDSStatus.InstallFailed);
            return;
        }
    } else if (getVds().isOvirtVintageNode()) {
        InstallVdsParameters parameters = new InstallVdsParameters(getVdsId());
        parameters.setIsReinstallOrUpgrade(true);
        parameters.setoVirtIsoFile(getParameters().getoVirtIsoFile());
        parameters.setActivateHost(getParameters().getInitialStatus() == VDSStatus.Up);
        ActionReturnValue result = runInternalAction(ActionType.UpgradeOvirtNodeInternal, parameters);
        if (!result.getSucceeded()) {
            setVdsStatus(VDSStatus.InstallFailed);
            propagateFailure(result);
            return;
        }
    }
    try {
        updateHostStatusAfterSuccessfulUpgrade();
        setSucceeded(true);
    } catch (Exception e) {
        log.error("Failed to set new status for host '{}' after upgrade has ended.", getVdsName());
        log.error("Exception", e);
        setVdsStatus(VDSStatus.InstallFailed);
    }
}
Also used : VDSType(org.ovirt.engine.core.common.businessentities.VDSType) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) InstallVdsParameters(org.ovirt.engine.core.common.action.hostdeploy.InstallVdsParameters) HostConnectivityChecker(org.ovirt.engine.core.bll.host.HostConnectivityChecker) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters)

Example 13 with VdsActionParameters

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

the class PowerSavingBalancePolicyUnit method processPmAction.

private void processPmAction(Pair<VDS, VDSStatus> action) {
    VDS vds = action.getFirst();
    VDSStatus currentStatus = vds.getStatus();
    VDSStatus targetStatus = action.getSecond();
    if (targetStatus == VDSStatus.Maintenance && currentStatus == VDSStatus.Up) {
        logAction(vds, AuditLogType.PM_POLICY_UP_TO_MAINTENANCE);
        /* Up -> Maint */
        Guid[] vdsList = new Guid[] { vds.getId() };
        MaintenanceNumberOfVdssParameters parameters = new MaintenanceNumberOfVdssParameters(Arrays.asList(vdsList), true, true);
        Backend.getInstance().runInternalAction(ActionType.MaintenanceNumberOfVdss, parameters, ExecutionHandler.createInternalJobContext());
    } else if (targetStatus == VDSStatus.Down && currentStatus == VDSStatus.Maintenance) {
        logAction(vds, AuditLogType.PM_POLICY_MAINTENANCE_TO_DOWN);
        /* Maint -> Down */
        VdsPowerDownParameters parameters = new VdsPowerDownParameters(vds.getId());
        parameters.setKeepPolicyPMEnabled(true);
        Backend.getInstance().runInternalAction(ActionType.VdsPowerDown, parameters, ExecutionHandler.createInternalJobContext());
    } else if (targetStatus == VDSStatus.Up && currentStatus == VDSStatus.Maintenance) {
        logAction(vds, AuditLogType.PM_POLICY_TO_UP);
        /* Maint -> Up */
        VdsActionParameters parameters = new VdsActionParameters(vds.getId());
        Backend.getInstance().runInternalAction(ActionType.ActivateVds, parameters, ExecutionHandler.createInternalJobContext());
    } else if (targetStatus == VDSStatus.Up && currentStatus == VDSStatus.Down) {
        logAction(vds, AuditLogType.PM_POLICY_TO_UP);
        /* Down -> Up */
        FenceVdsActionParameters parameters = new FenceVdsActionParameters(vds.getId());
        Backend.getInstance().runInternalAction(ActionType.StartVds, parameters, ExecutionHandler.createInternalJobContext());
    } else {
        /* Should not ever happen... */
        log.error("Unknown host power management transition '{}' -> '{}'", currentStatus, targetStatus);
    }
}
Also used : VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) VDS(org.ovirt.engine.core.common.businessentities.VDS) FenceVdsActionParameters(org.ovirt.engine.core.common.action.FenceVdsActionParameters) MaintenanceNumberOfVdssParameters(org.ovirt.engine.core.common.action.MaintenanceNumberOfVdssParameters) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) FenceVdsActionParameters(org.ovirt.engine.core.common.action.FenceVdsActionParameters) Guid(org.ovirt.engine.core.compat.Guid) VdsPowerDownParameters(org.ovirt.engine.core.common.action.VdsPowerDownParameters)

Example 14 with VdsActionParameters

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

the class ClusterGuideModel method onSelectHost.

public void onSelectHost() {
    MoveHost model = (MoveHost) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    if (!model.validate()) {
        return;
    }
    model.setSelectedHosts(new ArrayList<MoveHostData>());
    for (EntityModel a : model.getItems()) {
        if (a.getIsSelected()) {
            model.getSelectedHosts().add((MoveHostData) a);
        }
    }
    Cluster cluster = model.getCluster().getSelectedItem();
    final List<ActionParametersBase> parameterList = new ArrayList<>();
    for (MoveHostData hostData : model.getSelectedHosts()) {
        VDS host = hostData.getEntity();
        // Try to change host's cluster as neccessary.
        if (host.getClusterId() != null && !host.getClusterId().equals(cluster.getId())) {
            parameterList.add(new ChangeVDSClusterParameters(cluster.getId(), host.getId()));
        }
    }
    model.startProgress();
    Frontend.getInstance().runMultipleAction(ActionType.ChangeVDSCluster, parameterList, result -> {
        List<MoveHostData> hosts = ((MoveHost) getWindow()).getSelectedHosts();
        List<ActionReturnValue> retVals = result.getReturnValue();
        final List<ActionParametersBase> activateVdsParameterList = new ArrayList<>();
        if (retVals != null && hosts.size() == retVals.size()) {
            int i = 0;
            for (MoveHostData selectedHostData : hosts) {
                VDS selectedHost = selectedHostData.getEntity();
                if (selectedHost.getStatus() == VDSStatus.PendingApproval && retVals.get(i) != null && retVals.get(i).getSucceeded()) {
                    Frontend.getInstance().runAction(ActionType.ApproveVds, new ApproveVdsParameters(selectedHost.getId()));
                } else if (selectedHostData.getActivateHost()) {
                    activateVdsParameterList.add(new VdsActionParameters(selectedHostData.getEntity().getId()));
                }
                i++;
            }
        }
        if (activateVdsParameterList.isEmpty()) {
            getWindow().stopProgress();
            cancel();
            postAction();
        } else {
            final String searchString = getVdsSearchString((MoveHost) getWindow());
            Timer timer = new Timer() {

                public void run() {
                    checkVdsClusterChangeSucceeded(searchString, parameterList, activateVdsParameterList);
                }
            };
            timer.schedule(2000);
        }
    }, this);
}
Also used : MoveHost(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHost) VDS(org.ovirt.engine.core.common.businessentities.VDS) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ApproveVdsParameters(org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) Timer(com.google.gwt.user.client.Timer) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters) MoveHostData(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHostData)

Example 15 with VdsActionParameters

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

the class ClusterHostListModel method updateMomPolicy.

private void updateMomPolicy() {
    ArrayList<ActionParametersBase> list = new ArrayList<>();
    for (VDS vds : getSelectedItems()) {
        list.add(new VdsActionParameters(vds.getId()));
    }
    Frontend.getInstance().runMultipleAction(ActionType.UpdateMomPolicy, list, result -> {
    }, null);
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

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