use of org.ovirt.engine.core.common.action.hostdeploy.UpdateVdsActionParameters in project ovirt-engine by oVirt.
the class BackendHostResource method install.
@Override
public Response install(Action action) {
// REVISIT fencing options
VDS vds = getEntity();
UpdateVdsActionParameters params = new UpdateVdsActionParameters(vds.getStaticData(), action.getRootPassword(), true);
// Explicitly set null, to be clear we don't want to update fence agents.
params.setFenceAgents(null);
params.setHostedEngineDeployConfiguration(HostResourceParametersUtil.getHostedEngineDeployConfiguration(this));
params = (UpdateVdsActionParameters) getMapper(Action.class, VdsOperationActionParameters.class).map(action, params);
if (vds.isOvirtVintageNode()) {
params.setReinstallOrUpgrade(true);
if (action.isSetImage()) {
params.setoVirtIsoFile(action.getImage());
return doAction(ActionType.UpgradeOvirtNode, params, action);
}
}
return doAction(ActionType.UpdateVds, params, action);
}
use of org.ovirt.engine.core.common.action.hostdeploy.UpdateVdsActionParameters in project ovirt-engine by oVirt.
the class UpdateVdsCommandTest method createParameters.
private UpdateVdsActionParameters createParameters(VDS host) {
UpdateVdsActionParameters parameters = new UpdateVdsActionParameters();
parameters.setvds(host);
parameters.setVdsId(host.getId());
parameters.setAuthMethod(AuthenticationMethod.PublicKey);
parameters.setPassword(PASSWORD);
parameters.setHostedEngineDeployConfiguration(HOSTED_ENGINE_DEPLOY_CONFIGURATION);
return parameters;
}
use of org.ovirt.engine.core.common.action.hostdeploy.UpdateVdsActionParameters in project ovirt-engine by oVirt.
the class RegisterVdsQuery method handleOldVdssWithSameHostName.
private boolean handleOldVdssWithSameHostName(VDS vdsByUniqueId) {
// handle old VDSs with same host_name (IP)
log.debug("RegisterVdsQuery::handleOldVdssWithSameHostName - Entering");
boolean returnValue = true;
List<VDS> vdssByHostName = vdsDao.getAllForHostname(getParameters().getVdsHostName());
int lastIteratedIndex = 1;
if (vdssByHostName.size() > 0) {
log.debug("RegisterVdsQuery::handleOldVdssWithSameHostName - found '{}' VDS(s) with the same host name '{}'. Will try to change their hostname to a different value", vdssByHostName.size(), getParameters().getVdsHostName());
for (VDS vdsByHostName : vdssByHostName) {
// looping foreach VDS found with similar hostnames and change to each one to available hostname
if (vdsByUniqueId == null || !vdsByHostName.getId().equals(vdsByUniqueId.getId())) {
boolean unique = false;
String tryHostName = "";
for (int i = lastIteratedIndex; i <= 100; i++, lastIteratedIndex = i) {
tryHostName = String.format("hostname-was-%1$s-%2$s", getParameters().getVdsHostName(), i);
if (vdsDao.getAllForHostname(tryHostName).size() == 0) {
unique = true;
break;
}
}
if (unique) {
String oldHostName = vdsByHostName.getHostName();
vdsByHostName.setHostName(tryHostName);
UpdateVdsActionParameters parameters = new UpdateVdsActionParameters(vdsByHostName.getStaticData(), "", false);
parameters.setShouldBeLogged(false);
parameters.setTransactionScopeOption(TransactionScopeOption.RequiresNew);
if (vdsByHostName.isFenceAgentsExist()) {
parameters.setFenceAgents(vdsByHostName.getFenceAgents());
}
// If host exists in InstallingOs status, remove it from DB and move on
final VDS foundVds = vdsDao.getByName(parameters.getVdsStaticData().getName());
if ((foundVds != null) && (foundVds.getDynamicData().getStatus() == VDSStatus.InstallingOS)) {
TransactionSupport.executeInScope(TransactionScopeOption.Required, () -> {
vdsStatisticsDao.remove(foundVds.getId());
vdsDynamicDao.remove(foundVds.getId());
vdsStaticDao.remove(foundVds.getId());
return null;
});
}
ActionReturnValue ret = Backend.getInstance().runInternalAction(ActionType.UpdateVds, parameters);
if (!ret.getSucceeded()) {
error = AuditLogType.VDS_REGISTER_ERROR_UPDATING_HOST;
logable.addCustomValue("VdsName2", vdsByHostName.getStaticData().getName());
log.error("RegisterVdsQuery::handleOldVdssWithSameHostName - could not update VDS '{}'", vdsByHostName.getStaticData().getName());
captureCommandErrorsToLogger(ret, "RegisterVdsQuery::handleOldVdssWithSameHostName");
return false;
} else {
log.info("RegisterVdsQuery::handleOldVdssWithSameHostName - Another VDS was using this IP '{}'. Changed to '{}'", oldHostName, tryHostName);
}
} else {
log.error("Engine::handleOldVdssWithSameHostName - Could not change the IP for an existing VDS. All available hostnames are taken (ID = '{}', name = '{}', management IP = '{}' , host name = '{}')", vdsByHostName.getId(), vdsByHostName.getName(), vdsByHostName.getFenceAgents().isEmpty() ? "" : vdsByHostName.getFenceAgents().get(0).getIp(), vdsByHostName.getHostName());
error = AuditLogType.VDS_REGISTER_ERROR_UPDATING_HOST_ALL_TAKEN;
returnValue = false;
}
}
log.info("RegisterVdsQuery::handleOldVdssWithSameHostName - No Change required for VDS '{}'. Since it has the same unique Id", vdsByHostName.getId());
}
}
log.debug("RegisterVdsQuery::handleOldVdssWithSameHostName - Leaving with value '{}'", returnValue);
return returnValue;
}
use of org.ovirt.engine.core.common.action.hostdeploy.UpdateVdsActionParameters in project ovirt-engine by oVirt.
the class HostListModel method onSaveInternal.
public void onSaveInternal(boolean approveInitiated) {
HostModel model = (HostModel) getWindow();
if (model.getProgress() != null) {
return;
}
VDS host = model.getIsNew() ? new VDS() : (VDS) Cloner.clone(getSelectedItem());
// Save changes.
host.setVdsName(model.getName().getEntity());
host.setComment(model.getComment().getEntity());
host.setHostName(model.getHost().getEntity().trim());
host.setPort(Integer.parseInt(model.getPort().getEntity().toString()));
host.setSshPort(Integer.parseInt(model.getAuthSshPort().getEntity().toString()));
boolean sshUsernameSet = model.getUserName().getEntity() != null;
host.setSshUsername(sshUsernameSet ? model.getUserName().getEntity() : null);
boolean sshFpSet = model.getFetchSshFingerprint().getEntity() != null;
host.setSshKeyFingerprint(!sshFpSet ? null : model.getFetchSshFingerprint().getEntity());
host.setVdsSpmPriority(model.getSpmPriorityValue());
boolean consoleAddressSet = model.getConsoleAddressEnabled().getEntity();
host.setConsoleAddress(!consoleAddressSet ? null : model.getConsoleAddress().getEntity());
Guid oldClusterId = host.getClusterId();
Guid newClusterId = model.getCluster().getSelectedItem().getId();
host.setClusterId(newClusterId);
host.setVdsSpmPriority(model.getSpmPriorityValue());
host.setFenceProxySources(FenceProxySourceTypeHelper.parseFromString(model.getPmProxyPreferences()));
// Save other PM parameters.
host.setPmEnabled(model.getIsPm().getEntity());
host.setDisablePowerManagementPolicy(model.getDisableAutomaticPowerManagement().getEntity());
host.setPmKdumpDetection(model.getPmKdumpDetection().getEntity());
host.setCurrentKernelCmdline(model.getKernelCmdline().getEntity());
host.setKernelCmdlineBlacklistNouveau(model.getKernelCmdlineBlacklistNouveau().getEntity());
host.setKernelCmdlineParsable(model.isKernelCmdlineParsable());
host.setKernelCmdlineIommu(model.getKernelCmdlineIommu().getEntity());
host.setKernelCmdlineKvmNested(model.getKernelCmdlineKvmNested().getEntity());
host.setKernelCmdlineUnsafeInterrupts(model.getKernelCmdlineUnsafeInterrupts().getEntity());
host.setKernelCmdlinePciRealloc(model.getKernelCmdlinePciRealloc().getEntity());
cancelConfirm();
model.startProgress();
if (model.getIsNew()) {
AddVdsActionParameters parameters = new AddVdsActionParameters();
parameters.setVdsId(host.getId());
parameters.setvds(host);
parameters.setFenceAgents(model.getFenceAgentListModel().getFenceAgents());
if (model.getUserPassword().getEntity() != null) {
parameters.setPassword(model.getUserPassword().getEntity());
}
parameters.setOverrideFirewall(model.getOverrideIpTables().getEntity());
parameters.setAuthMethod(model.getAuthenticationMethod());
Provider<?> networkProvider = model.getNetworkProviders().getSelectedItem();
if (networkProvider != null) {
parameters.getVdsStaticData().setOpenstackNetworkProviderId(networkProvider.getId());
parameters.setNetworkMappings(model.getInterfaceMappings().getEntity());
}
if (model.getProviders().getSelectedItem() != null) {
parameters.getVdsStaticData().setHostProviderId(model.getProviders().getSelectedItem().getId());
}
if (Boolean.TRUE.equals(model.getIsDiscoveredHosts().getEntity())) {
Provider<?> provider = model.getProviders().getSelectedItem();
ExternalHostGroup hostGroup = (ExternalHostGroup) model.getExternalHostGroups().getSelectedItem();
ExternalComputeResource computeResource = (ExternalComputeResource) model.getExternalComputeResource().getSelectedItem();
ExternalDiscoveredHost discoveredHost = (ExternalDiscoveredHost) model.getExternalDiscoveredHosts().getSelectedItem();
parameters.initVdsActionParametersForProvision(provider.getId(), hostGroup, computeResource, discoveredHost.getMac(), discoveredHost.getName(), discoveredHost.getIp());
}
parameters.setHostedEngineDeployConfiguration(new HostedEngineDeployConfiguration(model.getHostedEngineHostModel().getSelectedItem()));
parameters.setAffinityLabels(model.getLabelList().getSelectedItems());
Frontend.getInstance().runAction(ActionType.AddVds, parameters, result -> {
Object[] array = (Object[]) result.getState();
HostListModel<Void> localModel = (HostListModel<Void>) array[0];
boolean localApproveInitiated = (Boolean) array[1];
localModel.postOnSaveInternal(result.getReturnValue(), localApproveInitiated);
}, new Object[] { this, approveInitiated });
} else {
// Update VDS -> consists of changing VDS cluster first and then updating rest of VDS properties:
UpdateVdsActionParameters parameters = new UpdateVdsActionParameters();
parameters.setvds(host);
parameters.setVdsId(host.getId());
// $NON-NLS-1$
parameters.setPassword("");
parameters.setInstallHost(false);
parameters.setAuthMethod(model.getAuthenticationMethod());
parameters.setFenceAgents(model.getFenceAgentListModel().getFenceAgents());
parameters.setAffinityLabels(model.getLabelList().getSelectedItems());
if (model.getExternalHostProviderEnabled().getEntity() && model.getProviders().getSelectedItem() != null) {
host.setHostProviderId(model.getProviders().getSelectedItem().getId());
}
if (!oldClusterId.equals(newClusterId)) {
Frontend.getInstance().runAction(ActionType.ChangeVDSCluster, new ChangeVDSClusterParameters(newClusterId, host.getId()), result -> {
Object[] array = (Object[]) result.getState();
HostListModel<Void> localModel = (HostListModel<Void>) array[0];
UpdateVdsActionParameters localParameters = (UpdateVdsActionParameters) array[1];
boolean localApproveInitiated = (Boolean) array[2];
ActionReturnValue localReturnValue = result.getReturnValue();
if (localReturnValue != null && localReturnValue.getSucceeded()) {
localModel.postOnSaveInternalChangeCluster(localParameters, localApproveInitiated);
} else {
localModel.getWindow().stopProgress();
}
}, new Object[] { this, parameters, approveInitiated });
} else {
postOnSaveInternalChangeCluster(parameters, approveInitiated);
}
}
}
use of org.ovirt.engine.core.common.action.hostdeploy.UpdateVdsActionParameters in project ovirt-engine by oVirt.
the class HostListModel method onInstall.
public void onInstall() {
final VDS host = getSelectedItem();
InstallModel model = (InstallModel) getWindow();
if (!model.validate(host.isOvirtVintageNode())) {
model.setValidationFailed(new EntityModel<>(true));
return;
}
final UpdateVdsActionParameters param = new UpdateVdsActionParameters();
param.setvds(host);
param.setVdsId(host.getId());
param.setPassword(model.getUserPassword().getEntity());
param.setReinstallOrUpgrade(true);
param.setInstallHost(true);
param.setoVirtIsoFile(null);
param.setOverrideFirewall(model.getOverrideIpTables().getEntity());
param.setActivateHost(model.getActivateHostAfterInstall().getEntity());
param.setAuthMethod(model.getAuthenticationMethod());
// Explicitly set null, to be clear we don't want to update fence agents.
param.setFenceAgents(null);
param.setHostedEngineDeployConfiguration(new HostedEngineDeployConfiguration(model.getHostedEngineHostModel().getSelectedItem()));
Provider<?> networkProvider = (Provider<?>) model.getNetworkProviders().getSelectedItem();
if (networkProvider == null) {
param.getVdsStaticData().setOpenstackNetworkProviderId(null);
} else {
param.getVdsStaticData().setOpenstackNetworkProviderId(networkProvider.getId());
param.setNetworkMappings((String) model.getInterfaceMappings().getEntity());
}
AsyncDataProvider.getInstance().getClusterById(new AsyncQuery<>(returnValue -> Frontend.getInstance().runAction(ActionType.InstallVds, param, result -> {
ActionReturnValue returnValue1 = result.getReturnValue();
if (returnValue1 != null && returnValue1.getSucceeded()) {
cancel();
}
})), host.getClusterId());
}
Aggregations