use of org.ovirt.engine.core.common.action.ChangeVDSClusterParameters in project ovirt-engine by oVirt.
the class GuideModel method checkVdsClusterChangeSucceeded.
protected void checkVdsClusterChangeSucceeded(final String searchStr, final List<ActionParametersBase> changeVdsParameterList, final List<ActionParametersBase> activateVdsParameterList) {
final Map<Guid, Guid> hostClusterIdMap = new HashMap<>();
for (ActionParametersBase param : changeVdsParameterList) {
hostClusterIdMap.put(((ChangeVDSClusterParameters) param).getVdsId(), ((ChangeVDSClusterParameters) param).getClusterId());
}
Frontend.getInstance().runQuery(QueryType.Search, new SearchParameters(searchStr, SearchType.VDS), new AsyncQuery<QueryReturnValue>(returnValue -> {
List<VDS> hosts = returnValue.getReturnValue();
boolean succeeded = true;
for (VDS host : hosts) {
if (!host.getClusterId().equals(hostClusterIdMap.get(host.getId()))) {
succeeded = false;
}
}
if (!succeeded) {
getWindow().stopProgress();
cancel();
errorPopupManager.show(ConstantsManager.getInstance().getConstants().hostChangeClusterTimeOut());
} else {
activateHostsAfterClusterChange(searchStr, activateVdsParameterList);
}
}));
}
use of org.ovirt.engine.core.common.action.ChangeVDSClusterParameters in project ovirt-engine by oVirt.
the class AddDataCenterRM method rollback3.
public void rollback3() {
Enlistment enlistment = context.enlistment;
EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext();
HostListModel<?> model = enlistmentContext.getModel();
VDS host = context.hostFoundById;
boolean abort = false;
if (model.getSelectedItem() != null) {
// Perform rollback only when the host is in maintenance.
if (host.getStatus() != VDSStatus.Maintenance) {
abort = true;
}
} else {
abort = true;
}
if (abort) {
context.enlistment = null;
enlistment.done();
return;
}
StoragePool dataCenter = context.dataCenterFoundById;
// Perform rollback only when the Data Center is un uninitialized.
if (dataCenter.getStatus() != StoragePoolStatus.Uninitialized) {
context.enlistment = null;
enlistment.done();
return;
}
if (enlistmentContext.getOldClusterId() != null) {
// Switch host back to previous cluster.
Frontend.getInstance().runAction(ActionType.ChangeVDSCluster, new ChangeVDSClusterParameters(enlistmentContext.getOldClusterId(), host.getId()), result -> {
ActionReturnValue returnValue = result.getReturnValue();
context.changeVDSClusterReturnValue = returnValue;
rollback4();
});
} else {
context.enlistment = null;
enlistment.done();
}
}
use of org.ovirt.engine.core.common.action.ChangeVDSClusterParameters in project ovirt-engine by oVirt.
the class ChangeHostClusterRM method prepare1.
public void prepare1() {
PreparingEnlistment enlistment = (PreparingEnlistment) context.enlistment;
EnlistmentContext enlistmentContext = (EnlistmentContext) context.enlistment.getContext();
HostListModel<?> model = enlistmentContext.getModel();
VDS host = model.getSelectedItem();
if (!enlistmentContext.getClusterId().equals(host.getClusterId())) {
enlistmentContext.setOldClusterId(host.getClusterId());
ChangeVDSClusterParameters parameters = new ChangeVDSClusterParameters(enlistmentContext.getClusterId(), host.getId());
parameters.setCorrelationId(getCorrelationId());
Frontend.getInstance().runAction(ActionType.ChangeVDSCluster, parameters, result -> {
ActionReturnValue returnValue = result.getReturnValue();
context.changeVDSClusterReturnValue = returnValue;
prepare2();
});
} else {
context.enlistment = null;
enlistment.prepared();
}
}
use of org.ovirt.engine.core.common.action.ChangeVDSClusterParameters in project ovirt-engine by oVirt.
the class DataCenterGuideModel method onSelectHost.
public void onSelectHost() {
MoveHost model = (MoveHost) getWindow();
if (model.getProgress() != null) {
return;
}
if (!model.validate()) {
return;
}
model.setSelectedHosts(new ArrayList<MoveHostData>());
for (MoveHostData a : model.getItems()) {
if (a.getIsSelected()) {
model.getSelectedHosts().add(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, new IFrontendMultipleActionAsyncCallback() {
@Override
public void executed(FrontendMultipleActionAsyncResult result) {
final DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
List<MoveHostData> hosts = ((MoveHost) dataCenterGuideModel.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()), null, this);
} else if (selectedHostData.getActivateHost()) {
activateVdsParameterList.add(new VdsActionParameters(selectedHostData.getEntity().getId()));
}
i++;
}
}
if (activateVdsParameterList.isEmpty()) {
dataCenterGuideModel.getWindow().stopProgress();
dataCenterGuideModel.cancel();
dataCenterGuideModel.postAction();
} else {
final String searchString = getVdsSearchString((MoveHost) dataCenterGuideModel.getWindow());
Timer timer = new Timer() {
public void run() {
checkVdsClusterChangeSucceeded(searchString, parameterList, activateVdsParameterList);
}
};
timer.schedule(2000);
}
}
}, this);
}
use of org.ovirt.engine.core.common.action.ChangeVDSClusterParameters 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);
}
}
}
Aggregations