for (Branding b : sub.getBranding()) {
newPool.getBranding().add(new Branding(b.getProductId(), b.getType(),
b.getName()));
}
newPool.setSourceSubscription(new SourceSubscription(sub.getId(), "master"));
ProductAttribute virtAtt = sub.getProduct().getAttribute("virt_only");
// note: the product attributes are getting copied above, but the following will
// make virt_only a pool attribute. That makes the pool explicitly virt_only to
// subscription manager and any other downstream comsumer.
if (virtAtt != null && virtAtt.getValue() != null &&
!virtAtt.getValue().equals("")) {
newPool.addAttribute(new org.candlepin.model.PoolAttribute("virt_only",
virtAtt.getValue()));
}
pools.add(newPool);
}
boolean hostLimited = attributes.containsKey("host_limited") &&
attributes.get("host_limited").equals("true");
// Check if we need to create a virt-only pool for this subscription:
if (attributes.containsKey("virt_limit") && !config.getBoolean(ConfigProperties.STANDALONE) &&
!hostLimited && !hasBonusPool(existingPools)) {
HashMap<String, String> virtAttributes = new HashMap<String, String>();
virtAttributes.put("virt_only", "true");
virtAttributes.put("pool_derived", "true");
virtAttributes.put("physical_only", "false");
// Make sure the virt pool does not have a virt_limit,
// otherwise this will recurse infinitely
virtAttributes.put("virt_limit", "0");
String virtQuantity = getVirtQuantity(attributes.get("virt_limit"), quantity);
if (virtQuantity != null) {
Pool derivedPool = helper.createPool(sub, sub.getProduct().getId(),
virtQuantity, virtAttributes);
// Using derived here because only one derived pool
// is created for this subscription
derivedPool.setSourceSubscription(
new SourceSubscription(sub.getId(), "derived"));
pools.add(derivedPool);
}
}
return pools;
}