Search in sources :

Example 1 with ExtendSANStorageDomainParameters

use of org.ovirt.engine.core.common.action.ExtendSANStorageDomainParameters 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 ExtendSANStorageDomainParameters

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

the class BackendStorageDomainResource method addLunsToStorageDomain.

private void addLunsToStorageDomain(List<LogicalUnit> newLuns, boolean overrideLuns) {
    ExtendSANStorageDomainParameters params = createParameters(guid, newLuns, overrideLuns);
    performAction(ActionType.ExtendSANStorageDomain, params);
}
Also used : ExtendSANStorageDomainParameters(org.ovirt.engine.core.common.action.ExtendSANStorageDomainParameters)

Example 3 with ExtendSANStorageDomainParameters

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

the class BackendStorageDomainResource method createParameters.

private ExtendSANStorageDomainParameters createParameters(Guid storageDomainId, List<LogicalUnit> newLuns, boolean force) {
    ExtendSANStorageDomainParameters params = new ExtendSANStorageDomainParameters();
    params.setStorageDomainId(storageDomainId);
    Set<String> lunIds = newLuns.stream().map(LogicalUnit::getId).collect(Collectors.toSet());
    params.setLunIds(lunIds);
    params.setForce(force);
    return params;
}
Also used : ExtendSANStorageDomainParameters(org.ovirt.engine.core.common.action.ExtendSANStorageDomainParameters)

Example 4 with ExtendSANStorageDomainParameters

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

the class BackendStorageDomainResource method refreshLuns.

@Override
public Response refreshLuns(Action action) {
    List<LogicalUnit> incomingLuns;
    if (action.isSetLogicalUnits()) {
        incomingLuns = action.getLogicalUnits().getLogicalUnits();
    } else {
        incomingLuns = Collections.emptyList();
    }
    ExtendSANStorageDomainParameters params = createParameters(guid, incomingLuns, false);
    return performAction(ActionType.RefreshLunsSize, params);
}
Also used : LogicalUnit(org.ovirt.engine.api.model.LogicalUnit) ExtendSANStorageDomainParameters(org.ovirt.engine.core.common.action.ExtendSANStorageDomainParameters)

Aggregations

ExtendSANStorageDomainParameters (org.ovirt.engine.core.common.action.ExtendSANStorageDomainParameters)4 HashSet (java.util.HashSet)1 Set (java.util.Set)1 LogicalUnit (org.ovirt.engine.api.model.LogicalUnit)1 ReduceSANStorageDomainDevicesCommandParameters (org.ovirt.engine.core.common.action.ReduceSANStorageDomainDevicesCommandParameters)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