use of org.ovirt.engine.core.common.action.hostdeploy.InstallVdsParameters in project ovirt-engine by oVirt.
the class AddVdsCommand method executeCommand.
@Override
protected void executeCommand() {
Guid oVirtId = getParameters().getVdsForUniqueId();
if (oVirtId != null) {
// if fails to remove deprecated entry, we might attempt to add new oVirt host with an existing unique-id.
if (!removeDeprecatedOvirtEntry(oVirtId)) {
log.error("Failed to remove duplicated oVirt entry with id '{}'. Abort adding oVirt Host type", oVirtId);
throw new EngineException(EngineError.HOST_ALREADY_EXISTS);
}
}
completeOpenstackNetworkProviderId();
TransactionSupport.executeInNewTransaction(() -> {
addVdsStaticToDb();
addVdsDynamicToDb();
addVdsStatisticsToDb();
addAffinityLabels();
getCompensationContext().stateChanged();
return null;
});
if (getParameters().isProvisioned()) {
HostProviderProxy proxy = providerProxyFactory.create(getHostProvider());
proxy.provisionHost(getParameters().getvds(), getParameters().getHostGroup(), getParameters().getComputeResource(), getParameters().getHostMac(), getParameters().getDiscoverName(), getParameters().getPassword(), getParameters().getDiscoverIp());
addCustomValue("HostGroupName", getParameters().getHostGroup().getName());
auditLogDirector.log(this, AuditLogType.VDS_PROVISION);
}
// set vds spm id
if (getCluster().getStoragePoolId() != null) {
VdsActionParameters tempVar = new VdsActionParameters(getVdsIdRef());
tempVar.setSessionId(getParameters().getSessionId());
tempVar.setCompensationEnabled(true);
ActionReturnValue addVdsSpmIdReturn = runInternalAction(ActionType.AddVdsSpmId, tempVar, cloneContext().withoutLock().withoutExecutionContext());
if (!addVdsSpmIdReturn.getSucceeded()) {
setSucceeded(false);
getReturnValue().setFault(addVdsSpmIdReturn.getFault());
return;
}
}
TransactionSupport.executeInNewTransaction(() -> {
initializeVds(true);
alertIfPowerManagementNotConfigured(getParameters().getVdsStaticData());
testVdsPowerManagementStatus(getParameters().getVdsStaticData());
setSucceeded(true);
setActionReturnValue(getVdsIdRef());
// If the installation failed, we don't want to compensate for the failure since it will remove the
// host, but instead the host should be left in an "install failed" status.
getCompensationContext().cleanupCompensationDataAfterSuccessfulCommand();
return null;
});
// clients). they are installed as part of the approve process or automatically after provision
if (Config.<Boolean>getValue(ConfigValues.InstallVds) && !getParameters().isPending() && !getParameters().isProvisioned()) {
final InstallVdsParameters installVdsParameters = new InstallVdsParameters(getVdsId(), getParameters().getPassword());
installVdsParameters.setAuthMethod(getParameters().getAuthMethod());
installVdsParameters.setOverrideFirewall(getParameters().getOverrideFirewall());
installVdsParameters.setActivateHost(getParameters().getActivateHost());
installVdsParameters.setNetworkProviderId(getParameters().getVdsStaticData().getOpenstackNetworkProviderId());
installVdsParameters.setNetworkMappings(getParameters().getNetworkMappings());
installVdsParameters.setEnableSerialConsole(getParameters().getEnableSerialConsole());
if (getParameters().getHostedEngineDeployConfiguration() != null) {
Map<String, String> vdsDeployParams = hostedEngineHelper.createVdsDeployParams(getVdsId(), getParameters().getHostedEngineDeployConfiguration().getDeployAction());
installVdsParameters.setHostedEngineConfiguration(vdsDeployParams);
}
Map<String, String> values = new HashMap<>();
values.put(VdcObjectType.VDS.name().toLowerCase(), getParameters().getvds().getName());
Step installStep = executionHandler.addSubStep(getExecutionContext(), getExecutionContext().getJob().getStep(StepEnum.EXECUTING), StepEnum.INSTALLING_HOST, ExecutionMessageDirector.resolveStepMessage(StepEnum.INSTALLING_HOST, values));
final ExecutionContext installCtx = new ExecutionContext();
installCtx.setJob(getExecutionContext().getJob());
installCtx.setStep(installStep);
installCtx.setMonitored(true);
installCtx.setShouldEndJob(true);
ThreadPoolUtil.execute(() -> runInternalAction(ActionType.InstallVdsInternal, installVdsParameters, cloneContextAndDetachFromParent().withExecutionContext(installCtx)));
ExecutionHandler.setAsyncJob(getExecutionContext(), true);
}
}
use of org.ovirt.engine.core.common.action.hostdeploy.InstallVdsParameters in project ovirt-engine by oVirt.
the class UpdateVdsCommand method executeCommand.
@Override
protected void executeCommand() {
getParameters().getVdsStaticData().setReinstallRequired(shouldVdsBeReinstalled());
updateVdsData();
if (needToUpdateVdsBroker()) {
initializeVds();
}
if (getParameters().isInstallHost()) {
InstallVdsParameters tempVar = new InstallVdsParameters(getVdsId(), getParameters().getPassword());
tempVar.setIsReinstallOrUpgrade(getParameters().isReinstallOrUpgrade());
tempVar.setoVirtIsoFile(getParameters().getoVirtIsoFile());
if (vdsDynamicDao.get(getVdsId()).getStatus() == VDSStatus.InstallingOS) {
// TODO: remove hack when reinstall api will provider override-firewall parameter.
// https://bugzilla.redhat.com/show_bug.cgi?id=1177126 - for now we override firewall
// configurations on each deploy for provisioned host to avoid wrong deployment.
tempVar.setOverrideFirewall(true);
} else {
tempVar.setOverrideFirewall(getParameters().getOverrideFirewall());
}
tempVar.setOverrideFirewall(getParameters().getOverrideFirewall());
tempVar.setActivateHost(getParameters().getActivateHost());
tempVar.setNetworkProviderId(getParameters().getVdsStaticData().getOpenstackNetworkProviderId());
tempVar.setNetworkMappings(getParameters().getNetworkMappings());
tempVar.setAuthMethod(getParameters().getAuthMethod());
if (getParameters().getHostedEngineDeployConfiguration() != null) {
tempVar.setHostedEngineConfiguration(hostedEngineHelper.createVdsDeployParams(getVdsId(), getParameters().getHostedEngineDeployConfiguration().getDeployAction()));
}
List<ActionReturnValue> resultList = runInternalMultipleActions(actionType, new ArrayList<>(Arrays.asList(tempVar)), ExecutionHandler.createInternalJobContext().getExecutionContext());
// status, therefore needed to fail the command to revert the status.
if (!resultList.isEmpty()) {
ActionReturnValue actionReturnValue = resultList.get(0);
if (actionReturnValue != null && !actionReturnValue.isValid()) {
List<String> validationMessages = actionReturnValue.getValidationMessages();
if (!validationMessages.isEmpty()) {
// add can do action messages to return value so error messages
// are returned back to the client
getReturnValue().getValidationMessages().addAll(validationMessages);
log.error("Installation/upgrade of Host '{}', '{}' failed: {}", getVdsId(), getVdsName(), StringUtils.join(Backend.getInstance().getErrorsTranslator().translateErrorText(validationMessages), ","));
}
// set can do action to false so can do action messages are
// returned back to client
getReturnValue().setValid(false);
setSucceeded(false);
// add old vds dynamic data to compensation context. This
// way the status will revert back to what it was before
// starting installation process
getCompensationContext().snapshotEntityStatus(oldHost.getDynamicData());
getCompensationContext().stateChanged();
return;
}
}
}
// set clusters network to be operational (if needed)
if (oldHost.getStatus() == VDSStatus.Up) {
List<Network> networks = networkDao.getAllForCluster(oldHost.getClusterId());
networkClusterHelper.setStatus(oldHost.getClusterId(), networks);
}
alertIfPowerManagementNotConfigured(getParameters().getVdsStaticData());
testVdsPowerManagementStatus(getParameters().getVdsStaticData());
checkKdumpIntegrationStatus();
updateAffinityLabels();
setSucceeded(true);
}
use of org.ovirt.engine.core.common.action.hostdeploy.InstallVdsParameters 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);
}
}
use of org.ovirt.engine.core.common.action.hostdeploy.InstallVdsParameters in project ovirt-engine by oVirt.
the class UpgradeOvirtNodeInternalCommandTest method createParameters.
private static InstallVdsParameters createParameters() {
InstallVdsParameters param = new InstallVdsParameters(Guid.newGuid());
param.setIsReinstallOrUpgrade(true);
return param;
}
use of org.ovirt.engine.core.common.action.hostdeploy.InstallVdsParameters in project ovirt-engine by oVirt.
the class InstallVdsInternalCommandTest method createParameters.
private static InstallVdsParameters createParameters() {
InstallVdsParameters param = new InstallVdsParameters(Guid.newGuid());
param.setIsReinstallOrUpgrade(true);
return param;
}
Aggregations