def get_filtered_pools_list(self, active_on, incompatible, overlapping, uninstalled, text, filter_string): """ Used for CLI --available filtering cuts down on api calls """ self.all_pools = {} self.compatible_pools = {} if active_on and overlapping: self.sorter = ComplianceManager(active_on) elif not active_on and overlapping: self.sorter = require(CERT_SORTER) if incompatible: for pool in list_pools(require(CP_PROVIDER).get_consumer_auth_cp(), self.identity.uuid, active_on=active_on, filter_string=filter_string): self.compatible_pools[pool['id']] = pool else: # --all has been used for pool in list_pools(require(CP_PROVIDER).get_consumer_auth_cp(), self.identity.uuid, list_all=True, active_on=active_on, filter_string=filter_string): self.all_pools[pool['id']] = pool return self._filter_pools(incompatible, overlapping, uninstalled, False, text)
def refresh(self, active_on): """ Refresh the list of pools from the server, active on the given date. """ if active_on: self.sorter = ComplianceManager(active_on) else: self.sorter = require(CERT_SORTER) self.all_pools = {} self.compatible_pools = {} log.debug("Refreshing pools from server...") for pool in list_pools(require(CP_PROVIDER).get_consumer_auth_cp(), self.identity.uuid, self.facts, active_on=active_on): self.compatible_pools[pool['id']] = pool self.all_pools[pool['id']] = pool # Filter the list of all pools, removing those we know are compatible. # Sadly this currently requires a second query to the server. self.incompatible_pools = {} for pool in list_pools(require(CP_PROVIDER).get_consumer_auth_cp(), self.identity.uuid, self.facts, list_all=True, active_on=active_on): if not pool['id'] in self.compatible_pools: self.incompatible_pools[pool['id']] = pool self.all_pools[pool['id']] = pool self.subscribed_pool_ids = self._get_subscribed_pool_ids() # In the gui, cache all pool types so when we attach new ones # we can avoid more api calls require(POOLTYPE_CACHE).update_from_pools(self.all_pools) log.debug("found %s pools:" % len(self.all_pools)) log.debug(" %s compatible" % len(self.compatible_pools)) log.debug(" %s incompatible" % len(self.incompatible_pools)) log.debug(" %s already subscribed" % len(self.subscribed_pool_ids))