Search in sources :

Example 1 with RemoveStorageDomainParameters

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

the class RemoveStoragePoolCommand method removeDomainFromPool.

protected boolean removeDomainFromPool(StorageDomain storageDomain, VDS vds) {
    if (storageDomain.getStorageType() != StorageType.LOCALFS || storageDomain.getStorageDomainType() == StorageDomainType.ISO) {
        DetachStorageDomainFromPoolParameters tempVar = new DetachStorageDomainFromPoolParameters(storageDomain.getId(), getStoragePool().getId());
        tempVar.setRemoveLast(true);
        tempVar.setDestroyingPool(true);
        // in detach of one of storage domains
        if (!Backend.getInstance().runInternalAction(ActionType.DetachStorageDomainFromPool, tempVar, cloneContext().withoutCompensationContext().withoutExecutionContext()).getSucceeded()) {
            return false;
        }
    } else {
        RemoveStorageDomainParameters tempVar = new RemoveStorageDomainParameters(storageDomain.getId());
        tempVar.setDestroyingPool(true);
        tempVar.setDoFormat(true);
        tempVar.setVdsId(vds.getId());
        if (!runInternalAction(ActionType.RemoveStorageDomain, tempVar, cloneContext().withoutLock().withoutExecutionContext()).getSucceeded()) {
            return false;
        }
    }
    return true;
}
Also used : RemoveStorageDomainParameters(org.ovirt.engine.core.common.action.RemoveStorageDomainParameters) DetachStorageDomainFromPoolParameters(org.ovirt.engine.core.common.action.DetachStorageDomainFromPoolParameters)

Example 2 with RemoveStorageDomainParameters

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

the class StorageListModel method onRemove.

private void onRemove() {
    if (getSelectedItem() != null) {
        StorageDomain storage = getSelectedItem();
        RemoveStorageModel model = (RemoveStorageModel) getWindow();
        if (!model.validate()) {
            return;
        }
        VDS host = model.getHostList().getSelectedItem();
        RemoveStorageDomainParameters tempVar = new RemoveStorageDomainParameters(storage.getId());
        tempVar.setVdsId(host.getId());
        tempVar.setDoFormat(model.getFormat().getEntity());
        Frontend.getInstance().runAction(ActionType.RemoveStorageDomain, tempVar, null, this);
    }
    cancel();
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) RemoveStorageDomainParameters(org.ovirt.engine.core.common.action.RemoveStorageDomainParameters) VDS(org.ovirt.engine.core.common.businessentities.VDS)

Example 3 with RemoveStorageDomainParameters

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

the class StorageDataCenterListModel method onDetach.

