当前位置: 首页>>代码示例>>Python>>正文


Python RemoteMachineShellConnection.get_file方法代码示例

本文整理汇总了Python中remote.remote_util.RemoteMachineShellConnection.get_file方法的典型用法代码示例。如果您正苦于以下问题:Python RemoteMachineShellConnection.get_file方法的具体用法?Python RemoteMachineShellConnection.get_file怎么用?Python RemoteMachineShellConnection.get_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在remote.remote_util.RemoteMachineShellConnection的用法示例。


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

示例1: run

# 需要导入模块: from remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from remote.remote_util.RemoteMachineShellConnection import get_file [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 crashes on {0} ... ".format(info.ip)
             print "erl_crash files under /opt/{0}/var/lib/{0}/".format(server_type)
             core_files.extend(remote.file_starts_with("/opt/{0}/var/lib/{0}/".format(server_type), "erl_crash"))
             print "core* files under /opt/{0}/var/lib/{0}/".format(server_type)
             core_files.extend(remote.file_starts_with("/opt/{0}/var/lib/{0}/".format(server_type), "core"))
             print "core* files under /tmp/"
             core_files.extend(remote.file_starts_with("/tmp/", "core"))
             if core_files:
                 print "found crashes on {0}: {1}".format(info.ip, core_files)
             else:
                 print "crashes not found on {0}".format(info.ip)
             i = 0
             for core_file in core_files:
                 if core_file.find('erl_crash.dump') != -1:
                     #let's just copy that file back
                     erl_crash_file_name = "erlang-{0}-{1}.log".format(self.server.ip, i)
                     remote_path, file_name = os.path.dirname(core_file), os.path.basename(core_file)
                     if remote.get_file(remote_path, file_name, os.path.join(self.path, erl_crash_file_name)):
                         print 'downloaded core file : {0}'.format(core_file)
                         i += 1
                 else:
                     command = "/opt/{0}/bin/tools/cbanalyze-core".format(server_type)
                     core_file_name = "core-{0}-{1}.log".format(self.server.ip, i)
                     core_log_output = "/tmp/{0}".format(core_file_name)
                     output, _ = remote.execute_command('{0} {1} -f {2}'.format(command, core_file, core_log_output))
                     print output
                     remote_path, file_name = os.path.dirname(core_log_output), os.path.basename(core_log_output)
                     if remote.get_file(remote_path, file_name, os.path.join(self.path, core_file_name)):
                         print 'downloaded core file : {0}'.format(core_log_output)
                         i += 1
             if i > 0:
                 command = "mkdir -p /tmp/backup_crash/{0};mv -f /tmp/core* /tmp/backup_crash/{0}; mv -f /opt/{0}/var/lib/{1}/erl_crash.dump* /tmp/backup_crash/{0}".\
                     format(stamp, server_type)
                 print "put all crashes on {0} in 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
                 remote.disconnect()
             if remote:
                 remote.disconnect()
     except Exception as ex:
         print ex
开发者ID:DavidAlphaFox,项目名称:couchbase,代码行数:55,代码来源:getcoredumps.py

示例2: download_backups

# 需要导入模块: from remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from remote.remote_util.RemoteMachineShellConnection import get_file [as 别名]
    def download_backups(self,backup_location):
        #connect and list all the files under that
        #location and download those files
        #create random folder in local machine
        #create temp folder and then uuid under temp os.getcwd()
        local_files = []
        cwd = os.getcwd()
        local_dir = "{0}/out/tmp/{1}".format(cwd, uuid.uuid4())
        if not os.path.exists(local_dir):
            os.makedirs(local_dir)
        self.log.info("created {0} folder in the local machine...".format(local_dir))
        shell = RemoteMachineShellConnection(self.server)
        files = shell.list_files(backup_location)
        for file in files:
            self.log.info("downloading remote file {0}".format(file))
            shell.get_file(file['path'], file['file'], "{0}/{1}".format(local_dir,file['file']))
            local_files.append({'path': local_dir, 'file': file['file']})
        shell.remove_directory(backup_location)
        #now we can remove these files:

        return local_files
开发者ID:jchris,项目名称:testrunner,代码行数:23,代码来源:mbbackuptests.py

示例3: run

