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 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