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

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

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

Quota.getQuotaClusters介绍

暂无

代码示例

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

/**
 * @return If the cluster quota is empty, returns true.
 */
public boolean isEmptyClusterQuota() {
  return globalQuotaCluster == null && (getQuotaClusters() == null || getQuotaClusters().isEmpty());
}

代码示例来源: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 cluster (has same id as quota)
    if (entity.getId().equals(id)) {
      if (entity.getGlobalQuotaCluster() == null) {
        throw404 = true;
      } else {
        entity.setGlobalQuotaCluster(null);
      }
      // specific cluster (has same id as cluster)
    } else {
      if (entity.getQuotaClusters() != null) {
        Iterator<QuotaCluster> iterator = entity.getQuotaClusters().iterator();
        while (iterator.hasNext()) {
          if (iterator.next().getClusterId().equals(id)) {
            iterator.remove();
            return;
          }
        }
        throw404 = true;
      }
    }
    if (throw404) {
      throw new WebApplicationException(Response.Status.NOT_FOUND);
    }
  }
}

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

private void saveClusterSpecificQuotas(Quota quota) {
  // Add quota specific vds group limitations.
  for (QuotaCluster quotaCluster : quota.getQuotaClusters()) {
    getCallsHandler().executeModification("InsertQuotaLimitation",
        getQuotaClusterParameterMap(quota.getId(), quotaCluster));
  }
}

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

@Override
public QuotaClusterLimits list() {
  Quota quota = getQuota();
  QuotaClusterLimits limits = new QuotaClusterLimits();
  if (quota.getGlobalQuotaCluster() != null) {
    addLimit(quotaId.toString(), limits, quota);
  } else if (quota.getQuotaClusters() != null) {
    for (QuotaCluster quotaCluster : quota.getQuotaClusters()) {
      addLimit(quotaCluster.getClusterId().toString(), limits, quota);
    }
  }
  return limits;
}

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

quota.setGlobalQuotaCluster(quotaCluster);
} else {
  if (quota.getQuotaClusters() == null) {
    quota.setQuotaClusters(new ArrayList<>());
  quota.getQuotaClusters().add(quotaCluster);

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

@Mapping(from = org.ovirt.engine.core.common.businessentities.Quota.class, to = QuotaClusterLimit.class)
public static QuotaClusterLimit map(org.ovirt.engine.core.common.businessentities.Quota entity,
    QuotaClusterLimit template) {
  QuotaClusterLimit model = template != null ? template : new QuotaClusterLimit();
  Guid guid = GuidUtils.asGuid(model.getId());
  // global
  if (guid.equals(entity.getId())) {
    map(model, entity.getGlobalQuotaCluster(), null, entity.getStoragePoolId().toString(), entity.getId()
        .toString());
  } else { // specific
    if (entity.getQuotaClusters() != null) {
      for (QuotaCluster quotaCluster : entity.getQuotaClusters()) {
        if (quotaCluster.getClusterId() != null && quotaCluster.getClusterId().equals(guid)) {
          map(model, quotaCluster, quotaCluster.getClusterId().toString(), entity.getStoragePoolId()
              .toString(), entity.getId().toString());
        }
      }
    }
  }
  return model;
}

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

@Mapping(from = QuotaClusterLimit.class, to = org.ovirt.engine.core.common.businessentities.Quota.class)
  public static org.ovirt.engine.core.common.businessentities.Quota map(QuotaClusterLimit model,
      org.ovirt.engine.core.common.businessentities.Quota template) {
    org.ovirt.engine.core.common.businessentities.Quota entity =
        template != null ? template : new org.ovirt.engine.core.common.businessentities.Quota();
    QuotaCluster quotaCluster = new QuotaCluster();
    if (model.isSetVcpuLimit()) {
      quotaCluster.setVirtualCpu(model.getVcpuLimit());
    }

    if (model.isSetMemoryLimit()) {
      double limit = model.getMemoryLimit();
      quotaCluster.setMemSizeMB( (limit < 0) ? -1 : (long) (limit * 1024) );
    }

    // specific cluster
    if (model.isSetCluster() && model.getCluster().isSetId()) {
      quotaCluster.setClusterId(GuidUtils.asGuid(model.getCluster().getId()));
      entity.getQuotaClusters().add(quotaCluster);
    } else { // global
      entity.setGlobalQuotaCluster(quotaCluster);
    }
    return entity;
  }
}

代码示例来源: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

quota.getGlobalQuotaCluster().setMemSizeMB(iter.getMemSizeMB());
quota.getGlobalQuotaCluster().setVirtualCpu(iter.getVirtualCpu());
quota.getQuotaClusters().clear();

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

quotaCluster.setQuotaId(quota.getId());
boolean containCluster = false;
for (QuotaCluster iter : quota.getQuotaClusters()) {
  if (quotaCluster.getClusterId().equals(iter.getClusterId())) {
    quotaCluster.setQuotaClusterId(iter.getQuotaClusterId());

相关文章