check_katello_sync.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:check_katello_sync 作者: stdevel 项目源码 文件源码
def check_product(product):
    """
    Checks a product for currency.

    :param product: Product dictionary
    :type product: dict
    """
    global PROD_OK, PROD_WARN, PROD_CRIT

    #check if product unsynced
    if product["last_sync"] == None:
        LOGGER.debug("Product '{0}' ({1}) is UNSYNCED!".format(
            product["label"], product["description"]
        ))
        PROD_CRIT.append(product["label"])
        set_code(2)
    else:
        LOGGER.debug("Product '{0}' ({1}) was synced at {2}".format(
            product["label"], product["description"], product["last_sync"][0:19]
        ))
        last_sync = datetime.strptime(
            product["last_sync"][0:19], "%Y-%m-%d %H:%M:%S"
        )
        delta = datetime.now() - last_sync
        LOGGER.debug("Delta for '{0}' is {1} days".format(
            product["label"], delta.days
        ))
        if delta.days > options.outdated_crit:
            PROD_CRIT.append(product["label"])
            set_code(2)
            LOGGER.debug("Critical product: '{0}'".format(product["label"]))
        if delta.days > options.outdated_warn:
            PROD_WARN.append(product["label"])
            set_code(1)
            LOGGER.debug("Warning product: '{0}'".format(product["label"]))
        else:
            PROD_OK.append(product["label"])
            LOGGER.debug("Ok product: '{0}'".format(product["label"]))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号