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


Python RemoteHelper.start_gateway方法代码示例

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


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

示例1: GatewayInstaller

# 需要导入模块: from perfrunner.helpers.remote import RemoteHelper [as 别名]
# 或者: from perfrunner.helpers.remote.RemoteHelper import start_gateway [as 别名]

#.........这里部分代码省略.........
        self.remote.kill_processes_gateload()

    def uninstall_gateway(self):
        self.remote.uninstall_gateway()
        self.remote.clean_gateway()

    def uninstall_gateload(self):
        self.remote.uninstall_gateload()
        self.remote.clean_gateload()

    def install_gateway(self):
        if self.is_source_build(self.version):
            commit_hash = self.version.split(":")[1]
            self.remote.install_gateway_from_source(commit_hash)
        else:
            filename, url = self.find_package()
            self.remote.install_gateway(url, filename)

    def is_source_build(self, version):
        """
        did the user pass in a version of the form commit:<commit_hash>
        as opposed to the form x.y.z (which represents a jenkins build release)?
        """
        return version.startswith("commit:")

    def install_gateload(self):
        self.remote.install_gateload()

    def choose_template(self):

        config_url_setting = self.test_config.gateway_settings.config_url
        if len(config_url_setting) > 0:

            target_filename = "downloaded_config.json"
            target_path = "templates/{}".format(target_filename)

            # build url to remote template (http://git.io/b9PK)
            config_url = "http://git.io/{}".format(config_url_setting)

            # download to a file in templates directory
            logger.info("Downloading config: {}".format(config_url))
            contents = urllib2.urlopen(config_url).read()
            logger.info("Writing config to: {}".format(target_path))
            f = open(target_path, 'w')
            f.write(contents)
            f.close()

            # return name of file
            return target_filename

        if self.test_config.gateway_settings.shadow == 'true':
            return 'gateway_config_shadow_template.json'
        else:
            return 'gateway_config_template.json'

    def generate_sync_gateways_config(self):
        loader = FileSystemLoader('templates')
        env = Environment(loader=loader)

        template_filename = self.choose_template()
        template = env.get_template(template_filename)

        for idx, gateway_ip in enumerate(self.remote.gateways, start=0):
            output_filename = "templates/gateway_config_{}.json".format(idx)
            cache_writer = "false"
            if idx == 0:
                cache_writer = self.test_config.gateway_settings.node0_cache_writer
            elif idx == 1:
                cache_writer = self.test_config.gateway_settings.node1_cache_writer
            elif idx == 2:
                cache_writer = self.test_config.gateway_settings.node2_cache_writer

            with open(output_filename, 'w') as fh:
                fh.write(template.render(
                    conn_in=self.test_config.gateway_settings.conn_in,
                    conn_db=self.test_config.gateway_settings.conn_db,
                    compression=self.test_config.gateway_settings.compression,
                    bucket=self.test_config.buckets[0],
                    cache_writer=cache_writer,
                    db_master=self.cluster_spec.yield_masters().next(),
                ))

    def start_sync_gateways(self):
        self.generate_sync_gateways_config()
        self.remote.start_gateway()

    def install(self):
        self.kill_processes_gateway()
        self.uninstall_gateway()
        self.install_gateway()

        self.kill_processes_gateload()
        self.uninstall_gateload()
        self.install_gateload()

        self.start_sync_gateways()
        for idx, gateway_ip in enumerate(self.remote.gateways, start=1):
            self.request_helper.wait_for_gateway_to_start(idx, gateway_ip)
            if self.test_config.gateway_settings.logging_verbose == 'false':
                self.request_helper.turn_off_gateway_logging(gateway_ip)
开发者ID:abhi-bit,项目名称:perfrunner,代码行数:104,代码来源:install_gw.py


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