//virtual pools
allOwnerPools.remove(ent.getPool());
}
List<Pool> filteredPools = new LinkedList<Pool>();
ComplianceStatus guestCompliance = complianceRules.getStatus(guest, entitleDate, false);
Set<String> tmpSet = new HashSet<String>();
//we only want to heal red products, not yellow
tmpSet.addAll(guestCompliance.getNonCompliantProducts());
/*Do not attempt to create subscriptions for products that
already have virt_only pools available to the guest */
Set<String> productsToRemove = new HashSet<String>();
for (Pool pool : allOwnerPoolsForGuest) {
if (pool.hasProductAttribute("virt_only") || pool.hasAttribute("virt_only")) {
for (String prodId : tmpSet) {
if (pool.provides(prodId)) {
productsToRemove.add(prodId);
}
}
}
}
tmpSet.removeAll(productsToRemove);
String[] productIds = tmpSet.toArray(new String [] {});
if (log.isDebugEnabled()) {
log.debug("Attempting for products on date: " + entitleDate);
for (String productId : productIds) {
log.debug(" " + productId);
}
}
for (Pool pool : allOwnerPools) {
boolean providesProduct = false;
// Would parse the int here, but it can be 'unlimited'
// and we only need to check that it's non-zero
if (pool.hasProductAttribute("virt_limit") &&
!pool.getProductAttribute("virt_limit").getValue().equals("0")) {
for (String productId : productIds) {
// If this is a derived pool, we need to see if the derived product
// provides anything for the guest, otherwise we use the parent.
if (pool.providesDerived(productId)) {
providesProduct = true;
break;
}
}
}
if (providesProduct) {
ValidationResult result = enforcer.preEntitlement(host,
pool, 1, CallerType.BEST_POOLS);
if (result.hasErrors() || result.hasWarnings()) {
// Just keep the last one around, if we need it
failedResult = result;
if (log.isDebugEnabled()) {
log.debug("Pool filtered from candidates due to rules " +
"failure: " +
pool.getId());
}
}
else {
filteredPools.add(pool);
}
}
}
// Only throw refused exception if we actually hit the rules:
if (filteredPools.size() == 0 && failedResult != null) {
throw new EntitlementRefusedException(failedResult);
}
ComplianceStatus hostCompliance = complianceRules.getStatus(host, entitleDate, false);
List<PoolQuantity> enforced = autobindRules.selectBestPools(host,
productIds, filteredPools, hostCompliance, serviceLevelOverride,
poolCurator.retrieveServiceLevelsForOwner(owner, true), true);
return enforced;