use of org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHostData in project ovirt-engine by oVirt.
the class GuideModel method getVdsSearchString.
protected String getVdsSearchString(final MoveHost moveHost) {
// $NON-NLS-1$
StringBuilder buf = new StringBuilder("Host: ");
for (MoveHostData hostData : moveHost.getSelectedHosts()) {
if (buf.length() > 6) {
// $NON-NLS-1$
buf.append(" or ");
}
// $NON-NLS-1$
buf.append("name = ");
buf.append(hostData.getEntity().getName());
}
return buf.toString();
}
use of org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHostData 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.MoveHostData 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);
}
Aggregations