當前位置: 首頁>>代碼示例>>Python>>正文


Python checks.run_mysql_checks方法代碼示例

本文整理匯總了Python中charmhelpers.contrib.hardening.mysql.checks.run_mysql_checks方法的典型用法代碼示例。如果您正苦於以下問題:Python checks.run_mysql_checks方法的具體用法?Python checks.run_mysql_checks怎麽用?Python checks.run_mysql_checks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在charmhelpers.contrib.hardening.mysql.checks的用法示例。


在下文中一共展示了checks.run_mysql_checks方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: harden

# 需要導入模塊: from charmhelpers.contrib.hardening.mysql import checks [as 別名]
# 或者: from charmhelpers.contrib.hardening.mysql.checks import run_mysql_checks [as 別名]
def harden(overrides=None):
    """Hardening decorator.

    This is the main entry point for running the hardening stack. In order to
    run modules of the stack you must add this decorator to charm hook(s) and
    ensure that your charm config.yaml contains the 'harden' option set to
    one or more of the supported modules. Setting these will cause the
    corresponding hardening code to be run when the hook fires.

    This decorator can and should be applied to more than one hook or function
    such that hardening modules are called multiple times. This is because
    subsequent calls will perform auditing checks that will report any changes
    to resources hardened by the first run (and possibly perform compliance
    actions as a result of any detected infractions).

    :param overrides: Optional list of stack modules used to override those
                      provided with 'harden' config.
    :returns: Returns value returned by decorated function once executed.
    """
    def _harden_inner1(f):
        log("Hardening function '%s'" % (f.__name__), level=DEBUG)

        def _harden_inner2(*args, **kwargs):
            RUN_CATALOG = OrderedDict([('os', run_os_checks),
                                       ('ssh', run_ssh_checks),
                                       ('mysql', run_mysql_checks),
                                       ('apache', run_apache_checks)])

            enabled = overrides or (config("harden") or "").split()
            if enabled:
                modules_to_run = []
                # modules will always be performed in the following order
                for module, func in six.iteritems(RUN_CATALOG):
                    if module in enabled:
                        enabled.remove(module)
                        modules_to_run.append(func)

                if enabled:
                    log("Unknown hardening modules '%s' - ignoring" %
                        (', '.join(enabled)), level=WARNING)

                for hardener in modules_to_run:
                    log("Executing hardening module '%s'" %
                        (hardener.__name__), level=DEBUG)
                    hardener()
            else:
                log("No hardening applied to '%s'" % (f.__name__), level=DEBUG)

            return f(*args, **kwargs)
        return _harden_inner2

    return _harden_inner1 
開發者ID:openstack,項目名稱:charm-swift-proxy,代碼行數:54,代碼來源:harden.py


注:本文中的charmhelpers.contrib.hardening.mysql.checks.run_mysql_checks方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。