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


Python RemoteMachineShellConnection.execute_command_raw方法代码示例

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


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

示例1: MemcachetestRunner

# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import execute_command_raw [as 别名]
class MemcachetestRunner():
    def __init__(self, server, path="/tmp/", memcached_ip="localhost", memcached_port="11211", num_items=100000, extra_params=""):
        self.server = server
        self.shell = RemoteMachineShellConnection(self.server)
        self.path = path
        self.memcached_ip = memcached_ip
        self.memcached_port = memcached_port
        self.num_items = num_items
        self.extra_params = extra_params
        self.log = logger.Logger.get_logger()

    def start_memcachetest(self):
        #check that memcachetest already installed
        exists = self.shell.file_exists('/usr/local/bin/', 'memcachetest')
        if not exists:
            #try to get from git and install
            output, error = self.shell.execute_command_raw("cd {0}; git clone git://github.com/membase/memcachetest.git".format(self.path))
            self.shell.log_command_output(output, error)
            output, error = self.shell.execute_command_raw("cd {0}/memcachetest; ./config/autorun.sh && ./configure && make install".format(self.path))
            self.shell.log_command_output(output, error)
        else:
            self.log.info("memcachetest already set on {0}:/usr/local/bin/memcachetest".format(self.server.ip, self.path))
        self.stop_memcachetest()
        return self.launch_memcachetest()

    def launch_memcachetest(self):
        command = "{0}/memcachetest/memcachetest -h {1}:{2} -i {3} {4}".format(self.path, self.memcached_ip, self.memcached_port, self.num_items, self.extra_params)
        output, error = self.shell.execute_command_raw(command)
        status = self.shell.log_command_output(output, error, track_words="downstream timeout")

    def stop_memcachetest(self):
        cmd = "killall memcachetest"
        output, error = self.shell.execute_command(cmd)
        self.shell.log_command_output(output, error)
        self.log.info("memcachetest was stopped on {0}".format(self.server.ip))
开发者ID:Boggypop,项目名称:testrunner,代码行数:37,代码来源:memcachetest_runner.py

示例2: convert_to_hostname

# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import execute_command_raw [as 别名]
 def convert_to_hostname(self, servers_with_hostnames, username='Administrator', password='password'):
     try:
         hostname = []
         for server in servers_with_hostnames:
             shell = RemoteMachineShellConnection(server)
             info = shell.extract_remote_info()
             domain = ''.join(info.domain[0])
             if not domain:
                 output = shell.execute_command_raw('nslookup %s' % info.hostname[0])
                 print output
                 self.fail("Domain is not defined, couchbase cannot be configured correctly. NOT A BUG. CONFIGURATION ISSUE")
             hostname.append(info.hostname[0] + "." + domain)
             master_rest = RestConnection(server)
             current_hostname = master_rest.get_nodes_self().hostname
             self.log.info("get_node_self function returned : {0}".format(current_hostname))
             if server.ip in current_hostname:
                 self.log.info("Node {0} is referred via IP. Need to be referred with hostname. Changing the name of the node!!".format(server.ip))
                 version = RestConnection(server).get_nodes_self().version
                 if version.startswith("1.8.1") or version.startswith("2.0.0") or version.startswith("2.0.1"):
                     RemoteUtilHelper.use_hostname_for_server_settings(server)
                     master_rest.init_cluster()
                 else:
                     master_rest.init_cluster()
                     master_rest.rename_node(username=username, password=password, port='', hostname=hostname[-1])
             else:
                 self.log.info("Node {0} already referred via hostname. No need to convert the name".format(server.ip))
     finally:
         shell.disconnect()
     return hostname
开发者ID:DavidAlphaFox,项目名称:couchbase,代码行数:31,代码来源:hostnameTests.py

示例3: start_measure_sched_delays

# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import execute_command_raw [as 别名]
 def start_measure_sched_delays(self):
     for server in self.servers:
         shell = RemoteMachineShellConnection(server)
         exists = shell.file_exists(self.path, 'measure-sched-delays')
         if not exists:
             shell.copy_file_local_to_remote("resources/linux/measure-sched-delays.tar.gz", "{0}.tar.gz".format(self.path))
             output, error = shell.execute_command_raw("cd /tmp/; tar -xvzf measure-sched-delays.tar.gz")
             shell.log_command_output(output, error)
             output, error = shell.execute_command_raw("cd {0}; ./configure; make".format(self.path))
             shell.log_command_output(output, error)
         else:
             self.log.info("measure-sched-delays already deployed on {0}:{1}".format(server.ip, self.path))
         self.stop_measure_sched_delay()
         output, error = shell.execute_command_raw("rm -rf {0}/sched-delay*".format(self.path))
         shell.log_command_output(output, error)
         self.launch_measure_sched_delay(shell, file="sched-delay-{0}".format(server.ip))
         shell.disconnect()
开发者ID:Boggypop,项目名称:testrunner,代码行数:19,代码来源:measure_sched_delays.py


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