Search in sources :

Example 21 with ActionParametersBase

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

the class ClusterListModel method onResetClusterEmulatedMachine.

public void onResetClusterEmulatedMachine() {
    final ConfirmationModel model = (ConfirmationModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    ArrayList<ActionParametersBase> prms = new ArrayList<>();
    for (Cluster cluster : getSelectedItems()) {
        ManagementNetworkOnClusterOperationParameters currentParam = new ManagementNetworkOnClusterOperationParameters(cluster);
        currentParam.setForceResetEmulatedMachine(true);
        prms.add(currentParam);
    }
    model.startProgress();
    Frontend.getInstance().runMultipleAction(ActionType.UpdateCluster, prms, result -> {
        model.stopProgress();
        cancel();
    });
}
Also used : ManagementNetworkOnClusterOperationParameters(org.ovirt.engine.core.common.action.ManagementNetworkOnClusterOperationParameters) ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 22 with ActionParametersBase

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

the class ClusterListModel method addHosts.

private void addHosts(final MultipleHostsModel hostsModel) {
    hostsModel.startProgress();
    ArrayList<ActionParametersBase> parametersList = new ArrayList<>();
    for (Object object : hostsModel.getHosts().getItems()) {
        HostDetailModel hostDetailModel = (HostDetailModel) ((EntityModel) object).getEntity();
        VDS host = new VDS();
        host.setVdsName(hostDetailModel.getName());
        host.setHostName(hostDetailModel.getAddress());
        host.setSshKeyFingerprint(hostDetailModel.getFingerprint());
        host.setPort(54321);
        // TODO: get from UI, till then using defaults.
        host.setSshPort(22);
        // $NON-NLS-1$
        host.setSshUsername("root");
        host.setClusterId(hostsModel.getClusterModel().getClusterId());
        host.setPmEnabled(false);
        AddVdsActionParameters parameters = new AddVdsActionParameters();
        parameters.setVdsId(host.getId());
        parameters.setvds(host);
        parameters.setPassword(hostDetailModel.getPassword());
        parameters.setOverrideFirewall(hostsModel.isConfigureFirewall());
        parametersList.add(parameters);
    }
    // Todo: calling the runMultipleAction() with isRunOnlyIfAllValidationPass=false
    // becuase this flag is now supported.
    // should check what is the required behaviour and return to true if required.
    Frontend.getInstance().runMultipleAction(ActionType.AddVds, parametersList, false, result -> {
        hostsModel.stopProgress();
        boolean isAllValidatePassed = true;
        for (ActionReturnValue returnValueBase : result.getReturnValue()) {
            isAllValidatePassed = returnValueBase.isValid();
            if (!isAllValidatePassed) {
                break;
            }
        }
        if (isAllValidatePassed) {
            cancel();
        }
    }, null);
}
Also used : HostDetailModel(org.ovirt.engine.ui.uicommonweb.models.hosts.HostDetailModel) VDS(org.ovirt.engine.core.common.businessentities.VDS) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ArrayList(java.util.ArrayList) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 23 with ActionParametersBase

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

the class ClusterGeneralModel method onSaveHosts.

public void onSaveHosts() {
    final MultipleHostsModel hostsModel = (MultipleHostsModel) getWindow();
    if (hostsModel == null) {
        return;
    }
    if (!hostsModel.validate()) {
        return;
    }
    hostsModel.startProgress();
    ArrayList<ActionParametersBase> parametersList = new ArrayList<>();
    for (Object object : hostsModel.getHosts().getItems()) {
        HostDetailModel hostDetailModel = (HostDetailModel) ((EntityModel) object).getEntity();
        VDS host = new VDS();
        host.setVdsName(hostDetailModel.getName());
        host.setHostName(hostDetailModel.getAddress());
        host.setSshKeyFingerprint(hostDetailModel.getFingerprint());
        host.setPort(54321);
        // TODO: get from UI, till than using defaults.
        host.setSshPort(22);
        // $NON-NLS-1$
        host.setSshUsername("root");
        host.setClusterId(getEntity().getId());
        host.setPmEnabled(false);
        AddVdsActionParameters parameters = new AddVdsActionParameters();
        parameters.setVdsId(host.getId());
        parameters.setvds(host);
        parameters.setPassword(hostDetailModel.getPassword());
        parameters.setOverrideFirewall(hostsModel.isConfigureFirewall());
        parametersList.add(parameters);
    }
    // Todo: calling the runMultipleAction() with isRunOnlyIfAllValidationPass=false
    // becuase this flag is now supported.
    // should check what is the required behaviour and return to true if required.
    Frontend.getInstance().runMultipleAction(ActionType.AddVds, parametersList, false, result -> {
        hostsModel.stopProgress();
        boolean isAllValidatePassed = true;
        for (ActionReturnValue returnValueBase : result.getReturnValue()) {
            isAllValidatePassed = isAllValidatePassed && returnValueBase.isValid();
            if (!isAllValidatePassed) {
                break;
            }
        }
        if (isAllValidatePassed) {
            updateAlerts();
            cancel();
        }
    }, null);
}
Also used : MultipleHostsModel(org.ovirt.engine.ui.uicommonweb.models.hosts.MultipleHostsModel) HostDetailModel(org.ovirt.engine.ui.uicommonweb.models.hosts.HostDetailModel) VDS(org.ovirt.engine.core.common.businessentities.VDS) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ArrayList(java.util.ArrayList) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 24 with ActionParametersBase

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

the class ClusterGeneralModel method onDetachNewGlusterHosts.

public void onDetachNewGlusterHosts() {
    if (getWindow() == null) {
        return;
    }
    final DetachGlusterHostsModel hostsModel = (DetachGlusterHostsModel) getWindow();
    if (!hostsModel.validate()) {
        return;
    }
    boolean force = hostsModel.getForce().getEntity();
    ArrayList<ActionParametersBase> parametersList = new ArrayList<>();
    for (Object model : hostsModel.getHosts().getSelectedItems()) {
        String host = (String) ((EntityModel) model).getEntity();
        parametersList.add(new RemoveGlusterServerParameters(getEntity().getId(), host, force));
    }
    Frontend.getInstance().runMultipleAction(ActionType.RemoveGlusterServer, parametersList);
    cancel();
}
Also used : ArrayList(java.util.ArrayList) DetachGlusterHostsModel(org.ovirt.engine.ui.uicommonweb.models.gluster.DetachGlusterHostsModel) RemoveGlusterServerParameters(org.ovirt.engine.core.common.action.gluster.RemoveGlusterServerParameters) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 25 with ActionParametersBase

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

the class ClusterGeneralModel method onManageGlusterSwiftServices.

private void onManageGlusterSwiftServices() {
    if (getWindow() == null) {
        return;
    }
    ManageGlusterSwiftModel glusterSwiftModel = (ManageGlusterSwiftModel) getWindow();
    glusterSwiftModel.startProgress();
    if (glusterSwiftModel.getIsManageServerLevel().getEntity()) {
        ArrayList<ActionParametersBase> parametersList = new ArrayList<>();
        for (Object model : glusterSwiftModel.getHostServicesList().getItems()) {
            GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) model;
            GlusterSwiftAction action = getGlusterSwiftAction(swiftServiceModel.getStartSwift().getEntity(), swiftServiceModel.getStopSwift().getEntity(), swiftServiceModel.getRestartSwift().getEntity());
            if (action != null) {
                GlusterServiceParameters parameters = new GlusterServiceParameters(getEntity().getId(), swiftServiceModel.getEntity().getServerId(), ServiceType.GLUSTER_SWIFT, action.name().toLowerCase());
                parametersList.add(parameters);
            }
        }
        // should check what is the required behaviour and return to true if required.
        if (!parametersList.isEmpty()) {
            Frontend.getInstance().runMultipleAction(ActionType.ManageGlusterService, parametersList, false, result -> {
                ManageGlusterSwiftModel innerGlusterSwiftModel = (ManageGlusterSwiftModel) result.getState();
                innerGlusterSwiftModel.stopProgress();
                cancel();
                updateGlusterDetails();
            }, glusterSwiftModel);
        } else {
            glusterSwiftModel.stopProgress();
            glusterSwiftModel.setMessage(ConstantsManager.getInstance().getConstants().noActionSelectedManageGlusterSwift());
        }
    } else {
        GlusterSwiftAction action = getGlusterSwiftAction(glusterSwiftModel.getStartSwift().getEntity(), glusterSwiftModel.getStopSwift().getEntity(), glusterSwiftModel.getRestartSwift().getEntity());
        if (action != null) {
            GlusterServiceParameters parameters = new GlusterServiceParameters(getEntity().getId(), null, ServiceType.GLUSTER_SWIFT, action.name().toLowerCase());
            Frontend.getInstance().runAction(ActionType.ManageGlusterService, parameters, result -> {
                ManageGlusterSwiftModel innerGlusterSwiftModel = (ManageGlusterSwiftModel) result.getState();
                innerGlusterSwiftModel.stopProgress();
                if (result.getReturnValue().getSucceeded()) {
                    cancel();
                    updateGlusterDetails();
                }
            }, glusterSwiftModel);
        } else {
            glusterSwiftModel.stopProgress();
            glusterSwiftModel.setMessage(ConstantsManager.getInstance().getConstants().noActionSelectedManageGlusterSwift());
        }
    }
}
Also used : ArrayList(java.util.ArrayList) GlusterServiceParameters(org.ovirt.engine.core.common.action.gluster.GlusterServiceParameters) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Aggregations

ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)204 ArrayList (java.util.ArrayList)149 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)53 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)52 ActionType (org.ovirt.engine.core.common.action.ActionType)45 Test (org.junit.Test)44 Guid (org.ovirt.engine.core.compat.Guid)35 VDS (org.ovirt.engine.core.common.businessentities.VDS)26 List (java.util.List)23 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)23 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)20 VM (org.ovirt.engine.core.common.businessentities.VM)19 QueryType (org.ovirt.engine.core.common.queries.QueryType)18 Frontend (org.ovirt.engine.ui.frontend.Frontend)18 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)18 IFrontendActionAsyncCallback (org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback)18 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)16 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)16 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)16 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)15