Search in sources :

Example 1 with PreparingEnlistment

use of org.ovirt.engine.ui.uicompat.PreparingEnlistment 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 PreparingEnlistment

use of org.ovirt.engine.ui.uicompat.PreparingEnlistment in project ovirt-engine by oVirt.

the class AddStorageDomainRM method prepare2.

private void prepare2() {
    PreparingEnlistment enlistment = (PreparingEnlistment) context.enlistment;
    ActionReturnValue returnValue = context.activateVdsReturnValue;
    if (returnValue == null || !returnValue.getSucceeded()) {
        context.enlistment = null;
        enlistment.forceRollback();
    } else {
        prepare3();
    }
}
Also used : PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue)

Example 3 with PreparingEnlistment

use of org.ovirt.engine.ui.uicompat.PreparingEnlistment in project ovirt-engine by oVirt.

the class AddStorageDomainRM method prepare4.

private void prepare4() {
    if (timer != null) {
        timer.cancel();
        timer = null;
    }
    PreparingEnlistment enlistment = (PreparingEnlistment) context.enlistment;
    EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext();
    HostListModel<?> model = enlistmentContext.getModel();
    ConfigureLocalStorageModel configureModel = (ConfigureLocalStorageModel) model.getWindow();
    if (context.host.getStatus() != VDSStatus.Up) {
        prepare3();
    } else {
        // Add storage domain.
        StorageServerConnections connection = new StorageServerConnections();
        connection.setConnection(configureModel.getStorage().getPath().getEntity());
        connection.setStorageType(StorageType.LOCALFS);
        context.connection = connection;
        StorageServerConnectionParametersBase parameters = new StorageServerConnectionParametersBase(connection, context.host.getId(), false);
        parameters.setCorrelationId(getCorrelationId());
        Frontend.getInstance().runAction(ActionType.AddStorageServerConnection, parameters, result -> {
            ActionReturnValue returnValue = result.getReturnValue();
            context.addStorageServerConnectionReturnValue = returnValue;
            prepare5();
        });
    }
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) StorageServerConnectionParametersBase(org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase)

Example 4 with PreparingEnlistment

use of org.ovirt.engine.ui.uicompat.PreparingEnlistment in project ovirt-engine by oVirt.

the class AddStorageDomainRM method prepare3.

private void prepare3() {
    PreparingEnlistment enlistment = (PreparingEnlistment) context.enlistment;
    EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext();
    HostListModel<?> model = enlistmentContext.getModel();
    VDS host = model.getSelectedItem();
    if (context.waitTries < MaxWaitTries) {
        context.waitTries++;
        AsyncDataProvider.getInstance().getHostById(new AsyncQuery<>(returnValue -> {
            context.host = returnValue;
            timer = new Timer() {

                @Override
                public void run() {
                    prepare4();
                }
            };
            timer.scheduleRepeating(WaitInterval);
        }), host.getId());
    } else {
        context.enlistment = null;
        enlistment.forceRollback();
    }
}
Also used : VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) IEnlistmentNotification(org.ovirt.engine.ui.uicompat.IEnlistmentNotification) StorageDomainManagementParameter(org.ovirt.engine.core.common.action.StorageDomainManagementParameter) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Enlistment(org.ovirt.engine.ui.uicompat.Enlistment) StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StorageServerConnectionParametersBase(org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) VDS(org.ovirt.engine.core.common.businessentities.VDS) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Timer(com.google.gwt.user.client.Timer) VDS(org.ovirt.engine.core.common.businessentities.VDS) Timer(com.google.gwt.user.client.Timer) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment)

Example 5 with PreparingEnlistment

use of org.ovirt.engine.ui.uicompat.PreparingEnlistment in project ovirt-engine by oVirt.

the class AddStorageDomainRM method prepare7.

private void prepare7() {
    PreparingEnlistment enlistment = (PreparingEnlistment) context.enlistment;
    ActionReturnValue returnValue = context.removeStorageServerConnectionReturnValue;
    context.enlistment = null;
    // ReturnValue not equals null means remove connection occurred.
    if (returnValue != null) {
        // Don't rollback.
        enlistment.done();
    } else {
        enlistment.prepared();
    }
}
Also used : PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue)

Aggregations

PreparingEnlistment (org.ovirt.engine.ui.uicompat.PreparingEnlistment)11 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)10 StorageDomainManagementParameter (org.ovirt.engine.core.common.action.StorageDomainManagementParameter)2 StorageServerConnectionParametersBase (org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase)2 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)2 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)2 VDS (org.ovirt.engine.core.common.businessentities.VDS)2 Timer (com.google.gwt.user.client.Timer)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 ChangeVDSClusterParameters (org.ovirt.engine.core.common.action.ChangeVDSClusterParameters)1 ClusterOperationParameters (org.ovirt.engine.core.common.action.ClusterOperationParameters)1 ManagementNetworkOnClusterOperationParameters (org.ovirt.engine.core.common.action.ManagementNetworkOnClusterOperationParameters)1 StoragePoolManagementParameter (org.ovirt.engine.core.common.action.StoragePoolManagementParameter)1 VdsActionParameters (org.ovirt.engine.core.common.action.VdsActionParameters)1 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)1 StorageDomainType (org.ovirt.engine.core.common.businessentities.StorageDomainType)1 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)1 VDSStatus (org.ovirt.engine.core.common.businessentities.VDSStatus)1 StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)1 Version (org.ovirt.engine.core.compat.Version)1