Search in sources :

Example 1 with QuotaCRUDParameters

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

the class QuotaListModel method onCreateQuotaInternal.

private void onCreateQuotaInternal(boolean isClone) {
    QuotaModel model = (QuotaModel) getWindow();
    if (!model.validate()) {
        return;
    }
    Quota quota = model.getEntity();
    quota.setQuotaName(model.getName().getEntity());
    quota.setDescription(model.getDescription().getEntity());
    quota.setStoragePoolId(model.getDataCenter().getSelectedItem().getId());
    quota.setGraceClusterPercentage(model.getGraceClusterAsInteger());
    quota.setGraceStoragePercentage(model.getGraceStorageAsInteger());
    quota.setThresholdClusterPercentage(model.getThresholdClusterAsInteger());
    quota.setThresholdStoragePercentage(model.getThresholdStorageAsInteger());
    if (model.getGlobalClusterQuota().getEntity()) {
        QuotaCluster quotaCluster;
        for (QuotaCluster iter : model.getQuotaClusters().getItems()) {
            quota.setGlobalQuotaCluster(new QuotaCluster());
            quota.getGlobalQuotaCluster().setMemSizeMB(iter.getMemSizeMB());
            quota.getGlobalQuotaCluster().setVirtualCpu(iter.getVirtualCpu());
            quota.getQuotaClusters().clear();
        }
    } else {
        quota.setGlobalQuotaCluster(null);
        ArrayList<QuotaCluster> quotaClusterList = new ArrayList<>();
        QuotaCluster quotaCluster;
        for (QuotaCluster iter : model.getAllDataCenterClusters().getItems()) {
            quotaCluster = iter;
            if (quotaCluster.getMemSizeMB() != null) {
                quotaClusterList.add(quotaCluster);
            }
        }
        quota.setQuotaClusters(quotaClusterList);
    }
    if (model.getGlobalStorageQuota().getEntity()) {
        QuotaStorage quotaStorage;
        for (QuotaStorage iter : model.getQuotaStorages().getItems()) {
            quota.setGlobalQuotaStorage(new QuotaStorage());
            quota.getGlobalQuotaStorage().setStorageSizeGB(iter.getStorageSizeGB());
            quota.getQuotaStorages().clear();
        }
    } else {
        quota.setGlobalQuotaStorage(null);
        ArrayList<QuotaStorage> quotaStorageList = new ArrayList<>();
        QuotaStorage quotaStorage;
        for (QuotaStorage iter : model.getAllDataCenterStorages().getItems()) {
            quotaStorage = iter;
            if (quotaStorage.getStorageSizeGB() != null) {
                quotaStorageList.add(quotaStorage);
            }
        }
        quota.setQuotaStorages(quotaStorageList);
    }
    Guid guid = quota.getId();
    QuotaCRUDParameters parameters = new QuotaCRUDParameters(quota);
    if (isClone) {
        parameters.setCopyPermissions(model.getCopyPermissions().getEntity());
        parameters.setQuotaId(quota.getId());
        quota.setId(Guid.Empty);
    }
    ActionType actionType = ActionType.AddQuota;
    if (!quota.getId().equals(Guid.Empty)) {
        actionType = ActionType.UpdateQuota;
    }
    Frontend.getInstance().runAction(actionType, parameters, result -> setWindow(null));
    quota.setId(guid);
}
Also used : QuotaCRUDParameters(org.ovirt.engine.core.common.action.QuotaCRUDParameters) QuotaStorage(org.ovirt.engine.core.common.businessentities.QuotaStorage) ActionType(org.ovirt.engine.core.common.action.ActionType) Quota(org.ovirt.engine.core.common.businessentities.Quota) ArrayList(java.util.ArrayList) QuotaCluster(org.ovirt.engine.core.common.businessentities.QuotaCluster) Guid(org.ovirt.engine.core.compat.Guid)

Example 2 with QuotaCRUDParameters

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

the class BackendQuotaClusterLimitsResource method add.

@Override
public Response add(QuotaClusterLimit incoming) {
    Quota entity = getQuota();
    QuotaCRUDParameters parameters = new QuotaCRUDParameters(map(incoming, entity));
    performAction(ActionType.UpdateQuota, parameters);
    entity = getQuota();
    updateIncomingId(incoming, entity);
    QuotaClusterLimit model = map(entity, incoming);
    model = addLinks(doPopulate(model, entity));
    return Response.ok(model).build();
}
Also used : QuotaCRUDParameters(org.ovirt.engine.core.common.action.QuotaCRUDParameters) Quota(org.ovirt.engine.core.common.businessentities.Quota) QuotaClusterLimit(org.ovirt.engine.api.model.QuotaClusterLimit)

Example 3 with QuotaCRUDParameters

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

the class BackendQuotaLimitResource method remove.

public Response remove() {
    Quota entity = getEntity(Quota.class, QueryType.GetQuotaByQuotaId, new IdQueryParameters(parentId), parentId.toString());
    updateEntityForRemove(entity, asGuid(id));
    return performAction(ActionType.UpdateQuota, new QuotaCRUDParameters(entity));
}
Also used : QuotaCRUDParameters(org.ovirt.engine.core.common.action.QuotaCRUDParameters) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Quota(org.ovirt.engine.core.common.businessentities.Quota)

Example 4 with QuotaCRUDParameters

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

the class BackendQuotaStorageLimitsResource method add.

public Response add(QuotaStorageLimit incoming) {
    Quota entity = getQuota();
    QuotaCRUDParameters parameters = new QuotaCRUDParameters(map(incoming, entity));
    performAction(ActionType.UpdateQuota, parameters);
    entity = getQuota();
    updateIncomingId(incoming, entity);
    QuotaStorageLimit model = map(entity, incoming);
    model = addLinks(doPopulate(model, entity));
    return Response.ok(model).build();
}
Also used : QuotaCRUDParameters(org.ovirt.engine.core.common.action.QuotaCRUDParameters) QuotaStorageLimit(org.ovirt.engine.api.model.QuotaStorageLimit) Quota(org.ovirt.engine.core.common.businessentities.Quota)

Example 5 with QuotaCRUDParameters

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

the class BackendQuotasResource method add.

@Override
public Response add(Quota quota) {
    validateParameters(quota, "name");
    org.ovirt.engine.core.common.businessentities.Quota entity = map(quota);
    entity.setStoragePoolId(dataCenterId);
    return performCreate(ActionType.AddQuota, new QuotaCRUDParameters(entity), new QueryIdResolver<Guid>(QueryType.GetQuotaByQuotaId, IdQueryParameters.class));
}
Also used : QuotaCRUDParameters(org.ovirt.engine.core.common.action.QuotaCRUDParameters) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Guid(org.ovirt.engine.core.compat.Guid)

Aggregations

QuotaCRUDParameters (org.ovirt.engine.core.common.action.QuotaCRUDParameters)5 Quota (org.ovirt.engine.core.common.businessentities.Quota)4 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)2 Guid (org.ovirt.engine.core.compat.Guid)2 ArrayList (java.util.ArrayList)1 QuotaClusterLimit (org.ovirt.engine.api.model.QuotaClusterLimit)1 QuotaStorageLimit (org.ovirt.engine.api.model.QuotaStorageLimit)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 QuotaCluster (org.ovirt.engine.core.common.businessentities.QuotaCluster)1 QuotaStorage (org.ovirt.engine.core.common.businessentities.QuotaStorage)1