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);
}
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();
}
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));
}
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();
}
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));
}
Aggregations