本文整理汇总了Python中remote_helper.RemoteHelper.scp_remote_to_local方法的典型用法代码示例。如果您正苦于以下问题:Python RemoteHelper.scp_remote_to_local方法的具体用法?Python RemoteHelper.scp_remote_to_local怎么用?Python RemoteHelper.scp_remote_to_local使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类remote_helper.RemoteHelper
的用法示例。
在下文中一共展示了RemoteHelper.scp_remote_to_local方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gather_logs
# 需要导入模块: from remote_helper import RemoteHelper [as 别名]
# 或者: from remote_helper.RemoteHelper import scp_remote_to_local [as 别名]
def gather_logs(cls, options):
"""Collects logs from each machine in the currently running AppScale
deployment.
Args:
options: A Namespace that has fields for each parameter that can be
passed in via the command-line interface.
"""
# First, make sure that the place we want to store logs doesn't
# already exist.
if os.path.exists(options.location):
raise AppScaleException("Can't gather logs, as the location you " + \
"specified, {0}, already exists.".format(options.location))
acc = AppControllerClient(LocalState.get_login_host(options.keyname),
LocalState.get_secret_key(options.keyname))
# do the mkdir after we get the secret key, so that a bad keyname will
# cause the tool to crash and not create this directory
os.mkdir(options.location)
for ip in acc.get_all_public_ips():
# Get the logs from each node, and store them in our local directory
local_dir = "{0}/{1}".format(options.location, ip)
os.mkdir(local_dir)
RemoteHelper.scp_remote_to_local(ip, options.keyname, '/var/log/appscale',
local_dir, options.verbose)
AppScaleLogger.success("Successfully copied logs to {0}".format(
options.location))
示例2: gather_logs
# 需要导入模块: from remote_helper import RemoteHelper [as 别名]
# 或者: from remote_helper.RemoteHelper import scp_remote_to_local [as 别名]
def gather_logs(cls, options):
"""Collects logs from each machine in the currently running AppScale
deployment.
Args:
options: A Namespace that has fields for each parameter that can be
passed in via the command-line interface.
"""
# First, make sure that the place we want to store logs doesn't
# already exist.
if os.path.exists(options.location):
raise AppScaleException("Can't gather logs, as the location you " + \
"specified, {0}, already exists.".format(options.location))
acc = AppControllerClient(LocalState.get_login_host(options.keyname),
LocalState.get_secret_key(options.keyname))
try:
all_ips = acc.get_all_public_ips()
except socket.error: # Occurs when the AppController has failed.
AppScaleLogger.warn("Couldn't get an up-to-date listing of the " + \
"machines in this AppScale deployment. Using our locally cached " + \
"info instead.")
all_ips = LocalState.get_all_public_ips(options.keyname)
# do the mkdir after we get the secret key, so that a bad keyname will
# cause the tool to crash and not create this directory
os.mkdir(options.location)
for ip in all_ips:
# Get the logs from each node, and store them in our local directory
local_dir = "{0}/{1}".format(options.location, ip)
os.mkdir(local_dir)
RemoteHelper.scp_remote_to_local(ip, options.keyname, '/var/log/appscale',
local_dir, options.verbose)
try:
RemoteHelper.scp_remote_to_local(ip, options.keyname,
'/var/log/cassandra', local_dir, options.verbose)
except ShellException:
pass
try:
RemoteHelper.scp_remote_to_local(ip, options.keyname,
'/var/log/zookeeper', local_dir, options.verbose)
except ShellException:
pass
RemoteHelper.scp_remote_to_local(ip, options.keyname, '/var/log/kern.log',
local_dir, options.verbose)
RemoteHelper.scp_remote_to_local(ip, options.keyname, '/var/log/syslog',
local_dir, options.verbose)
AppScaleLogger.success("Successfully copied logs to {0}".format(
options.location))
示例3: gather_logs
# 需要导入模块: from remote_helper import RemoteHelper [as 别名]
# 或者: from remote_helper.RemoteHelper import scp_remote_to_local [as 别名]
def gather_logs(cls, options):
"""Collects logs from each machine in the currently running AppScale
deployment.
Args:
options: A Namespace that has fields for each parameter that can be
passed in via the command-line interface.
"""
# First, make sure that the place we want to store logs doesn't
# already exist.
if os.path.exists(options.location):
raise AppScaleException(
"Can't gather logs, as the location you " + "specified, {0}, already exists.".format(options.location)
)
acc = AppControllerClient(
LocalState.get_login_host(options.keyname), LocalState.get_secret_key(options.keyname)
)
try:
all_ips = acc.get_all_public_ips()
except socket.error: # Occurs when the AppController has failed.
AppScaleLogger.warn(
"Couldn't get an up-to-date listing of the "
+ "machines in this AppScale deployment. Using our locally cached "
+ "info instead."
)
all_ips = LocalState.get_all_public_ips(options.keyname)
# do the mkdir after we get the secret key, so that a bad keyname will
# cause the tool to crash and not create this directory
os.mkdir(options.location)
# The log paths that we collect logs from.
log_paths = [
"/var/log/appscale",
"/var/log/kern.log*",
"/var/log/monit.log*",
"/var/log/nginx",
"/var/log/syslog*",
"/var/log/zookeeper",
]
failures = False
for ip in all_ips:
# Get the logs from each node, and store them in our local directory
local_dir = "{0}/{1}".format(options.location, ip)
os.mkdir(local_dir)
for log_path in log_paths:
try:
RemoteHelper.scp_remote_to_local(ip, options.keyname, log_path, local_dir, options.verbose)
except ShellException as shell_exception:
failures = True
AppScaleLogger.warn("Unable to collect logs from '{}' for host '{}'".format(log_path, ip))
AppScaleLogger.verbose("Encountered exception: {}".format(str(shell_exception)), options.verbose)
if failures:
AppScaleLogger.log(
"Done copying to {0}. There were " "failures while collecting AppScale logs.".format(options.location)
)
else:
AppScaleLogger.success("Successfully collected all AppScale logs into " "{0}".format(options.location))