Search in sources :

Example 1 with ReduceSANStorageDomainDevicesCommandParameters

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

the class StorageListModel method saveSanStorage.

private void saveSanStorage(TaskContext context) {
    this.context = context;
    StorageModel model = (StorageModel) getWindow();
    SanStorageModelBase sanModel = (SanStorageModelBase) model.getCurrentStorageItem();
    StorageDomain storage = getSelectedItem();
    boolean isNew = model.getStorage() == null;
    storageDomain = isNew ? new StorageDomainStatic() : (StorageDomainStatic) Cloner.clone(storage.getStorageStaticData());
    storageDomain.setStorageType(isNew ? sanModel.getType() : storageDomain.getStorageType());
    storageDomain.setStorageDomainType(isNew ? sanModel.getRole() : storageDomain.getStorageDomainType());
    storageDomain.setStorageFormat(isNew ? sanModel.getContainer().getFormat().getSelectedItem() : storageDomain.getStorageFormat());
    storageDomain.setDescription(model.getDescription().getEntity());
    storageDomain.setComment(model.getComment().getEntity());
    saveCommonStorageProperties(model);
    if (isNew) {
        saveNewSanStorage();
    } else {
        Frontend.getInstance().runAction(ActionType.UpdateStorageDomain, new StorageDomainManagementParameter(storageDomain), new IFrontendActionAsyncCallback() {

            @Override
            public void executed(FrontendActionAsyncResult result) {
                StorageListModel storageListModel = (StorageListModel) result.getState();
                StorageModel storageModel = (StorageModel) getWindow();
                SanStorageModelBase sanStorageModelBase = (SanStorageModelBase) storageModel.getCurrentStorageItem();
                boolean force = sanStorageModelBase.isForce();
                StorageDomain storageDomain1 = storageListModel.getSelectedItem();
                HashSet<String> lunIds = new HashSet<>();
                for (LunModel lun : sanStorageModelBase.getAddedLuns()) {
                    lunIds.add(lun.getLunId());
                }
                if (lunIds.size() > 0) {
                    Frontend.getInstance().runAction(ActionType.ExtendSANStorageDomain, new ExtendSANStorageDomainParameters(storageDomain1.getId(), new HashSet<>(lunIds), force), null, this);
                }
                Set<String> lunToRefreshIds = sanStorageModelBase.getLunsToRefresh();
                if (lunToRefreshIds.size() > 0) {
                    Frontend.getInstance().runAction(ActionType.RefreshLunsSize, new ExtendSANStorageDomainParameters(storageDomain1.getId(), lunToRefreshIds, false), null, this);
                }
                if (storageDomain1.getStatus() == StorageDomainStatus.Maintenance) {
                    Set<String> lunsToRemoveIds = sanStorageModelBase.getLunsToRemove();
                    if (lunsToRemoveIds.size() > 0) {
                        Frontend.getInstance().runAction(ActionType.ReduceSANStorageDomainDevices, new ReduceSANStorageDomainDevicesCommandParameters(storageDomain1.getId(), new ArrayList<>(lunsToRemoveIds)), null, this);
                    }
                }
                storageListModel.onFinish(storageListModel.context, true, storageListModel.storageModel);
            }
        }, this);
    }
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) FrontendActionAsyncResult(org.ovirt.engine.ui.uicompat.FrontendActionAsyncResult) Set(java.util.Set) HashSet(java.util.HashSet) StorageDomainManagementParameter(org.ovirt.engine.core.common.action.StorageDomainManagementParameter) ReduceSANStorageDomainDevicesCommandParameters(org.ovirt.engine.core.common.action.ReduceSANStorageDomainDevicesCommandParameters) ExtendSANStorageDomainParameters(org.ovirt.engine.core.common.action.ExtendSANStorageDomainParameters) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) HashSet(java.util.HashSet)

Example 2 with ReduceSANStorageDomainDevicesCommandParameters

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

the class BackendStorageDomainResource method reduceLuns.

@Override
public Response reduceLuns(Action action) {
    List<LogicalUnit> reducedLuns = action.getLogicalUnits().getLogicalUnits();
    List<String> lunIds = reducedLuns.stream().map(LogicalUnit::getId).collect(toList());
    ReduceSANStorageDomainDevicesCommandParameters parameters = new ReduceSANStorageDomainDevicesCommandParameters(guid, lunIds);
    return performAction(ActionType.ReduceSANStorageDomainDevices, parameters);
}
Also used : LogicalUnit(org.ovirt.engine.api.model.LogicalUnit) ReduceSANStorageDomainDevicesCommandParameters(org.ovirt.engine.core.common.action.ReduceSANStorageDomainDevicesCommandParameters)

Aggregations

ReduceSANStorageDomainDevicesCommandParameters (org.ovirt.engine.core.common.action.ReduceSANStorageDomainDevicesCommandParameters)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1 LogicalUnit (org.ovirt.engine.api.model.LogicalUnit)1 ExtendSANStorageDomainParameters (org.ovirt.engine.core.common.action.ExtendSANStorageDomainParameters)1 StorageDomainManagementParameter (org.ovirt.engine.core.common.action.StorageDomainManagementParameter)1 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)1 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)1 FrontendActionAsyncResult (org.ovirt.engine.ui.uicompat.FrontendActionAsyncResult)1 IFrontendActionAsyncCallback (org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback)1