本文整理汇总了Python中mongoctl.mongoctl_logging.log_info函数的典型用法代码示例。如果您正苦于以下问题:Python log_info函数的具体用法?Python log_info怎么用?Python log_info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log_info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_cluster_command
def show_cluster_command(parsed_options):
cluster = repository.lookup_cluster(parsed_options.cluster)
if cluster is None:
raise MongoctlException("Could not find cluster '%s'." %
parsed_options.cluster)
log_info("Configuration for cluster '%s':" % parsed_options.cluster)
print cluster
示例2: do_mongo_restore
def do_mongo_restore(source,
host=None,
port=None,
dbpath=None,
database=None,
username=None,
password=None,
version_info=None,
restore_options=None):
# create restore command with host and port
restore_cmd = [get_mongo_restore_executable(version_info)]
if host:
restore_cmd.extend(["--host", host])
if port:
restore_cmd.extend(["--port", str(port)])
# dbpath
if dbpath:
restore_cmd.extend(["--dbpath", dbpath])
# database
if database:
restore_cmd.extend(["-d", database])
# username and password
if username:
restore_cmd.extend(["-u", username, "-p"])
if password:
restore_cmd.append(password)
# ignore authenticationDatabase option is version_info is less than 2.4.0
if (restore_options and "authenticationDatabase" in restore_options and
version_info and version_info < make_version_info("2.4.0")):
restore_options.pop("authenticationDatabase", None)
# ignore restoreDbUsersAndRoles option is version_info is less than 2.6.0
if (restore_options and "restoreDbUsersAndRoles" in restore_options and
version_info and version_info < make_version_info("2.6.0")):
restore_options.pop("restoreDbUsersAndRoles", None)
# append shell options
if restore_options:
restore_cmd.extend(options_to_command_args(restore_options))
# pass source arg
restore_cmd.append(source)
cmd_display = restore_cmd[:]
# mask user/password
if username:
cmd_display[cmd_display.index("-u") + 1] = "****"
if password:
cmd_display[cmd_display.index("-p") + 1] = "****"
# execute!
log_info("Executing command: \n%s" % " ".join(cmd_display))
call_command(restore_cmd, bubble_exit_code=True)
示例3: show_server_command
def show_server_command(parsed_options):
server = repository.lookup_server(parsed_options.server)
if server is None:
raise MongoctlException("Could not find server '%s'." %
parsed_options.server)
log_info("Configuration for server '%s':" % parsed_options.server)
print server
示例4: set_runtime_parameter_cmd
def set_runtime_parameter_cmd(self, name, value):
log_info("Setting runtime parameter '%s' to '%s', for server '%s'..." %
(name, value, self.id))
cmd = {
"setParameter": 1,
name: value
}
self.db_command(cmd, "admin")
示例5: configure_sharded_cluster
def configure_sharded_cluster(self):
sh_list = self.list_shards()
if sh_list and sh_list.get("shards"):
log_info("Shard cluster already configured. Will only be adding"
" new shards as needed...")
for shard_member in self.shards:
self.add_shard(shard_member.get_shard())
示例6: do_mongo_dump
def do_mongo_dump(host=None,
port=None,
dbpath=None,
database=None,
username=None,
password=None,
version_info=None,
dump_options=None):
# create dump command with host and port
dump_cmd = [get_mongo_dump_executable(version_info)]
if host:
dump_cmd.extend(["--host", host])
if port:
dump_cmd.extend(["--port", str(port)])
# dbpath
if dbpath:
dump_cmd.extend(["--dbpath", dbpath])
# database
if database:
dump_cmd.extend(["-d", database])
# username and password
if username:
dump_cmd.extend(["-u", username, "-p"])
if password:
dump_cmd.append(password)
# ignore authenticationDatabase option is version_info is less than 2.4.0
if (dump_options and "authenticationDatabase" in dump_options and
version_info and version_info < VersionInfo("2.4.0")):
dump_options.pop("authenticationDatabase", None)
# ignore dumpDbUsersAndRoles option is version_info is less than 2.6.0
if (dump_options and "dumpDbUsersAndRoles" in dump_options and
version_info and version_info < VersionInfo("2.6.0")):
dump_options.pop("dumpDbUsersAndRoles", None)
# append shell options
if dump_options:
dump_cmd.extend(options_to_command_args(dump_options))
cmd_display = dump_cmd[:]
# mask user/password
if username:
cmd_display[cmd_display.index("-u") + 1] = "****"
if password:
cmd_display[cmd_display.index("-p") + 1] = "****"
log_info("Executing command: \n%s" % " ".join(cmd_display))
call_command(dump_cmd, bubble_exit_code=True)
示例7: do_restart_server
def do_restart_server(server, options_override=None):
log_info("Restarting server '%s'..." % server.id)
if server.is_online():
do_stop_server(server)
else:
log_info("Server '%s' is not running." % server.id)
do_start_server(server, options_override)
示例8: extract_archive
def extract_archive(archive_name):
log_info("Extracting %s..." % archive_name)
if not which("tar"):
msg = ("Cannot extract archive.You need to have 'tar' command in your"
" path in order to proceed.")
raise MongoctlException(msg)
tar_cmd = ['tar', 'xvf', archive_name]
call_command(tar_cmd)
示例9: get_environment_variables
def get_environment_variables(self):
env_vars = super(MongodServer, self).get_environment_variables() or {}
# default TCMALLOC_AGGRESSIVE_DECOMMIT as needed if not set
if "TCMALLOC_AGGRESSIVE_DECOMMIT" not in env_vars and self.needs_tcmalloc_aggressive_decommit():
log_info("Defaulting TCMALLOC_AGGRESSIVE_DECOMMIT=y")
env_vars["TCMALLOC_AGGRESSIVE_DECOMMIT"] = "y"
return env_vars
示例10: remove_shard
def remove_shard(self, shard, unsharded_data_dest_id=None, synchronized=False):
log_info("Removing shard '%s' from shardset '%s' " % (shard.id, self.id))
configured_shards = self.list_shards()
log_info("Current configured shards: \n%s" % document_pretty_string(configured_shards))
completed = False
while not completed:
result = self._do_remove_shard(shard, unsharded_data_dest_id)
completed = synchronized and (result["state"] == "completed" or not self.is_shard_configured(shard))
if not completed:
time.sleep(2)
示例11: verify_runtime_parameters
def verify_runtime_parameters(self):
log_info("Verifying runtime params...")
wtcs_gb = self.get_cmd_option("wiredTigerCacheSizeGB")
if wtcs_gb is not None and isinstance(wtcs_gb, float):
wtcs_bytes = int(wtcs_gb * 1024 * 1024 * 1024)
server_status = self.server_status()
if not(server_status and "wiredTiger" in server_status and "cache" in server_status["wiredTiger"] and
"maximum bytes configured" in server_status["wiredTiger"]["cache"] and
server_status["wiredTiger"]["cache"]["maximum bytes configured"] == wtcs_bytes):
raise MongoctlException("CONFIG ERROR: wiredTigerCacheSizeGB was not applied")
log_info("Runtime params verification passed!")
示例12: do_open_mongo_shell_to
def do_open_mongo_shell_to(address,
database=None,
username=None,
password=None,
server_version=None,
shell_options=None,
js_files=None,
ssl=False):
# default database to admin
database = database if database else "admin"
shell_options = shell_options or {}
js_files = js_files or []
# override port if specified in --port
if "port" in shell_options:
address = "%s:%s" % (address.split(":")[0], shell_options["port"])
# remove port from options since passing address + port is disallowed in mongo
del shell_options["port"]
connect_cmd = [get_mongo_shell_executable(server_version),
"%s/%s" % (address, database)]
if username:
connect_cmd.extend(["-u",username, "-p"])
if password:
connect_cmd.extend([password])
# append shell options
if shell_options:
connect_cmd.extend(options_to_command_args(shell_options))
# append js files
if js_files:
connect_cmd.extend(js_files)
# ssl options
if ssl and "--ssl" not in connect_cmd:
connect_cmd.append("--ssl")
cmd_display = connect_cmd[:]
# mask user/password
if username:
cmd_display[cmd_display.index("-u") + 1] = "****"
if password:
cmd_display[cmd_display.index("-p") + 1] = "****"
log_info("Executing command: \n%s" % " ".join(cmd_display))
call_command(connect_cmd, bubble_exit_code=True)
示例13: dry_run_configure_cluster
def dry_run_configure_cluster(cluster, force_primary_server_id=None):
log_info("\n************ Dry Run ************\n")
db_command = None
force = force_primary_server_id is not None
if cluster.is_replicaset_initialized():
log_info("Replica set already initialized. "
"Making the replSetReconfig command...")
db_command = cluster.get_replicaset_reconfig_db_command(force=force)
else:
log_info("Replica set has not yet been initialized."
" Making the replSetInitiate command...")
db_command = cluster.get_replicaset_init_all_db_command()
log_info("Executing the following command on the current primary:")
log_info(document_pretty_string(db_command))
示例14: list_servers_command
def list_servers_command(parsed_options):
servers = repository.lookup_all_servers()
if not servers or len(servers) < 1:
log_info("No servers have been configured.")
return
servers = sorted(servers, key=lambda s: s.id)
bar = "-" * 80
print bar
formatter = "%-25s %-40s %s"
print formatter % ("_ID", "DESCRIPTION", "CONNECT TO")
print bar
for server in servers:
print formatter % (server.id, to_string(server.get_description()), to_string(server.get_address_display()))
print "\n"
示例15: download
def download(url):
log_info("Downloading %s..." % url)
if which("curl"):
download_cmd = ['curl', '-O']
if not is_interactive_mode():
download_cmd.append('-Ss')
elif which("wget"):
download_cmd = ['wget']
else:
msg = ("Cannot download file.You need to have 'curl' or 'wget"
"' command in your path in order to proceed.")
raise MongoctlException(msg)
download_cmd.append(url)
call_command(download_cmd)