private Quota getQuota() { Quota quota = new Quota(); quota.setName("Quota_Name"); quota.setClusterHardLimitPct(CLUSTER_HARD_LIMIT_PCT); quota.setClusterSoftLimitPct(CLUSTER_SOFT_LIMIT_PCT); quota.setStorageHardLimitPct(STORAGE_HARD_LIMIT_PCT); quota.setStorageSoftLimitPct(STORAGE_SOFT_LIMIT_PCT); return quota; }
@Mapping(from = Quota.class, to = org.ovirt.engine.core.common.businessentities.Quota.class) public static org.ovirt.engine.core.common.businessentities.Quota map(Quota model, org.ovirt.engine.core.common.businessentities.Quota template) { org.ovirt.engine.core.common.businessentities.Quota entity = (template==null) ? new org.ovirt.engine.core.common.businessentities.Quota() : template; if (model.isSetId()) { entity.setId(GuidUtils.asGuid(model.getId())); } if (model.isSetName()) { entity.setQuotaName(model.getName()); } if (model.isSetDescription()) { entity.setDescription(model.getDescription()); } if (model.isSetDataCenter()) { entity.setStoragePoolId(GuidUtils.asGuid(model.getDataCenter().getId())); } if (model.isSetClusterHardLimitPct()) { entity.setGraceClusterPercentage(model.getClusterHardLimitPct()); } if (model.isSetStorageHardLimitPct()) { entity.setGraceStoragePercentage(model.getStorageHardLimitPct()); } if (model.isSetClusterSoftLimitPct()) { entity.setThresholdClusterPercentage(model.getClusterSoftLimitPct()); } if (model.isSetStorageSoftLimitPct()) { entity.setThresholdStoragePercentage(model.getStorageSoftLimitPct()); } return entity; }
private Quota getModel() { Quota quota = new Quota(); quota.setId(GUIDS[0].toString()); quota.setDescription(DESCRIPTIONS[0]); quota.setClusterHardLimitPct(30); return quota; }
@Override public V3Quota adapt(Quota from) { V3Quota to = new V3Quota(); if (from.isSetLinks()) { to.getLinks().addAll(adaptOut(from.getLinks())); if (from.isSetActions()) { to.setActions(adaptOut(from.getActions())); if (from.isSetClusterHardLimitPct()) { to.setClusterHardLimitPct(from.getClusterHardLimitPct()); if (from.isSetClusterSoftLimitPct()) { to.setClusterSoftLimitPct(from.getClusterSoftLimitPct()); if (from.isSetComment()) { to.setComment(from.getComment()); if (from.isSetDataCenter()) { to.setDataCenter(adaptOut(from.getDataCenter())); if (from.isSetDescription()) { to.setDescription(from.getDescription()); if (from.isSetDisks()) { to.setDisks(new V3Disks()); to.getDisks().getDisks().addAll(adaptOut(from.getDisks().getDisks())); if (from.isSetId()) { to.setId(from.getId());
@Override public Quota adapt(V3Quota from) { Quota to = new Quota(); if (from.isSetLinks()) { to.getLinks().addAll(adaptIn(from.getLinks())); to.setActions(adaptIn(from.getActions())); to.setClusterHardLimitPct(from.getClusterHardLimitPct()); to.setClusterSoftLimitPct(from.getClusterSoftLimitPct()); to.setComment(from.getComment()); to.setDataCenter(adaptIn(from.getDataCenter())); to.setDescription(from.getDescription()); to.setDisks(new Disks()); to.getDisks().getDisks().addAll(adaptIn(from.getDisks().getDisks())); to.setId(from.getId()); to.setHref(from.getHref()); to.setName(from.getName()); to.setStorageHardLimitPct(from.getStorageHardLimitPct()); to.setStorageSoftLimitPct(from.getStorageSoftLimitPct());
@Mapping(from = org.ovirt.engine.core.common.businessentities.Quota.class, to = Quota.class) public static Quota map(org.ovirt.engine.core.common.businessentities.Quota template, Quota model) { Quota ret = (model==null) ? new Quota() : model; if (template.getId()!=null) { ret.setId(template.getId().toString()); } if (template.getQuotaName()!=null) { ret.setName(template.getQuotaName()); } if (template.getDescription()!=null) { ret.setDescription(template.getDescription()); } if (template.getStoragePoolId()!=null) { if (ret.getDataCenter()==null) { ret.setDataCenter(new DataCenter()); } ret.getDataCenter().setId(template.getStoragePoolId().toString()); } ret.setClusterHardLimitPct(template.getGraceClusterPercentage()); ret.setStorageHardLimitPct(template.getGraceStoragePercentage()); ret.setClusterSoftLimitPct(template.getThresholdClusterPercentage()); ret.setStorageSoftLimitPct(template.getThresholdStoragePercentage()); return ret; }
private static void map(QuotaStorageLimit model, QuotaStorage quotaStorage, String storageDomainId, String dataCenterId, String quotaId) { model.setQuota(new Quota()); model.getQuota().setId(quotaId); model.getQuota().setDataCenter(new DataCenter()); model.getQuota().getDataCenter().setId(dataCenterId); if (storageDomainId != null) { model.setStorageDomain(new StorageDomain()); model.getStorageDomain().setId(storageDomainId); } if (quotaStorage.getStorageSizeGB() != null) { model.setLimit(quotaStorage.getStorageSizeGB()); } if (quotaStorage.getStorageSizeGBUsage() != null) { model.setUsage(quotaStorage.getStorageSizeGBUsage()); } }
/** * Create an instance of {@link Quota } * */ public Quota createQuota() { return new Quota(); }
public static void validateAdd(Quota quota) { if (quota == null) { throw new ValidationException("Parameter 'quota' is mandatory but was not provided."); } if (quota.getName()==null) { throw new ValidationException("Parameter 'quota.name' is mandatory but was not provided."); } }
private static void map(QuotaClusterLimit template, QuotaCluster quotaCluster, String clusterId, String dataCenterId, String quotaId) { template.setQuota(new Quota()); template.getQuota().setId(quotaId); template.getQuota().setDataCenter(new DataCenter()); template.getQuota().getDataCenter().setId(dataCenterId); if (clusterId != null) { template.setCluster(new Cluster()); template.getCluster().setId(clusterId); } if (quotaCluster.getMemSizeMB() != null) { // show GB instead of MB (ignore -1) double value = quotaCluster.getMemSizeMB() == -1 ? quotaCluster.getMemSizeMB().doubleValue() : quotaCluster.getMemSizeMB().doubleValue() / 1024.0; template.setMemoryLimit(value); } if (quotaCluster.getMemSizeMBUsage() != null) { template.setMemoryUsage(quotaCluster.getMemSizeMBUsage() / 1024.0); } if (quotaCluster.getVirtualCpu() != null) { template.setVcpuLimit(quotaCluster.getVirtualCpu()); } if (quotaCluster.getVirtualCpuUsage() != null) { template.setVcpuUsage(quotaCluster.getVirtualCpuUsage()); } }
Quota quota = new Quota(); quota.setId(entity.getQuotaId().toString()); quota.setDataCenter(new DataCenter()); quota.getDataCenter().setId(entity.getStoragePoolId().toString());