private void onDetach() {
    final ConfirmationModel model = (ConfirmationModel) getWindow();
    if (!model.validate()) {
        return;
    }
    setdetachPrms(new ArrayList<ActionParametersBase>());
    setremovePrms(new ArrayList<ActionParametersBase>());
    for (Object item : getSelectedItems()) {
        StorageDomain storageDomain = (StorageDomain) item;
        if (storageDomain.getStorageType() != StorageType.LOCALFS) {
            DetachStorageDomainFromPoolParameters param = new DetachStorageDomainFromPoolParameters();
            param.setStorageDomainId(getEntity().getId());
            if (storageDomain.getStoragePoolId() != null) {
                param.setStoragePoolId(storageDomain.getStoragePoolId());
            }
            getdetachPrms().add(param);
        } else {
            AsyncDataProvider.getInstance().getLocalStorageHost(new AsyncQuery<>(locaVds -> {
                StorageDomain storage = getEntity();
                RemoveStorageDomainParameters tempVar = new RemoveStorageDomainParameters(storage.getId());
                tempVar.setVdsId(locaVds != null ? locaVds.getId() : null);
                tempVar.setDoFormat(model.getForce().getEntity());
                RemoveStorageDomainParameters removeStorageDomainParameters = tempVar;
                getremovePrms().add(removeStorageDomainParameters);
                if (getremovePrms().size() + getdetachPrms().size() == getSelectedItems().size()) {
                    Frontend.getInstance().runMultipleAction(ActionType.RemoveStorageDomain, getremovePrms());
                }
            }), storageDomain.getStoragePoolName());
        }
        if (getdetachPrms().size() > 0) {
            Frontend.getInstance().runMultipleAction(ActionType.DetachStorageDomainFromPool, getdetachPrms());
        }
    }
    cancel();
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) LexoNumericComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) StorageDomainPoolParametersBase(org.ovirt.engine.core.common.action.StorageDomainPoolParametersBase) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Model(org.ovirt.engine.ui.uicommonweb.models.Model) AttachStorageDomainToPoolParameters(org.ovirt.engine.core.common.action.AttachStorageDomainToPoolParameters) RemoveStorageDomainParameters(org.ovirt.engine.core.common.action.RemoveStorageDomainParameters) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) ActionUtils(org.ovirt.engine.core.common.ActionUtils) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) StoragePoolStatus(org.ovirt.engine.core.common.businessentities.StoragePoolStatus) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) StorageDomainSharedStatus(org.ovirt.engine.core.common.businessentities.StorageDomainSharedStatus) List(java.util.List) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) Comparator(java.util.Comparator) Collections(java.util.Collections) DeactivateStorageDomainWithOvfUpdateParameters(org.ovirt.engine.core.common.action.DeactivateStorageDomainWithOvfUpdateParameters) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) DetachStorageDomainFromPoolParameters(org.ovirt.engine.core.common.action.DetachStorageDomainFromPoolParameters) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) RemoveStorageDomainParameters(org.ovirt.engine.core.common.action.RemoveStorageDomainParameters) DetachStorageDomainFromPoolParameters(org.ovirt.engine.core.common.action.DetachStorageDomainFromPoolParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 4 with RemoveStorageDomainParameters

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

the class DataCenterStorageListModel method onDetach.

public void onDetach() {
    final ConfirmationModel confirmModel = (ConfirmationModel) getWindow();
    if (confirmModel.getProgress() != null) {
        return;
    }
    if (!confirmModel.validate()) {
        return;
    }
    // A list of 'detach' action parameters
    setDetachParams(new ArrayList<>());
    // A list of 'remove' action parameters
    setRemoveParams(new ArrayList<>());
    String localStorgaeDC = null;
    for (StorageDomain a : getSelectedItems()) {
        // For local storage - remove; otherwise - detach
        if (a.getStorageType() == StorageType.LOCALFS && a.getStorageDomainType() != StorageDomainType.ISO) {
            getRemoveParams().add(new RemoveStorageDomainParameters(a.getId()));
            localStorgaeDC = a.getStoragePoolName();
        } else {
            getDetachParams().add(new DetachStorageDomainFromPoolParameters(a.getId(), getEntity().getId()));
        }
    }
    confirmModel.startProgress();
    if (getRemoveParams().size() > 0) {
        AsyncDataProvider.getInstance().getLocalStorageHost(new AsyncQuery<>(locaVds -> {
            for (ActionParametersBase item : getRemoveParams()) {
                ((RemoveStorageDomainParameters) item).setVdsId(locaVds != null ? locaVds.getId() : null);
                ((RemoveStorageDomainParameters) item).setDoFormat(confirmModel.getForce().getEntity());
            }
            postDetach(getWindow());
        }), localStorgaeDC);
    } else {
        postDetach(confirmModel);
    }
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) StorageDomainPoolParametersBase(org.ovirt.engine.core.common.action.StorageDomainPoolParametersBase) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) StorageFormatType(org.ovirt.engine.core.common.businessentities.StorageFormatType) Model(org.ovirt.engine.ui.uicommonweb.models.Model) AttachStorageDomainToPoolParameters(org.ovirt.engine.core.common.action.AttachStorageDomainToPoolParameters) RemoveStorageDomainParameters(org.ovirt.engine.core.common.action.RemoveStorageDomainParameters) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) ActionUtils(org.ovirt.engine.core.common.ActionUtils) Linq(org.ovirt.engine.ui.uicommonweb.Linq) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) StorageDomainSharedStatus(org.ovirt.engine.core.common.businessentities.StorageDomainSharedStatus) Collectors(java.util.stream.Collectors) NotifyCollectionChangedEventArgs(org.ovirt.engine.ui.uicompat.NotifyCollectionChangedEventArgs) List(java.util.List) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) DeactivateStorageDomainWithOvfUpdateParameters(org.ovirt.engine.core.common.action.DeactivateStorageDomainWithOvfUpdateParameters) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) DetachStorageDomainFromPoolParameters(org.ovirt.engine.core.common.action.DetachStorageDomainFromPoolParameters) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) RemoveStorageDomainParameters(org.ovirt.engine.core.common.action.RemoveStorageDomainParameters) DetachStorageDomainFromPoolParameters(org.ovirt.engine.core.common.action.DetachStorageDomainFromPoolParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 5 with RemoveStorageDomainParameters

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

the class BackendAttachedStorageDomainResource method remove.

@Override
public Response remove() {
    StorageDomain storageDomain = get();
    if (storageDomain.getStorage().getType().equals(StorageType.LOCALFS)) {
        RemoveStorageDomainParameters params = new RemoveStorageDomainParameters(guid);
        params.setDoFormat(true);
        return performAction(ActionType.RemoveStorageDomain, params);
    } else {
        DetachStorageDomainFromPoolParameters params = new DetachStorageDomainFromPoolParameters(guid, dataCenterId);
        return performAction(ActionType.DetachStorageDomainFromPool, params);
    }
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) RemoveStorageDomainParameters(org.ovirt.engine.core.common.action.RemoveStorageDomainParameters) DetachStorageDomainFromPoolParameters(org.ovirt.engine.core.common.action.DetachStorageDomainFromPoolParameters)

Aggregations

RemoveStorageDomainParameters (org.ovirt.engine.core.common.action.RemoveStorageDomainParameters)6 DetachStorageDomainFromPoolParameters (org.ovirt.engine.core.common.action.DetachStorageDomainFromPoolParameters)4 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ActionUtils (org.ovirt.engine.core.common.ActionUtils)2 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 ActionType (org.ovirt.engine.core.common.action.ActionType)2 AttachStorageDomainToPoolParameters (org.ovirt.engine.core.common.action.AttachStorageDomainToPoolParameters)2 DeactivateStorageDomainWithOvfUpdateParameters (org.ovirt.engine.core.common.action.DeactivateStorageDomainWithOvfUpdateParameters)2 StorageDomainPoolParametersBase (org.ovirt.engine.core.common.action.StorageDomainPoolParametersBase)2 StorageDomainSharedStatus (org.ovirt.engine.core.common.businessentities.StorageDomainSharedStatus)2 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)2 StorageDomainType (org.ovirt.engine.core.common.businessentities.StorageDomainType)2 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)2 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)2 QueryType (org.ovirt.engine.core.common.queries.QueryType)2 Frontend (org.ovirt.engine.ui.frontend.Frontend)2 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)2