Search in sources :

Example 1 with DataCenterModel

use of org.ovirt.engine.ui.uicommonweb.models.datacenters.DataCenterModel 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 DataCenterModel

use of org.ovirt.engine.ui.uicommonweb.models.datacenters.DataCenterModel in project ovirt-engine by oVirt.

the class AddDataCenterRM method prepare1.

private void prepare1() {
    EnlistmentContext enlistmentContext = (EnlistmentContext) context.enlistment.getContext();
    HostListModel<?> model = enlistmentContext.getModel();
    ConfigureLocalStorageModel configureModel = (ConfigureLocalStorageModel) model.getWindow();
    DataCenterModel dataCenterModel = configureModel.getDataCenter();
    String dataCenterName = dataCenterModel.getName().getEntity();
    if (!StringHelper.isNullOrEmpty(dataCenterName)) {
        AsyncDataProvider.getInstance().getDataCenterListByName(new AsyncQuery<>(returnValue -> {
            context.dataCenterFoundByName = Linq.firstOrNull(returnValue);
            prepare2();
        }), dataCenterName);
    } else {
        prepare2();
    }
}
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) DataCenterModel(org.ovirt.engine.ui.uicommonweb.models.datacenters.DataCenterModel)

Aggregations

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