use of org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHost 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.ui.uicommonweb.models.hosts.MoveHost in project ovirt-engine by oVirt.
the class ClusterGuideModel method selectHost.
public void selectHost() {
final ArrayList<Cluster> clusters = new ArrayList<>();
clusters.add(getEntity());
final MoveHost model = new MoveHost();
model.setTitle(ConstantsManager.getInstance().getConstants().selectHostTitle());
model.setHelpTag(HelpTag.select_host);
// $NON-NLS-1$
model.setHashName("select_host");
// In case of local storage, only one host is allowed in the cluster so we should disable multi selection
AsyncDataProvider.getInstance().getDataCenterById(new AsyncQuery<>(dataCenter -> {
boolean isMultiHostDC = dataCenter.isLocal();
if (isMultiHostDC) {
model.setMultiSelection(false);
}
setWindow(model);
model.getCluster().setItems(clusters);
model.getCluster().setSelectedItem(Linq.firstOrNull(clusters));
model.getCluster().setIsAvailable(false);
// $NON-NLS-1$
UICommand tempVar = UICommand.createDefaultOkUiCommand("OnSelectHost", ClusterGuideModel.this);
model.getCommands().add(tempVar);
// $NON-NLS-1$
UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", ClusterGuideModel.this);
model.getCommands().add(tempVar2);
}), getEntity().getStoragePoolId());
}
use of org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHost 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);
}
use of org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHost in project ovirt-engine by oVirt.
the class DataCenterGuideModel method selectHost.
public void selectHost() {
final MoveHost model = new MoveHost();
model.setTitle(ConstantsManager.getInstance().getConstants().selectHostTitle());
model.setHelpTag(HelpTag.select_host);
// $NON-NLS-1$
model.setHashName("select_host");
// In case of local storage, do not show the cluster selection in host select menu as there can be only one cluster in that case
// also only one host is allowed in the cluster so we should disable multi selection
boolean isMultiHostDC = getEntity().isLocal();
if (isMultiHostDC) {
model.getCluster().setIsAvailable(false);
model.setMultiSelection(false);
}
setWindow(model);
AsyncDataProvider.getInstance().getClusterList(new AsyncQuery<>(clusters -> {
model.getCluster().setItems(clusters);
model.getCluster().setSelectedItem(Linq.firstOrNull(clusters));
// $NON-NLS-1$
UICommand tempVar = UICommand.createDefaultOkUiCommand("OnSelectHost", DataCenterGuideModel.this);
model.getCommands().add(tempVar);
// $NON-NLS-1$
UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", DataCenterGuideModel.this);
model.getCommands().add(tempVar2);
}), getEntity().getId());
}
Aggregations