Search in sources :

Example 1 with MoveHostData

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();
}
Also used : MoveHostData(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHostData)

Example 2 with MoveHostData

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);
}
Also used : IFrontendMultipleActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback) MoveHost(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHost) VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ApproveVdsParameters(org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) FrontendMultipleActionAsyncResult(org.ovirt.engine.ui.uicompat.FrontendMultipleActionAsyncResult) Timer(com.google.gwt.user.client.Timer) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters) MoveHostData(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHostData) List(java.util.List) ArrayList(java.util.ArrayList)

Example 3 with MoveHostData

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);
}
Also used : MoveHost(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHost) VDS(org.ovirt.engine.core.common.businessentities.VDS) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ApproveVdsParameters(org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) Timer(com.google.gwt.user.client.Timer) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters) MoveHostData(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHostData)

Aggregations

MoveHostData (org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHostData)3 Timer (com.google.gwt.user.client.Timer)2 ArrayList (java.util.ArrayList)2 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 ChangeVDSClusterParameters (org.ovirt.engine.core.common.action.ChangeVDSClusterParameters)2 VdsActionParameters (org.ovirt.engine.core.common.action.VdsActionParameters)2 AddVdsActionParameters (org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters)2 ApproveVdsParameters (org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2 VDS (org.ovirt.engine.core.common.businessentities.VDS)2 MoveHost (org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHost)2 List (java.util.List)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)1 FrontendMultipleActionAsyncResult (org.ovirt.engine.ui.uicompat.FrontendMultipleActionAsyncResult)1 IFrontendMultipleActionAsyncCallback (org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback)1