Exemplo n.º 1
0
def check_status(force_signal):

    if force_signal is not None:
        debug("forcing status signal from cli arg")
        return force_signal

    if ClassicCheck().is_registered_with_classic():
        debug("System is already registered to another entitlement system")
        return RHN_CLASSIC

    if not ConsumerIdentity.existsAndValid():
        debug("The system is not currently registered.")
        return RHSM_REGISTRATION_REQUIRED

    facts = Facts()
    sorter = CertSorter(certdirectory.ProductDirectory(),
                        certdirectory.EntitlementDirectory(),
                        facts.get_facts())

    if len(sorter.unentitled_products.keys()) > 0 or len(
            sorter.expired_products.keys()) > 0:
        debug("System has one or more certificates that are not valid")
        debug(sorter.unentitled_products.keys())
        debug(sorter.expired_products.keys())
        return RHSM_EXPIRED
    elif len(sorter.partially_valid_products) > 0:
        debug("System has one or more partially entitled products")
        return RHSM_PARTIALLY_VALID
    elif in_warning_period(sorter):
        debug("System has one or more entitlements in their warning period")
        return RHSM_WARNING
    else:
        debug("System entitlements appear valid")
        return RHSM_VALID
Exemplo n.º 2
0
    def __init__(self, product_dir=None, entitlement_dir=None):

        self.product_directory = product_dir
        if not product_dir:
            self.product_directory = certdirectory.ProductDirectory()

        self.entitlement_directory = entitlement_dir
        if not entitlement_dir:
            self.entitlement_directory = certdirectory.EntitlementDirectory()
Exemplo n.º 3
0
    def __init__(self, ent_dir=None, prod_dir=None):
        self.facts = {}

        self.entitlement_dir = ent_dir or certdirectory.EntitlementDirectory()
        self.product_dir = prod_dir or certdirectory.ProductDirectory()
        # see bz #627962
        # we would like to have this info, but for now, since it
        # can change constantly on laptops, it makes for a lot of
        # fact churn, so we report it, but ignore it as an indicator
        # that we need to update
        self.graylist = ['cpu.cpu_mhz']
Exemplo n.º 4
0
def getInstalledProductStatus(product_directory=None,
                              entitlement_directory=None,
                              facts=None):
    """
     Returns the Installed products and their subscription states
    """
    # allow us to stub these out for testing
    if product_directory is None:
        product_directory = certdirectory.ProductDirectory()
    if entitlement_directory is None:
        entitlement_directory = certdirectory.EntitlementDirectory()
    if facts is None:
        facts = Facts().get_facts()

    product_status = []

    sorter = CertSorter(product_directory, entitlement_directory, facts)

    for installed_product in sorter.installed_products:
        product_cert = sorter.installed_products[installed_product]
        for product in product_cert.getProducts():
            begin = ""
            end = ""
            calculator = ValidProductDateRangeCalculator(sorter)
            prod_status_range = calculator.calculate(product.getHash())
            if prod_status_range:
                # Format the date in user's local time as the date
                # range is returned in GMT.
                begin = formatDate(prod_status_range.begin())
                end = formatDate(prod_status_range.end())
            data = (product.getName(), installed_product, product.getVersion(),
                    product.getArch(), sorter.get_status(product.getHash()),
                    begin, end)
            product_status.append(data)

    return product_status
Exemplo n.º 5
0
def getInstalledProductHashMap():
    products = certdirectory.ProductDirectory().list()
    phash = {}
    for product in products:
        phash[product.getProduct().getName()] = product.getProduct().getHash()
    return phash