• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python mongoctl_logging.log_verbose函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mongoctl_logging.log_verbose函数的典型用法代码示例。如果您正苦于以下问题:Python log_verbose函数的具体用法?Python log_verbose怎么用?Python log_verbose使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了log_verbose函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setup_server_users

def setup_server_users(server):
    """
    Seeds all users returned by get_seed_users() IF there are no users seed yet
    i.e. system.users collection is empty
    """
    """if not should_seed_users(server):
        log_verbose("Not seeding users for server '%s'" % server.id)
        return"""

    log_info("Checking if there are any users that need to be added for "
             "server '%s'..." % server.id)

    seed_users = server.get_seed_users()

    count_new_users = 0

    # Note: If server member of a replica then don't setup admin
    # users because primary server will do that at replinit

    # Now create admin ones
    if not server.is_slave():
        count_new_users += setup_server_admin_users(server)

    for dbname, db_seed_users in seed_users.items():
        # create the admin ones last so we won't have an auth issue
        if dbname in ["admin", "local"]:
            continue
        count_new_users += setup_server_db_users(server, dbname, db_seed_users)


    if count_new_users > 0:
        log_info("Added %s users." % count_new_users)
    else:
        log_verbose("Did not add any new users.")
开发者ID:zenglzh,项目名称:mongoctl,代码行数:34,代码来源:users.py


示例2: validate_repositories

def validate_repositories():
    global __repos_validated__
    if not __repos_validated__:
        if not(has_file_repository() or has_db_repository() or has_commandline_servers_or_clusters()):
            log_verbose("******* WARNING!\nNo fileRepository or databaseRepository configured."
                        "\n*******")
        __repos_validated__ = True
开发者ID:hongchoi,项目名称:mongoctl,代码行数:7,代码来源:repository.py


示例3: get_mongoctl_database

def get_mongoctl_database():

    # if not using db then return
    if not has_db_repository():
        return

    global __mongoctl_db__

    if __mongoctl_db__ is not None:
        return __mongoctl_db__

    log_verbose("Connecting to mongoctl db...")
    try:

        (conn, dbname) = _db_repo_connect()

        __mongoctl_db__ = conn[dbname]
        return __mongoctl_db__
    except Exception, e:
        log_exception(e)
        __mongoctl_db__ = "OFFLINE"
        log_warning("\n*************\n"
                    "Will not be using database repository for configurations"
                    " at this time!"
                    "\nREASON: Could not establish a database"
                    " connection to mongoctl's database repository."
                    "\nCAUSE: %s."
                    "\n*************" % e)
开发者ID:Mat-Loz,项目名称:mongoctl,代码行数:28,代码来源:repository.py


示例4: get_download_url

    def get_download_url(self, mongodb_version, mongodb_edition):
        template_args = get_template_args(mongodb_version, mongodb_edition)
        platform_spec = template_args["platform_spec"]
        os_dist_name = template_args["os_dist_name"]
        os_dist_version_no_dots = template_args["os_dist_version_no_dots"]
        os_name = template_args["os_name"]

        version_info = make_version_info(mongodb_version)
        if mongodb_edition == MongoDBEdition.COMMUNITY:
            archive_name = "mongodb-%s-%s.tgz" % (platform_spec,
                                                  mongodb_version)
            domain = "fastdl.mongodb.org"
        # community ssl from mongodb.org are supported only for version >= 3.0
        elif mongodb_edition == MongoDBEdition.COMMUNITY_SSL:
            if version_info >= VERSION_3_0:
                # Platforms that lack OS dist data (eg OS X) apparently don't
                # need it
                dist_bits = ""
                # Ones that have it, need it injected, i.e.
                # 'mongodb-linux-x86_64-debian71-3.2.9.tgz
                if os_dist_name is not None:
                    dist_bits = "-{0}{1}".format(
                        os_dist_name,
                        os_dist_version_no_dots
                    )
                archive_name = "mongodb-{0}{1}-{2}.tgz".format(
                    platform_spec,
                    dist_bits,
                    mongodb_version
                )
                domain = "fastdl.mongodb.org"
            else:
                return None
        elif mongodb_edition == MongoDBEdition.ENTERPRISE:
            if version_info and version_info >= VERSION_2_6_1:
                domain = "downloads.10gen.com"
                rel_name = "enterprise"
            else:
                rel_name = "subscription"
                domain = "downloads.mongodb.com"

            archive_name = ("mongodb-%s-%s-%s%s-%s.tgz" %
                            (platform_spec, rel_name, os_dist_name,
                             os_dist_version_no_dots,
                             mongodb_version))

        else:
            raise MongoctlException("Unsupported edition '%s'" %
                                    mongodb_edition)

        url = "http://%s/%s/%s" % (domain, os_name, archive_name)
        log_verbose("Download url for MongoDB %s (%s edition) OS %s, dist '%s': %s" %
                    (mongodb_version, mongodb_edition, os_name, os_dist_name, url))

        return url
