本文整理汇总了Python中remote.remote_util.RemoteMachineShellConnection.file_ends_with方法的典型用法代码示例。如果您正苦于以下问题:Python RemoteMachineShellConnection.file_ends_with方法的具体用法?Python RemoteMachineShellConnection.file_ends_with怎么用?Python RemoteMachineShellConnection.file_ends_with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类remote.remote_util.RemoteMachineShellConnection
的用法示例。
在下文中一共展示了RemoteMachineShellConnection.file_ends_with方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from remote.remote_util.RemoteMachineShellConnection import file_ends_with [as 别名]
def run(self):
remote = RemoteMachineShellConnection(self.server)
server_type = 'membase'
if remote.is_couchbase_installed():
server_type = 'couchbase'
stamp = time.strftime("%d_%m_%Y_%H_%M")
try:
info = remote.extract_remote_info()
if info.type.lower() != 'windows':
core_files = []
print "looking for Erlang/Memcached crashes on {0} ... ".format(info.ip)
core_files.extend(remote.file_starts_with("/opt/{0}/var/lib/{0}/".format(server_type), "erl_crash"))
core_files.extend(remote.file_starts_with("/opt/{0}/var/lib/{0}/".format(server_type), "core"))
core_files.extend(remote.file_starts_with("/tmp/", "core"))
core_files.extend(remote.file_ends_with("/opt/{0}/var/lib/{0}/crash".format(server_type), ".dmp"))
if core_files:
print "found dumps on {0}: {1}".format(info.ip, core_files)
command = "mkdir -p /tmp/backup_crash/{0};" \
"mv -f /tmp/core* /tmp/backup_crash/{0};" \
"mv -f /opt/{1}/var/lib/{1}/erl_crash.dump* /tmp/backup_crash/{0}; " \
"mv -f /opt/{1}/var/lib/{1}/crash/*.dmp /tmp/backup_crash/{0};".\
format(stamp, server_type)
print "Moved all dumps on {0} to backup folder: /tmp/backup_crash/{1}".format(self.server.ip, stamp)
remote.execute_command(command)
output, error = remote.execute_command("ls -la /tmp/backup_crash/{0}".format(stamp))
for o in output:
print o
for core_file in core_files:
remote_path, file_name = os.path.dirname(core_file), os.path.basename(core_file)
if remote.delete_file(remote_path, file_name):
print 'deleted core file : {0}'.format(core_file)
remote.disconnect()
else:
print "dump files not found on {0}".format(info.ip)
if remote:
remote.disconnect()
except Exception as ex:
print ex