Search in sources :

Example 1 with Enlistment

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

the class AddDataCenterRM method rollback3.

public void rollback3() {
    Enlistment enlistment = context.enlistment;
    EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext();
    HostListModel<?> model = enlistmentContext.getModel();
    VDS host = context.hostFoundById;
    boolean abort = false;
    if (model.getSelectedItem() != null) {
        // Perform rollback only when the host is in maintenance.
        if (host.getStatus() != VDSStatus.Maintenance) {
            abort = true;
        }
    } else {
        abort = true;
    }
    if (abort) {
        context.enlistment = null;
        enlistment.done();
        return;
    }
    StoragePool dataCenter = context.dataCenterFoundById;
    // Perform rollback only when the Data Center is un uninitialized.
    if (dataCenter.getStatus() != StoragePoolStatus.Uninitialized) {
        context.enlistment = null;
        enlistment.done();
        return;
    }
    if (enlistmentContext.getOldClusterId() != null) {
        // Switch host back to previous cluster.
        Frontend.getInstance().runAction(ActionType.ChangeVDSCluster, new ChangeVDSClusterParameters(enlistmentContext.getOldClusterId(), host.getId()), result -> {
            ActionReturnValue returnValue = result.getReturnValue();
            context.changeVDSClusterReturnValue = returnValue;
            rollback4();
        });
    } else {
        context.enlistment = null;
        enlistment.done();
    }
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VDS(org.ovirt.engine.core.common.businessentities.VDS) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) Enlistment(org.ovirt.engine.ui.uicompat.Enlistment) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters)

Example 2 with Enlistment

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

the class AddDataCenterRM method rollback4.

private void rollback4() {
    Enlistment enlistment = context.enlistment;
    EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext();
    ActionReturnValue returnValue = context.changeVDSClusterReturnValue;
    if (returnValue != null && returnValue.getSucceeded()) {
        // Remove cluster.
        if (enlistmentContext.getClusterId() != null) {
            Frontend.getInstance().runAction(ActionType.RemoveCluster, new ClusterParametersBase(enlistmentContext.getClusterId()), result -> rollback5());
        }
    } else {
        context.enlistment = null;
        enlistment.done();
    }
}
Also used : ClusterParametersBase(org.ovirt.engine.core.common.action.ClusterParametersBase) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) Enlistment(org.ovirt.engine.ui.uicompat.Enlistment)

Example 3 with Enlistment

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

the class AddDataCenterRM method rollback2.

public void rollback2() {
    Enlistment enlistment = context.enlistment;
    EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext();
    HostListModel<?> model = enlistmentContext.getModel();
    VDS host = model.getSelectedItem();
    // Retrieve host to make sure we have an updated status etc.
    AsyncDataProvider.getInstance().getHostById(new AsyncQuery<>(returnValue -> {
        context.hostFoundById = returnValue;
        rollback3();
    }), host.getId());
}
Also used : ClusterParametersBase(org.ovirt.engine.core.common.action.ClusterParametersBase) StoragePoolParametersBase(org.ovirt.engine.core.common.action.StoragePoolParametersBase) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) StoragePoolStatus(org.ovirt.engine.core.common.businessentities.StoragePoolStatus) IEnlistmentNotification(org.ovirt.engine.ui.uicompat.IEnlistmentNotification) Linq(org.ovirt.engine.ui.uicommonweb.Linq) Guid(org.ovirt.engine.core.compat.Guid) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) StringHelper(org.ovirt.engine.core.compat.StringHelper) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) StoragePoolManagementParameter(org.ovirt.engine.core.common.action.StoragePoolManagementParameter) Objects(java.util.Objects) 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) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) DataCenterModel(org.ovirt.engine.ui.uicommonweb.models.datacenters.DataCenterModel) VDS(org.ovirt.engine.core.common.businessentities.VDS) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) VDS(org.ovirt.engine.core.common.businessentities.VDS) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) Enlistment(org.ovirt.engine.ui.uicompat.Enlistment)

Example 4 with Enlistment

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

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

the class AddDataCenterRM method rollback1.

public void rollback1() {
    Enlistment enlistment = context.enlistment;
    EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext();
    if (enlistmentContext.getDataCenterId() != null) {
        AsyncDataProvider.getInstance().getDataCenterById(new AsyncQuery<>(returnValue -> {
            context.dataCenterFoundById = returnValue;
            rollback2();
        }), enlistmentContext.getDataCenterId());
    } else {
        rollback3();
    }
}
Also used : ClusterParametersBase(org.ovirt.engine.core.common.action.ClusterParametersBase) StoragePoolParametersBase(org.ovirt.engine.core.common.action.StoragePoolParametersBase) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) StoragePoolStatus(org.ovirt.engine.core.common.businessentities.StoragePoolStatus) IEnlistmentNotification(org.ovirt.engine.ui.uicompat.IEnlistmentNotification) Linq(org.ovirt.engine.ui.uicommonweb.Linq) Guid(org.ovirt.engine.core.compat.Guid) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) StringHelper(org.ovirt.engine.core.compat.StringHelper) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) StoragePoolManagementParameter(org.ovirt.engine.core.common.action.StoragePoolManagementParameter) Objects(java.util.Objects) 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) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) DataCenterModel(org.ovirt.engine.ui.uicommonweb.models.datacenters.DataCenterModel) VDS(org.ovirt.engine.core.common.businessentities.VDS) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) Enlistment(org.ovirt.engine.ui.uicompat.Enlistment)

Aggregations

Enlistment (org.ovirt.engine.ui.uicompat.Enlistment)6 PreparingEnlistment (org.ovirt.engine.ui.uicompat.PreparingEnlistment)6 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)5 VDS (org.ovirt.engine.core.common.businessentities.VDS)4 ActionType (org.ovirt.engine.core.common.action.ActionType)3 ChangeVDSClusterParameters (org.ovirt.engine.core.common.action.ChangeVDSClusterParameters)3 ClusterParametersBase (org.ovirt.engine.core.common.action.ClusterParametersBase)3 StoragePoolParametersBase (org.ovirt.engine.core.common.action.StoragePoolParametersBase)3 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)3 VDSStatus (org.ovirt.engine.core.common.businessentities.VDSStatus)3 AsyncQuery (org.ovirt.engine.ui.frontend.AsyncQuery)3 Frontend (org.ovirt.engine.ui.frontend.Frontend)3 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)3 IEnlistmentNotification (org.ovirt.engine.ui.uicompat.IEnlistmentNotification)3 Objects (java.util.Objects)2 StoragePoolManagementParameter (org.ovirt.engine.core.common.action.StoragePoolManagementParameter)2 StoragePoolStatus (org.ovirt.engine.core.common.businessentities.StoragePoolStatus)2 Guid (org.ovirt.engine.core.compat.Guid)2 StringHelper (org.ovirt.engine.core.compat.StringHelper)2 Linq (org.ovirt.engine.ui.uicommonweb.Linq)2