开发者ID:mongolab,项目名称:mongoctl,代码行数:55,代码来源:binary_repo.py


示例5: should_seed_db_users

def should_seed_db_users(server, dbname):
    log_verbose("See if we should seed users for database '%s'" % dbname)
    try:
        connection = server.get_db_connection()
        if connection[dbname]['system.users'].find_one():
            return False
        else:
            return True
    except Exception, e:
        log_exception(e)
        return False
开发者ID:zenglzh,项目名称:mongoctl,代码行数:11,代码来源:users.py


示例6: prepend_global_admin_user

def prepend_global_admin_user(other_users, server):
    """
    When making lists of administrative users -- e.g., seeding a new server --
    it's useful to put the credentials supplied on the command line at the head
    of the queue.
    """
    cred0 = get_global_login_user(server, "admin")
    if cred0 and cred0["username"] and cred0["password"]:
        log_verbose("Seeding : CRED0 to the front of the line!")
        return [cred0] + other_users if other_users else [cred0]
    else:
        return other_users
开发者ID:zenglzh,项目名称:mongoctl,代码行数:12,代码来源:users.py


示例7: should_seed_db_users

def should_seed_db_users(server, dbname):
    log_verbose("See if we should seed users for database '%s'" % dbname)
    try:
        connection = server.get_db_connection()
        if connection[dbname]['system.users'].find_one():
            return False
        else:
            return True
    except Exception, e:
        log_exception(e)
        if is_auth_error(e) and dbname == "admin" and server.try_on_auth_failures():
            return True
        return False
开发者ID:nowshad-amin,项目名称:mongoctl,代码行数:13,代码来源:users.py


示例8: should_seed_users

def should_seed_users(server):
    log_verbose("See if we should seed users for server '%s'" %
                server.id)
    try:
        connection = server.get_db_connection()
        dbnames = connection.database_names()
        for dbname in dbnames:
            if connection[dbname]['system.users'].find_one():
                return False
        return True
    except Exception, e:
        log_exception(e)
        return False
开发者ID:zenglzh,项目名称:mongoctl,代码行数:13,代码来源:users.py


示例9: download_mongodb_binary

def download_mongodb_binary(mongodb_version, mongodb_edition,
                            destination=None):
    destination = destination or os.getcwd()

    log_info("Looking for a download for MongoDB ('%s', '%s')" %
             (mongodb_version, mongodb_edition))

    for repo in get_registered_binary_repositories():
        log_verbose("Trying from '%s' binary repository..." % repo.name)
        if mongodb_edition in repo.supported_editions:
            try:
                if repo.file_exists(mongodb_version, mongodb_edition):
                    return repo.download_file(mongodb_version, mongodb_edition,
                                              destination=destination)
                else:
                    log_verbose("Repository '%s' doesnt have this version. Skipping..." % repo.name)
                    continue
            except FileNotInRepoError, e:
                log_verbose("No mongodb binary (version: '%s', edition: '%s' )"
                            "found in repo '%s'" %
                            (mongodb_version, mongodb_edition, repo.name))
        else:
            log_verbose("Binary repository '%s' does not support edition '%s'."
                        " Supported editions %s" %
                        (repo.name, mongodb_edition, repo.supported_editions))
开发者ID:hongchoi,项目名称:mongoctl,代码行数:25,代码来源:binary_repo.py


示例10: setup_db_users

def setup_db_users(server, db, db_users):
    count_new_users = 0
    for user in db_users :
        username = user['username']
        log_verbose("adding user '%s' to db '%s'" % (username, db.name))
        password = user.get('password')
        if not password:
            password = read_seed_password(db.name, username)

        _mongo_add_user(server, db, username, password)
        # if there is no login user for this db then set it to this new one
        db_login_user = server.get_login_user(db.name)
        if not db_login_user:
            server.set_login_user(db.name, username, password)
            # inc new users
        count_new_users += 1

    return count_new_users
开发者ID:zenglzh,项目名称:mongoctl,代码行数:18,代码来源:users.py


示例11: setup_server_admin_users

def setup_server_admin_users(server):

    admin_users = server.get_admin_users()
    if server.is_auth():
        admin_users = prepend_global_admin_user(admin_users, server)

    if admin_users is None or len(admin_users) < 1:
        log_verbose("No users configured for admin DB...")
        return 0

    root_user_added = setup_root_admin_user(server, admin_users)
    if not root_user_added:
        log_verbose("Not seeding users for database 'admin'")
        return 0

    log_verbose("Checking setup for other admin users...")
    count_new_users = 1
    try:
        admin_db = server.get_db("admin")
        count_new_users += setup_db_users(server, admin_db, admin_users[1:])
        return count_new_users
    except Exception, e:
        log_exception(e)
        raise MongoctlException(
            "Error while setting up admin users on server '%s'."
            "\n Cause: %s" % (server.id, e))
