Search in sources :

Example 1 with StoragePoolManagementParameter

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

the class AddDataCenterRM method prepare2.

private void prepare2() {
    PreparingEnlistment enlistment = (PreparingEnlistment) context.enlistment;
    EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext();
    HostListModel<?> model = enlistmentContext.getModel();
    ConfigureLocalStorageModel configureModel = (ConfigureLocalStorageModel) model.getWindow();
    StoragePool candidate = configureModel.getCandidateDataCenter();
    DataCenterModel dataCenterModel = configureModel.getDataCenter();
    String dataCenterName = dataCenterModel.getName().getEntity();
    if (candidate == null || !Objects.equals(candidate.getName(), dataCenterName)) {
        // Try to find existing data center with the specified name.
        StoragePool dataCenter = context.dataCenterFoundByName;
        if (dataCenter != null) {
            enlistmentContext.setDataCenterId(dataCenter.getId());
            context.enlistment = null;
            enlistment.prepared();
        } else {
            dataCenter = new StoragePool();
            dataCenter.setName(dataCenterName);
            dataCenter.setdescription(dataCenterModel.getDescription().getEntity());
            dataCenter.setComment(dataCenterModel.getComment().getEntity());
            dataCenter.setIsLocal(dataCenterModel.getStoragePoolType().getSelectedItem());
            dataCenter.setCompatibilityVersion(dataCenterModel.getVersion().getSelectedItem());
            StoragePoolManagementParameter parameters = new StoragePoolManagementParameter(dataCenter);
            parameters.setCorrelationId(getCorrelationId());
            Frontend.getInstance().runAction(ActionType.AddEmptyStoragePool, parameters, result -> {
                context.addDataCenterReturnValue = result.getReturnValue();
                prepare3();
            });
        }
    } else {
        enlistmentContext.setDataCenterId(configureModel.getDataCenter().getDataCenterId());
        context.enlistment = null;
        enlistment.prepared();
    }
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) DataCenterModel(org.ovirt.engine.ui.uicommonweb.models.datacenters.DataCenterModel) StoragePoolManagementParameter(org.ovirt.engine.core.common.action.StoragePoolManagementParameter)

Example 2 with StoragePoolManagementParameter

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

the class DataCenterListModel method onSaveInternal.

public void onSaveInternal() {
    DataCenterModel model = (DataCenterModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    StoragePool dataCenter = model.getIsNew() ? new StoragePool() : (StoragePool) Cloner.clone(getSelectedItem());
    // cancel confirm window if there is
    cancelConfirmation();
    // Save changes.
    dataCenter.setName(model.getName().getEntity());
    dataCenter.setdescription(model.getDescription().getEntity());
    dataCenter.setComment(model.getComment().getEntity());
    dataCenter.setIsLocal(model.getStoragePoolType().getSelectedItem());
    dataCenter.setCompatibilityVersion(model.getVersion().getSelectedItem());
    dataCenter.setQuotaEnforcementType(model.getQuotaEnforceTypeListModel().getSelectedItem());
    model.startProgress();
    if (model.getIsNew()) {
        // When adding a data center use sync action to be able present a Guide Me dialog afterwards.
        Frontend.getInstance().runAction(ActionType.AddEmptyStoragePool, new StoragePoolManagementParameter(dataCenter), result -> {
            DataCenterListModel localModel = (DataCenterListModel) result.getState();
            localModel.postOnSaveInternal(result.getReturnValue());
        }, this);
    } else {
        // Use async action in order to close dialog immediately.
        Frontend.getInstance().runMultipleAction(ActionType.UpdateStoragePool, new ArrayList<ActionParametersBase>(Arrays.asList(new StoragePoolManagementParameter(dataCenter))), result -> {
            DataCenterListModel localModel = (DataCenterListModel) result.getState();
            localModel.postOnSaveInternal(result.getReturnValue().get(0));
        }, this);
    }
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) StoragePoolManagementParameter(org.ovirt.engine.core.common.action.StoragePoolManagementParameter) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 3 with StoragePoolManagementParameter

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

the class BackendDataCentersResource method add.

@Override
public Response add(DataCenter dataCenter) {
    validateParameters(dataCenter, "name");
    if (!dataCenter.isSetLocal()) {
        validateParameters(dataCenter, "local");
    }
    StoragePool entity = map(dataCenter);
    return performCreate(ActionType.AddEmptyStoragePool, new StoragePoolManagementParameter(entity), new QueryIdResolver<Guid>(QueryType.GetStoragePoolById, IdQueryParameters.class));
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Guid(org.ovirt.engine.core.compat.Guid) StoragePoolManagementParameter(org.ovirt.engine.core.common.action.StoragePoolManagementParameter)

Aggregations

StoragePoolManagementParameter (org.ovirt.engine.core.common.action.StoragePoolManagementParameter)3 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)3 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1 Guid (org.ovirt.engine.core.compat.Guid)1 DataCenterModel (org.ovirt.engine.ui.uicommonweb.models.datacenters.DataCenterModel)1 PreparingEnlistment (org.ovirt.engine.ui.uicompat.PreparingEnlistment)1