org.ovirt.engine.core.common.businessentities.Quota.getGlobalQuotaStorage()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(5.4k)|赞(0)|评价(0)|浏览(118)

本文整理了Java中org.ovirt.engine.core.common.businessentities.Quota.getGlobalQuotaStorage方法的一些代码示例,展示了Quota.getGlobalQuotaStorage的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Quota.getGlobalQuotaStorage方法的具体详情如下:
包路径:org.ovirt.engine.core.common.businessentities.Quota
类名称:Quota
方法名:getGlobalQuotaStorage

Quota.getGlobalQuotaStorage介绍

暂无

代码示例

代码示例来源:origin: oVirt/ovirt-engine

@Override
  protected void updateEntityForRemove(Quota entity, Guid id) {
    // since we're mocking remove using update, we'll throw 404 if the object isn't found
    boolean throw404 = false;
    // global storage (has same id as quota)
    if (entity.getId().equals(id)) {
      if (entity.getGlobalQuotaStorage() == null) {
        throw404 = true;
      } else {
        entity.setGlobalQuotaStorage(null);
      }
      // specific storage (has same id as storage domain)
    } else {
      if (entity.getQuotaStorages() != null) {
        for (int i = 0; i < entity.getQuotaStorages().size(); i++) {
          if (entity.getQuotaStorages().get(i).getStorageId().equals(id)) {
            entity.getQuotaStorages().remove(i);
            return;
          }
        }
        throw404 = true;
      }
    }
    if (throw404) {
      throw new WebApplicationException(Response.Status.NOT_FOUND);
    }
  }
}

代码示例来源:origin: oVirt/ovirt-engine

@Override
public QuotaStorageLimits list() {
  Quota quota = getQuota();
  QuotaStorageLimits limits = new QuotaStorageLimits();
  if (quota.getGlobalQuotaStorage() != null) {
    addLimit(quotaId.toString(), limits, quota);
  } else if (quota.getQuotaStorages() != null) {
    for (QuotaStorage quotaStorage : quota.getQuotaStorages()) {
      addLimit(quotaStorage.getStorageId().toString(), limits, quota);
    }
  }
  return limits;
}

代码示例来源:origin: oVirt/ovirt-engine

/**
 * Build parameter map, for quota limitation table, to indicate global limitation on {@code StoragePool}.
 *
 * @param quota
 *            - The global quota.
 * @return - Global quota Parameter Map.
 */
private MapSqlParameterSource getFullQuotaParameterMap(Quota quota) {
  return getCustomMapSqlParameterSource()
      .addValue("id", quota.getId())
      .addValue("quota_id", quota.getId())
      .addValue("cluster_id", null)
      .addValue("storage_id", null)
      .addValue("storage_size_gb",
          quota.getGlobalQuotaStorage() != null ? quota.getGlobalQuotaStorage()
              .getStorageSizeGB() : null)
      .addValue("virtual_cpu",
          quota.getGlobalQuotaCluster() != null ? quota.getGlobalQuotaCluster().getVirtualCpu()
              : null)
      .addValue("mem_size_mb",
          quota.getGlobalQuotaCluster() != null ? quota.getGlobalQuotaCluster().getMemSizeMB()
              : null);
}

代码示例来源:origin: oVirt/ovirt-engine

/**
 * Make Quota specific to be the same as Quota general and specific.
 */
@Test
public void testUpdateQuota() {
  Quota quotaGeneralToSpecific = dao.getById(FixturesTool.QUOTA_GENERAL);
  // Save quotaName and cluster list for future check.
  String quotaName = "New Temporary name";
  List<QuotaCluster> quotaClusterList =
      getQuotaCluster(getSpecificQuotaCluster(quotaGeneralToSpecific.getId()));
  Long newStorageLimit = 2345L;
  // Check before the update, that the fields are not equal.
  assertNotEquals(quotaName, quotaGeneralToSpecific.getQuotaName());
  assertNotEquals(quotaClusterList.size(), quotaGeneralToSpecific.getQuotaClusters().size());
  assertNotEquals(newStorageLimit, quotaGeneralToSpecific.getGlobalQuotaStorage().getStorageSizeGB());
  // Update
  quotaGeneralToSpecific.setQuotaName(quotaName);
  quotaGeneralToSpecific.getGlobalQuotaStorage().setStorageSizeGB(newStorageLimit);
  quotaGeneralToSpecific.setQuotaClusters(quotaClusterList);
  dao.update(quotaGeneralToSpecific);
  quotaGeneralToSpecific = dao.getById(FixturesTool.QUOTA_GENERAL);
  // Check after the update, that the fields are equal now.
  assertEquals(quotaName, quotaGeneralToSpecific.getQuotaName());
  assertEquals(quotaClusterList.size(), quotaGeneralToSpecific.getQuotaClusters().size());
  assertEquals(newStorageLimit, quotaGeneralToSpecific.getGlobalQuotaStorage().getStorageSizeGB());
}

代码示例来源:origin: oVirt/ovirt-engine

qModel.getGlobalClusterQuota().setEntity(true);
if (quota.getGlobalQuotaStorage() != null) {
  QuotaStorage storage = ((ArrayList<QuotaStorage>) qModel.getQuotaStorages().getItems()).get(0);
  storage.setStorageSizeGB(quota.getGlobalQuotaStorage().getStorageSizeGB());
  storage.setStorageSizeGBUsage(quota.getGlobalQuotaStorage().getStorageSizeGBUsage());
  qModel.getGlobalStorageQuota().setEntity(true);
            if (storageList == null || storageList.size() == 0) {
              qModel.getAllDataCenterStorages().setItems(new ArrayList<QuotaStorage>());
              if (quota.getGlobalQuotaStorage() == null) {
                qModel.getSpecificStorageQuota().setEntity(true);
            if (quota.getGlobalQuotaStorage() == null) {
              qModel.getSpecificStorageQuota().setEntity(true);

代码示例来源:origin: oVirt/ovirt-engine

@Mapping(from = org.ovirt.engine.core.common.businessentities.Quota.class, to = QuotaStorageLimit.class)
public static QuotaStorageLimit map(org.ovirt.engine.core.common.businessentities.Quota entity,
    QuotaStorageLimit template) {
  QuotaStorageLimit model = template != null ? template : new QuotaStorageLimit();
  Guid guid = GuidUtils.asGuid(model.getId());
  // global
  if (guid.equals(entity.getId())) {
    map(model, entity.getGlobalQuotaStorage(), null, entity.getStoragePoolId().toString(), entity.getId()
        .toString());
  } else { // specific
    if (entity.getQuotaStorages() != null) {
      for (QuotaStorage quotaStorage : entity.getQuotaStorages()) {
        if (quotaStorage.getStorageId() != null && quotaStorage.getStorageId().equals(guid)) {
          map(model, quotaStorage, quotaStorage.getStorageId().toString(), entity.getStoragePoolId()
              .toString(), entity.getId().toString());
        }
      }
    }
  }
  return model;
}

代码示例来源:origin: oVirt/ovirt-engine

for (QuotaStorage iter : model.getQuotaStorages().getItems()) {
  quota.setGlobalQuotaStorage(new QuotaStorage());
  quota.getGlobalQuotaStorage().setStorageSizeGB(iter.getStorageSizeGB());
  quota.getQuotaStorages().clear();

相关文章