Search in sources :

Example 6 with ChangeVDSClusterParameters

use of org.ovirt.engine.core.common.action.ChangeVDSClusterParameters 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)

Example 7 with ChangeVDSClusterParameters

use of org.ovirt.engine.core.common.action.ChangeVDSClusterParameters in project ovirt-engine by oVirt.

the class BackendHostResource method update.

@Override
public Host update(Host incoming) {
    QueryIdResolver<Guid> hostResolver = new QueryIdResolver<>(QueryType.GetVdsByVdsId, IdQueryParameters.class);
    VDS entity = getEntity(hostResolver, true);
    BackendExternalProviderHelper.completeExternalNetworkProviderConfigurations(this, incoming.getExternalNetworkProviderConfigurations());
    // if fence agents list is null set it to null in entity
    if (incoming.getAgents() == null) {
        entity.setFenceAgents(null);
    }
    if (incoming.isSetCluster() && (incoming.getCluster().isSetId() || incoming.getCluster().isSetName())) {
        Guid clusterId = lookupClusterId(incoming);
        if (!clusterId.equals(entity.getClusterId())) {
            performAction(ActionType.ChangeVDSCluster, new ChangeVDSClusterParameters(clusterId, guid));
            // After changing the cluster with the specialized command we need to reload the entity, so that it
            // contains the new cluster id. If we don't do this the next command will think that we are trying
            // to change the cluster, and it will explicitly refuse to perform the update.
            entity = getEntity(hostResolver, true);
        }
    }
    Host host = performUpdate(incoming, entity, map(entity), hostResolver, ActionType.UpdateVds, new UpdateParametersProvider());
    return host;
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters) Host(org.ovirt.engine.api.model.Host) Guid(org.ovirt.engine.core.compat.Guid)

Aggregations

ChangeVDSClusterParameters (org.ovirt.engine.core.common.action.ChangeVDSClusterParameters)7 VDS (org.ovirt.engine.core.common.businessentities.VDS)7 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)4 Timer (com.google.gwt.user.client.Timer)3 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)3 AddVdsActionParameters (org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters)3 Guid (org.ovirt.engine.core.compat.Guid)3 MoveHost (org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHost)3 MoveHostData (org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHostData)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 VdsActionParameters (org.ovirt.engine.core.common.action.VdsActionParameters)2 ApproveVdsParameters (org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2 PreparingEnlistment (org.ovirt.engine.ui.uicompat.PreparingEnlistment)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Host (org.ovirt.engine.api.model.Host)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 UpdateVdsActionParameters (org.ovirt.engine.core.common.action.hostdeploy.UpdateVdsActionParameters)1