开发者ID:mongolab,项目名称:mongoctl,代码行数:26,代码来源:users.py


示例12: setup_server_db_users

def setup_server_db_users(server, dbname, db_users):
    log_verbose("Checking if there are any users that needs to be added for " "database '%s'..." % dbname)

    if not should_seed_db_users(server, dbname):
        log_verbose("Not seeding users for database '%s'" % dbname)
        return 0

    db = server.get_db(dbname)

    try:
        any_new_user_added = setup_db_users(server, db, db_users)
        if not any_new_user_added:
            log_verbose("No new users added for database '%s'" % dbname)
        return any_new_user_added
    except Exception, e:
        log_exception(e)
        raise MongoctlException(
            "Error while setting up users for '%s'" " database on server '%s'." "\n Cause: %s" % (dbname, server.id, e)
        )
开发者ID:hongchoi,项目名称:mongoctl,代码行数:19,代码来源:users.py


示例13: setup_server_admin_users

def setup_server_admin_users(server):

    if not should_seed_db_users(server, "admin"):
        log_verbose("Not seeding users for database 'admin'")
        return 0

    admin_users = server.get_admin_users()
    if server.is_auth():
        admin_users = prepend_global_admin_user(admin_users, server)

    if (admin_users is None or len(admin_users) < 1):
        log_verbose("No users configured for admin DB...")
        return 0

    log_verbose("Checking setup for admin users...")
    count_new_users = 0
    try:
        admin_db = server.get_db("admin")

        # potentially create the 1st admin user
        count_new_users += setup_db_users(server, admin_db, admin_users[0:1])

        # the 1st-time init case:
        # BEFORE adding 1st admin user, auth. is not possible --
        #       only localhost cxn gets a magic pass.
        # AFTER adding 1st admin user, authentication is required;
        #      so, to be sure we now have authenticated cxn, re-pull admin db:
        admin_db = server.get_db("admin")

        # create the rest of the users
        count_new_users += setup_db_users(server, admin_db, admin_users[1:])
        return count_new_users
    except Exception, e:
        log_exception(e)
        raise MongoctlException(
            "Error while setting up admin users on server '%s'."
            "\n Cause: %s" % (server.id, e))
开发者ID:zenglzh,项目名称:mongoctl,代码行数:37,代码来源:users.py


示例14: do_main

def do_main(args):
    init_mongoctl_signal_handler()

    header = """
-------------------------------------------------------------------------------------------
  __ _  ___  ___  ___ ____  ____/ /_/ /
 /  ' \/ _ \/ _ \/ _ `/ _ \/ __/ __/ / 
/_/_/_/\___/_//_/\_, /\___/\__/\__/_/  
                /___/ 
-------------------------------------------------------------------------------------------
   """

    # Parse options
    parser = get_mongoctl_cmd_parser()

    if len(args) < 1:
        print(header)
        parser.print_help()
        return

    # Parse the arguments and call the function of the selected cmd
    parsed_args = parser.parse_args(args)

    # turn on verbose if specified
    if namespace_get_property(parsed_args, "mongoctlVerbose"):
        turn_logging_verbose_on()

    # set interactive mode
    non_interactive = namespace_get_property(parsed_args, "noninteractive")
    non_interactive = False if non_interactive is None else non_interactive

    set_interactive_mode(not non_interactive)

    if not is_interactive_mode():
        log_verbose("Running with noninteractive mode")

    # set global prompt value
    yes_all = parsed_args.yesToEverything
    no_all = parsed_args.noToEverything

    if yes_all and no_all:
        raise MongoctlException("Cannot have --yes and --no at the same time. " "Please choose either --yes or --no")
    elif yes_all:
        say_yes_to_everything()
    elif no_all:
        say_no_to_everything()

    # set the global SSL_OFF flag
    if parsed_args.clientSslMode:
        objects.server.set_client_ssl_mode(parsed_args.clientSslMode)

    # set the global USE_ALT_ADDRESS field
    if parsed_args.useAltAddress:
        use_alt_address = parsed_args.useAltAddress
        log_info("Using alternative address '%s'..." % use_alt_address)
        objects.server.USE_ALT_ADDRESS = use_alt_address

    # set conf root if specified
    if parsed_args.configRoot is not None:
        config.set_config_root(parsed_args.configRoot)
    elif os.getenv(CONF_ROOT_ENV_VAR) is not None:
        config.set_config_root(os.getenv(CONF_ROOT_ENV_VAR))

    # set cmd arg servers/clusters
    if parsed_args.servers or parsed_args.clusters:
        repository.set_commandline_servers_and_clusters(parsed_args.servers, parsed_args.clusters)

    # get the function to call from the parser framework
    command_function = parsed_args.func

    # parse global login if present
    username = namespace_get_property(parsed_args, "username")

    password = namespace_get_property(parsed_args, "password")
    server_id = namespace_get_property(parsed_args, SERVER_ID_PARAM)
    parse_global_login_user_arg(username, password, server_id)

    if server_id is not None:
        # check if assumeLocal was specified
        assume_local = namespace_get_property(parsed_args, "assumeLocal")
        if assume_local:
            objects.server.assume_local_server(server_id)
    # execute command
    log_info("")
    return command_function(parsed_args)
