Search in sources :

Example 1 with HostConnectivityChecker

use of org.ovirt.engine.core.bll.host.HostConnectivityChecker 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)

Aggregations

HostConnectivityChecker (org.ovirt.engine.core.bll.host.HostConnectivityChecker)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 VdsActionParameters (org.ovirt.engine.core.common.action.VdsActionParameters)1 InstallVdsParameters (org.ovirt.engine.core.common.action.hostdeploy.InstallVdsParameters)1 VDSType (org.ovirt.engine.core.common.businessentities.VDSType)1