# 需要导入模块: from remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from remote.remote_util.RemoteMachineShellConnection import get_file [as 别名]
    def run(self):
        remote_client = RemoteMachineShellConnection(self.server)
        now = datetime.now()
        day = now.day
        month = now.month
        year = now.year
        file_name = "%s-%s%s%s-diag.zip" % (self.server.ip, month, day, year)
        print "Collecting logs from %s\n" % (self.server.ip)
        output, error = remote_client.execute_cbcollect_info(file_name)
        print "\n".join(output)
        print "\n".join(error)

        user_path = "/home/"
        if self.server.ssh_username == "root":
            user_path = "/"
        if not remote_client.file_exists("%s%s" % (user_path, self.server.ssh_username), file_name):
            raise Exception("%s doesn't exists on server" % (file_name))
        if remote_client.get_file("%s%s" % (user_path, self.server.ssh_username), file_name, "%s/%s" % (self.path, file_name)):
            print "Downloading zipped logs from %s" % (self.server.ip)
        else:
            raise Exception("Fail to download zipped logs from %s" % (self.server.ip))
        remote_client.disconnect()
开发者ID:ronniedada,项目名称:testrunner,代码行数:24,代码来源:collect_server_info.py

示例4: get_all_stats

# 需要导入模块: from remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from remote.remote_util.RemoteMachineShellConnection import get_file [as 别名]
    def get_all_stats(self):
        # One node, the 'master', should aggregate stats from client and server nodes
        # and push results to couchdb.
        # Assuming clients ssh_username/password are same as server
        # Save servers list as clients
        # Replace servers ip with clients ip
        clients = self.input.servers
        for i  in range(len(clients)):
            clients[i].ip = self.input.clients[i]
        remotepath = '/tmp'

        i = 0
        for client in clients:
            shell = RemoteMachineShellConnection(client)
            filename = '{0}.json'.format(i)
            destination = "{0}/{1}".format(os.getcwd(), filename)
            print "Getting client stats file {0} from {1}".format(filename, client)
            if not shell.get_file(remotepath, filename, destination):
                print "Unable to fetch the json file {0} on Client {1} @ {2}".format(remotepath+'/'+filename \
                                                                                     , i, client.ip)
                exit(1)
            i += 1

        self.aggregate_all_stats(len(clients))
开发者ID:vmx,项目名称:testrunner,代码行数:26,代码来源:eperf.py

示例5:

# 需要导入模块: from remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from remote.remote_util.RemoteMachineShellConnection import get_file [as 别名]
 print "looking for erl_crash files under /opt/{0}/var/lib/{0}/".format(server_type)
 core_files.extend(remote.file_starts_with("/opt/{0}/var/lib/{0}/".format(server_type), "erl_crash"))
 print "looking for core* files under /opt/{0}/var/lib/{0}/".format(server_type)
 core_files.extend(remote.file_starts_with("/opt/{0}/var/lib/{0}/".format(server_type), "core"))
 print "looking for core* files under /tmp/"
 core_files.extend(remote.file_starts_with("/tmp/", "core"))
 i = 0
 for core_file in core_files:
     if core_file.find('erl_crash.dump') != -1:
         #let's just copy that file back
         erl_crash_file_name = "erlang-{0}-{1}.log".format(serverInfo.ip, i)
         erl_crash_path = "/opt/{0}/var/lib/{0}/{1}".format(server_type, erl_crash_file_name)
         remote.execute_command('cp {0} {1}'.format(core_file, erl_crash_path))
         destination = "{0}/{1}".format(os.getcwd(), erl_crash_file_name)
         if remote.get_file(remotepath="/opt/{0}/var/lib/{0}/".format(server_type),
                            filename=erl_crash_file_name,
                            todir=destination):
             print 'downloaded core file : {0}'.format(destination)
             i += 1
     else:
         command = "/opt/{0}/bin/analyze_core".format(server_type)
         core_file_name = "core-{0}-{1}.log".format(serverInfo.ip, i)
         core_log_output = "/{0}/{1}".format("tmp", core_file_name)
         output, error = remote.execute_command('{0} {1} -f {2}'.format(command, core_file, core_log_output))
         print output
         destination = "{0}/{1}".format(os.getcwd(), core_file_name)
         if remote.get_file(remotepath="/tmp", filename=core_file_name, todir=destination):
             print 'downloaded core file : {0}'.format(destination)
             i += 1
 if i > 0:
     remote.execute_command('mkdir -p /tmp/backup;mv -f /tmp/core* /tmp/backup/;')
开发者ID:Boggypop,项目名称:testrunner,代码行数:33,代码来源:getcoredumps.py


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