开发者ID:mongolab,项目名称:mongoctl,代码行数:85,代码来源:mongoctl.py


示例15: __do_execute

def __do_execute(args):
    header = """
-------------------------------------------------------------------------------------------
  __ _  ___  ___  ___ ____  ____/ /_/ /
 /  ' \/ _ \/ _ \/ _ `/ _ \/ __/ __/ / 
/_/_/_/\___/_//_/\_, /\___/\__/\__/_/  
                /___/ 
-------------------------------------------------------------------------------------------
   """
    global parser

    if len(args) < 1:
        print(header)
        parser.print_help()
        return

    # Parse the arguments and call the function of the selected cmd
    parsed_args = parser.parse_args(args)

    # turn on verbose if specified
    if namespace_get_property(parsed_args, "mongoctlVerbose"):
        turn_logging_verbose_on()

    # set interactive mode
    non_interactive = namespace_get_property(parsed_args, 'noninteractive')
    non_interactive = False if non_interactive is None else non_interactive

    set_interactive_mode(not non_interactive)

    if not is_interactive_mode():
        log_verbose("Running with noninteractive mode")

    # set global prompt value
    yes_all = parsed_args.yesToEverything
    no_all = parsed_args.noToEverything

    if yes_all and no_all:
        raise MongoctlException("Cannot have --yes and --no at the same time. "
                                "Please choose either --yes or --no")
    elif yes_all:
        say_yes_to_everything()
    elif no_all:
        say_no_to_everything()

    # set conf root if specified
    if parsed_args.configRoot is not None:
        config._set_config_root(parsed_args.configRoot)
    elif os.getenv(CONF_ROOT_ENV_VAR) is not None:
        config._set_config_root(os.getenv(CONF_ROOT_ENV_VAR))

    # get the function to call from the parser framework
    command_function = parsed_args.func

    # parse global login if present
    username = namespace_get_property(parsed_args, "username")
    password = namespace_get_property(parsed_args, "password")
    server_id = namespace_get_property(parsed_args, SERVER_ID_PARAM)
    parse_global_login_user_arg(username, password, server_id)

    if server_id is not None:
        # check if assumeLocal was specified
        assume_local = namespace_get_property(parsed_args, "assumeLocal")
        if assume_local:
            objects.server.assume_local_server(server_id)
    # execute command
    log_info("")
    return command_function(parsed_args)
开发者ID:richardxx,项目名称:mongoctl-service,代码行数:67,代码来源:mongoctl.py


示例16: setup_cluster_users

def setup_cluster_users(cluster, primary_server):
    log_verbose("Setting up cluster '%s' users using primary server '%s'" %
                (cluster.id, primary_server.id))
    return setup_server_users(primary_server)
开发者ID:zenglzh,项目名称:mongoctl,代码行数:4,代码来源:users.py


示例17: should_seed_db_users

def should_seed_db_users(server, dbname):
    log_verbose("See if we should seed users for database '%s'" % dbname)
    return not list_database_users(server, server.get_db(dbname))
开发者ID:mongolab,项目名称:mongoctl,代码行数:3,代码来源:users.py


示例18: setup_server_local_users

            "\n Cause: %s" % (server.id, e))

###############################################################################
def setup_server_local_users(server):

    seed_local_users = False
    try:
        local_db = server.get_db("local", retry=False)
        if not local_db['system.users'].find_one():
            seed_local_users = True
    except Exception, e:
        log_exception(e)
        pass

    if not seed_local_users:
        log_verbose("Not seeding users for database 'local'")
        return 0

    try:
        local_users = server.get_db_seed_users("local")
        if server.is_auth():
            local_users = prepend_global_admin_user(local_users, server)

        if local_users:
            return setup_db_users(server, local_db, local_users)
        else:
            return 0
    except Exception, e:
        log_exception(e)
        raise MongoctlException(
            "Error while setting up local users on server '%s'."
开发者ID:zenglzh,项目名称:mongoctl,代码行数:31,代码来源:users.py



注:本文中的mongoctl_logging.log_verbose函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mongodb.MongoDBCollector类代码示例发布时间:2022-05-27
下一篇:
Python utils.resolve_path函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap