Search in sources :

Example 1 with ClusterOperationParameters

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

the class AddClusterRM method prepare2.

public void prepare2() {
    PreparingEnlistment enlistment = (PreparingEnlistment) context.enlistment;
    EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext();
    HostListModel<?> model = enlistmentContext.getModel();
    ConfigureLocalStorageModel configureModel = (ConfigureLocalStorageModel) model.getWindow();
    Cluster candidate = configureModel.getCandidateCluster();
    ClusterModel clusterModel = configureModel.getCluster();
    String clusterName = clusterModel.getName().getEntity();
    if (candidate == null || !Objects.equals(candidate.getName(), clusterName)) {
        // Try to find existing cluster with the specified name.
        Cluster cluster = context.clusterFoundByName;
        if (cluster != null) {
            enlistmentContext.setClusterId(cluster.getId());
            context.enlistment = null;
            enlistment.prepared();
        } else {
            Version version = clusterModel.getVersion().getSelectedItem();
            cluster = new Cluster();
            cluster.setName(clusterName);
            cluster.setDescription(clusterModel.getDescription().getEntity());
            cluster.setStoragePoolId(enlistmentContext.getDataCenterId());
            cluster.setCpuName(clusterModel.getCPU().getSelectedItem().getCpuName());
            cluster.setMaxVdsMemoryOverCommit(clusterModel.getMemoryOverCommit());
            cluster.setCountThreadsAsCores(Boolean.TRUE.equals(clusterModel.getVersionSupportsCpuThreads().getEntity()) && Boolean.TRUE.equals(clusterModel.getCountThreadsAsCores().getEntity()));
            cluster.setTransparentHugepages(true);
            cluster.setCompatibilityVersion(version);
            cluster.setMigrateOnError(clusterModel.getMigrateOnErrorOption());
            ClusterOperationParameters parameters = new ManagementNetworkOnClusterOperationParameters(cluster);
            parameters.setCorrelationId(getCorrelationId());
            Frontend.getInstance().runAction(ActionType.AddCluster, parameters, result -> {
                ActionReturnValue returnValue = result.getReturnValue();
                context.addClusterReturnValue = returnValue;
                prepare3();
            });
        }
    } else {
        enlistmentContext.setClusterId(configureModel.getCluster().getClusterId());
        context.enlistment = null;
        enlistment.prepared();
    }
}
Also used : ClusterModel(org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterModel) ManagementNetworkOnClusterOperationParameters(org.ovirt.engine.core.common.action.ManagementNetworkOnClusterOperationParameters) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) Version(org.ovirt.engine.core.compat.Version) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ClusterOperationParameters(org.ovirt.engine.core.common.action.ClusterOperationParameters) ManagementNetworkOnClusterOperationParameters(org.ovirt.engine.core.common.action.ManagementNetworkOnClusterOperationParameters)

Aggregations

ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 ClusterOperationParameters (org.ovirt.engine.core.common.action.ClusterOperationParameters)1 ManagementNetworkOnClusterOperationParameters (org.ovirt.engine.core.common.action.ManagementNetworkOnClusterOperationParameters)1 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)1 Version (org.ovirt.engine.core.compat.Version)1 ClusterModel (org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterModel)1 PreparingEnlistment (org.ovirt.engine.ui.uicompat.PreparingEnlistment)1