def filter_out_overlapping(self, pools): entitled_product_ids_to_certs = self._get_entitled_product_to_cert_map( ) filtered_pools = [] for pool in pools: provided_ids = set( [p['productId'] for p in pool['providedProducts']]) wrapped_pool = PoolWrapper(pool) # NOTE: We may have to check for other types or handle the case of a product with no type in the future if wrapped_pool.get_product_attributes('type')['type'] == 'SVC': provided_ids.add(pool['productId']) overlap = 0 possible_overlap_pids = provided_ids.intersection( list(entitled_product_ids_to_certs.keys())) for productid in possible_overlap_pids: if self._dates_overlap(pool, entitled_product_ids_to_certs[productid]) \ and productid not in self.sorter.partially_valid_products: overlap += 1 else: break if overlap != len(provided_ids) or wrapped_pool.get_stacking_id( ) in self.sorter.partial_stacks: filtered_pools.append(pool) return filtered_pools
def get_available_entitlements(get_all=False, active_on=None, overlapping=False, uninstalled=False, text=None, filter_string=None): """ Returns a list of entitlement pools from the server. The 'all' setting can be used to return all pools, even if the rules do not pass. (i.e. show pools that are incompatible for your hardware) """ columns = [ 'id', 'quantity', 'consumed', 'endDate', 'productName', 'providedProducts', 'productId', 'attributes', 'pool_type', 'service_level', 'service_type', 'suggested', 'contractNumber', 'management_enabled' ] pool_stash = PoolStash() dlist = pool_stash.get_filtered_pools_list(active_on, not get_all, overlapping, uninstalled, text, filter_string) for pool in dlist: pool_wrapper = PoolWrapper(pool) pool['providedProducts'] = pool_wrapper.get_provided_products() if allows_multi_entitlement(pool): pool['multi-entitlement'] = "Yes" else: pool['multi-entitlement'] = "No" support_attrs = pool_wrapper.get_product_attributes("support_level", "support_type") pool['service_level'] = support_attrs['support_level'] pool['service_type'] = support_attrs['support_type'] pool['suggested'] = pool_wrapper.get_suggested_quantity() pool['pool_type'] = pool_wrapper.get_pool_type() pool['management_enabled'] = pool_wrapper.management_enabled() if pool['suggested'] is None: pool['suggested'] = "" # no default, so default is None if key not found data = [_sub_dict(pool, columns) for pool in dlist] for d in data: if int(d['quantity']) < 0: d['quantity'] = _('Unlimited') else: d['quantity'] = str(int(d['quantity']) - int(d['consumed'])) d['endDate'] = format_date(isodate.parse_date(d['endDate'])) del d['consumed'] return data
def get_available_entitlements(facts, get_all=False, active_on=None, overlapping=False, uninstalled=False, text=None): """ Returns a list of entitlement pools from the server. Facts will be updated if appropriate before making the request, to ensure the rules on the server will pass if appropriate. The 'all' setting can be used to return all pools, even if the rules do not pass. (i.e. show pools that are incompatible for your hardware) """ columns = ['id', 'quantity', 'consumed', 'endDate', 'productName', 'providedProducts', 'productId', 'attributes', 'pool_type', 'service_level', 'service_type', 'suggested', 'contractNumber'] pool_stash = PoolStash(Facts(require(ENT_DIR), require(PROD_DIR))) dlist = pool_stash.get_filtered_pools_list(active_on, not get_all, overlapping, uninstalled, text) for pool in dlist: pool_wrapper = PoolWrapper(pool) pool['providedProducts'] = pool_wrapper.get_provided_products() if allows_multi_entitlement(pool): pool['multi-entitlement'] = "Yes" else: pool['multi-entitlement'] = "No" support_attrs = pool_wrapper.get_product_attributes("support_level", "support_type") pool['service_level'] = support_attrs['support_level'] pool['service_type'] = support_attrs['support_type'] pool['suggested'] = pool_wrapper.get_suggested_quantity() pool['pool_type'] = pool_wrapper.get_pool_type() if pool['suggested'] is None: pool['suggested'] = "" # no default, so default is None if key not found data = [_sub_dict(pool, columns) for pool in dlist] for d in data: if int(d['quantity']) < 0: d['quantity'] = _('Unlimited') else: d['quantity'] = str(int(d['quantity']) - int(d['consumed'])) d['endDate'] = format_date(isodate.parse_date(d['endDate'])) del d['consumed'] return data
def getAvailableEntitlements(cpserver, consumer_uuid, facts, get_all=False, active_on=None): """ Returns a list of entitlement pools from the server. Facts will be updated if appropriate before making the request, to ensure the rules on the server will pass if appropriate. The 'all' setting can be used to return all pools, even if the rules do not pass. (i.e. show pools that are incompatible for your hardware) """ columns = [ "id", "quantity", "consumed", "endDate", "productName", "providedProducts", "productId", "attributes", "multi-entitlement", "service_level", "service_type", ] dlist = list_pools(cpserver, consumer_uuid, facts, get_all, active_on) for pool in dlist: pool_wrapper = PoolWrapper(pool) if allows_multi_entitlement(pool): pool["multi-entitlement"] = "Yes" else: pool["multi-entitlement"] = "No" support_attrs = pool_wrapper.get_product_attributes("support_level", "support_type") pool["service_level"] = support_attrs["support_level"] pool["service_type"] = support_attrs["support_type"] data = [_sub_dict(pool, columns) for pool in dlist] for d in data: if int(d["quantity"]) < 0: d["quantity"] = "unlimited" else: d["quantity"] = str(int(d["quantity"]) - int(d["consumed"])) d["endDate"] = formatDate(parseDate(d["endDate"])) del d["consumed"] return data
def get_available_entitlements(cpserver, consumer_uuid, facts, get_all=False, active_on=None): """ Returns a list of entitlement pools from the server. Facts will be updated if appropriate before making the request, to ensure the rules on the server will pass if appropriate. The 'all' setting can be used to return all pools, even if the rules do not pass. (i.e. show pools that are incompatible for your hardware) """ columns = [ 'id', 'quantity', 'consumed', 'endDate', 'productName', 'providedProducts', 'productId', 'attributes', 'multi-entitlement', 'service_level', 'service_type' ] dlist = list_pools(cpserver, consumer_uuid, facts, get_all, active_on) for pool in dlist: pool_wrapper = PoolWrapper(pool) if allows_multi_entitlement(pool): pool['multi-entitlement'] = "Yes" else: pool['multi-entitlement'] = "No" support_attrs = pool_wrapper.get_product_attributes( "support_level", "support_type") pool['service_level'] = support_attrs['support_level'] pool['service_type'] = support_attrs['support_type'] data = [_sub_dict(pool, columns) for pool in dlist] for d in data: if int(d['quantity']) < 0: d['quantity'] = _('Unlimited') else: d['quantity'] = str(int(d['quantity']) - int(d['consumed'])) d['endDate'] = format_date(isodate.parse_date(d['endDate'])) del d['consumed'] return data
def filter_out_overlapping(self, pools): entitled_product_ids_to_certs = self._get_entitled_product_to_cert_map() filtered_pools = [] for pool in pools: provided_ids = set([p['productId'] for p in pool['providedProducts']]) wrapped_pool = PoolWrapper(pool) # NOTE: We may have to check for other types or handle the case of a product with no type in the future if wrapped_pool.get_product_attributes('type')['type'] == 'SVC': provided_ids.add(pool['productId']) overlap = 0 possible_overlap_pids = provided_ids.intersection(list(entitled_product_ids_to_certs.keys())) for productid in possible_overlap_pids: if self._dates_overlap(pool, entitled_product_ids_to_certs[productid]) \ and productid not in self.sorter.partially_valid_products: overlap += 1 else: break if overlap != len(provided_ids) or wrapped_pool.get_stacking_id() in self.sorter.partial_stacks: filtered_pools.append(pool) return filtered_pools
def get_available_entitlements(cpserver, consumer_uuid, facts, get_all=False, active_on=None): """ Returns a list of entitlement pools from the server. Facts will be updated if appropriate before making the request, to ensure the rules on the server will pass if appropriate. The 'all' setting can be used to return all pools, even if the rules do not pass. (i.e. show pools that are incompatible for your hardware) """ columns = ['id', 'quantity', 'consumed', 'endDate', 'productName', 'providedProducts', 'productId', 'attributes', 'multi-entitlement', 'service_level', 'service_type'] dlist = list_pools(cpserver, consumer_uuid, facts, get_all, active_on) for pool in dlist: pool_wrapper = PoolWrapper(pool) if allows_multi_entitlement(pool): pool['multi-entitlement'] = "Yes" else: pool['multi-entitlement'] = "No" support_attrs = pool_wrapper.get_product_attributes("support_level", "support_type") pool['service_level'] = support_attrs['support_level'] pool['service_type'] = support_attrs['support_type'] data = [_sub_dict(pool, columns) for pool in dlist] for d in data: if int(d['quantity']) < 0: d['quantity'] = _('Unlimited') else: d['quantity'] = str(int(d['quantity']) - int(d['consumed'])) d['endDate'] = format_date(isodate.parse_date(d['endDate'])) del d['consumed'] return data
def get_available_entitlements( get_all=False, active_on=None, overlapping=False, uninstalled=False, text=None, filter_string=None, future=None, after_date=None, page=0, items_per_page=0, iso_dates=False, ): """ Returns a list of entitlement pools from the server. The 'all' setting can be used to return all pools, even if the rules do not pass. (i.e. show pools that are incompatible for your hardware) """ columns = [ "id", "quantity", "consumed", "startDate", "endDate", "productName", "providedProducts", "productId", "roles", "attributes", "pool_type", "service_level", "service_type", "usage", "addons", "suggested", "contractNumber", "management_enabled", ] pool_stash = PoolStash() dlist = pool_stash.get_filtered_pools_list( active_on, not get_all, overlapping, uninstalled, text, filter_string, future=future, after_date=after_date, page=page, items_per_page=items_per_page, ) if iso_dates: date_formatter = format_iso8601_date else: date_formatter = format_date for pool in dlist: pool_wrapper = PoolWrapper(pool) pool["providedProducts"] = pool_wrapper.get_provided_products() if allows_multi_entitlement(pool): pool["multi-entitlement"] = "Yes" else: pool["multi-entitlement"] = "No" support_attrs = pool_wrapper.get_product_attributes( "support_level", "support_type", "roles", "usage", "addons" ) pool["service_level"] = support_attrs["support_level"] pool["service_type"] = support_attrs["support_type"] pool["roles"] = support_attrs["roles"] pool["usage"] = support_attrs["usage"] pool["addons"] = support_attrs["addons"] pool["suggested"] = pool_wrapper.get_suggested_quantity() pool["pool_type"] = pool_wrapper.get_pool_type() pool["management_enabled"] = pool_wrapper.management_enabled() if pool["suggested"] is None: pool["suggested"] = "" # no default, so default is None if key not found data = [_sub_dict(pool, columns) for pool in dlist] for d in data: if int(d["quantity"]) < 0: d["quantity"] = _("Unlimited") else: d["quantity"] = str(int(d["quantity"]) - int(d["consumed"])) d["startDate"] = date_formatter(isodate.parse_date(d["startDate"])) d["endDate"] = date_formatter(isodate.parse_date(d["endDate"])) del d["consumed"] return data