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


Python Server.fromServer方法代码示例

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


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

示例1: setup

# 需要导入模块: from mysql.utilities.common.server import Server [as 别名]
# 或者: from mysql.utilities.common.server.Server import fromServer [as 别名]
    def setup(self):
        self.res_fname = "result.txt"

        # Spawn servers
        self.server0 = self.servers.get_server(0)
        mysqld = MYSQL_OPTS_DEFAULT.format(port=self.servers.view_next_port())
        self.server1 = self.servers.spawn_server("rep_master_gtid", mysqld, True)
        mysqld = MYSQL_OPTS_DEFAULT.format(port=self.servers.view_next_port())
        self.server2 = self.servers.spawn_server("rep_slave1_gtid", mysqld, True)
        mysqld = MYSQL_OPTS_DEFAULT.format(port=self.servers.view_next_port())
        self.server3 = self.servers.spawn_server("rep_slave2_gtid", mysqld, True)

        for server in [self.server1, self.server2, self.server3]:
            try:
                grant_proxy_ssl_privileges(server, ssl_user, ssl_pass)
            except UtilError as err:
                raise MUTLibError("{0} on:{1}".format(err.errmsg, server.role))
        conn_info = {
            "user": ssl_user,
            "passwd": ssl_pass,
            "host": self.server0.host,
            "port": self.server0.port,
            "ssl_ca": ssl_c_ca,
            "ssl_cert": ssl_c_cert,
            "ssl_key": ssl_c_key,
        }

        conn_info["port"] = self.server1.port
        conn_info["port"] = self.server1.port
        self.server1 = Server.fromServer(self.server1, conn_info)
        self.server1.connect()

        conn_info["port"] = self.server2.port
        conn_info["port"] = self.server2.port
        self.server2 = Server.fromServer(self.server2, conn_info)
        self.server2.connect()

        conn_info["port"] = self.server3.port
        conn_info["port"] = self.server3.port
        self.server3 = Server.fromServer(self.server3, conn_info)
        self.server3.connect()

        # Reset spawned servers (clear binary log and GTID_EXECUTED set)
        self.reset_master([self.server1, self.server2, self.server3])

        # Set replication topology.
        self.reset_topology([self.server2, self.server3])

        return True
开发者ID:fengshao0907,项目名称:mysql-utilities,代码行数:51,代码来源:rpl_sync_ssl.py

示例2: setup

# 需要导入模块: from mysql.utilities.common.server import Server [as 别名]
# 或者: from mysql.utilities.common.server.Server import fromServer [as 别名]
    def setup(self):
        try:
            mysqld = "--log-bin=mysql-bin {0}".format(ssl_server_opts())
            self.servers.spawn_server('ssl_server',
                                      mysqld, kill=False)
        except MUTLibError as err:
            raise MUTLibError("Cannot spawn needed servers: {0}"
                              "".format(err.errmsg))

        index = self.servers.find_server_by_name('ssl_server')
        self.server1 = self.servers.get_server(index)

        for server in [self.server1]:
            try:
                grant_proxy_ssl_privileges(server, ssl_user, ssl_pass)
                grant_proxy_ssl_privileges(server, "ssl_opt", "ssl_opt_pass",
                                           ssl=False)
            except UtilError as err:
                raise MUTLibError("{0} on:{1}".format(err.errmsg,
                                                      server.role))

        conn_info = {
            'user': ssl_user,
            'passwd': ssl_pass,
            'host': self.server1.host,
            'port': self.server1.port,
            'ssl_ca': ssl_c_ca,
            'ssl_cert': ssl_c_cert,
            'ssl_key': ssl_c_key,
            'ssl': 1
        }

        self.server1 = Server.fromServer(self.server1, conn_info)
        self.server1.connect()

        res = self.server1.exec_query("SHOW STATUS LIKE 'Ssl_cipher'")
        if not res[0][1]:
            raise MUTLibError("Cannot spawn a SSL server.")

        self.drop_all()
        self.load_test_data()

        return True
开发者ID:abooitt,项目名称:mysql-utilities,代码行数:45,代码来源:ssl_connection_simple_test.py

示例3: setup

# 需要导入模块: from mysql.utilities.common.server import Server [as 别名]
# 或者: from mysql.utilities.common.server.Server import fromServer [as 别名]
    def setup(self):
        # Remove previews configiration files (leftover from previous test).
        try:
            os.unlink(self.config_file_path)
        except OSError:
            pass
        try:
            self.servers.spawn_server("ssl_server", ssl_server_opts(), kill=False)
        except MUTLibError as err:
            raise MUTLibError("Cannot spawn needed servers: {0}" "".format(err.errmsg))

        index = self.servers.find_server_by_name("ssl_server")
        self.server1 = self.servers.get_server(index)

        for server in [self.server1]:
            try:
                grant_proxy_ssl_privileges(server, ssl_user, ssl_pass)
            except UtilError as err:
                raise MUTLibError("{0} on: {1}".format(err.errmsg, server.role))

        conn_info = {
            "user": ssl_user,
            "passwd": ssl_pass,
            "host": self.server1.host,
            "port": self.server1.port,
            "ssl_ca": ssl_c_ca,
            "ssl_cert": ssl_c_cert,
            "ssl_key": ssl_c_key,
        }

        self.server2 = Server.fromServer(self.server1, conn_info)
        self.server2.connect()

        res = self.server2.exec_query("SHOW STATUS LIKE 'Ssl_cipher'")
        if not res[0][1]:
            raise MUTLibError("Cannot setup SSL server for test")

        config_p = ConfigParser.ConfigParser()
        with open(self.config_file_path, "w") as config_f:

            config_p.add_section("client")
            config_p.set("client", "user", self.server1.user)
            config_p.set("client", "password", self.server1.passwd)
            config_p.set("client", "host", self.server1.host)
            config_p.set("client", "port", self.server1.port)

            self.test_group_names.append(("simple group name", "simple_login"))
            config_p.add_section("simple_login")
            config_p.set("simple_login", "user", self.server1.user)
            config_p.set("simple_login", "password", self.server1.passwd)
            config_p.set("simple_login", "host", self.server1.host)
            config_p.set("simple_login", "port", self.server1.port)

            group_name = "very_loooooooooooooooooooooooong_group_name"
            self.test_group_names.append(("long group name ", group_name))
            config_p.add_section(group_name)
            config_p.set(group_name, "user", self.server1.user)
            config_p.set(group_name, "password", self.server1.passwd)
            config_p.set(group_name, "host", self.server1.host)

            config_p.set(group_name, "port", self.server1.port)

            group_name = "c0Mpl1-cat3d//name_group"
            self.test_group_names.append(("complicated group name ", group_name))
            config_p.add_section(group_name)
            config_p.set(group_name, "user", self.server1.user)
            config_p.set(group_name, "password", self.server1.passwd)
            config_p.set(group_name, "host", self.server1.host)
            config_p.set(group_name, "port", self.server1.port)

            config_p.add_section("ssl-login")
            self.test_group_names.append(("login with ssl", "ssl-login"))
            config_p.set("ssl-login", "user", self.server2.user)
            config_p.set("ssl-login", "password", self.server2.passwd)
            config_p.set("ssl-login", "host", self.server2.host)
            config_p.set("ssl-login", "port", self.server2.port)
            config_p.set("ssl-login", "ssl-ca", self.server2.ssl_ca)
            config_p.set("ssl-login", "ssl-cert", self.server2.ssl_cert)
            config_p.set("ssl-login", "ssl-key", self.server2.ssl_key)
            config_p.write(config_f)

        return True
开发者ID:fengshao0907,项目名称:mysql-utilities,代码行数:84,代码来源:parser_config.py

示例4: setup

# 需要导入模块: from mysql.utilities.common.server import Server [as 别名]
# 或者: from mysql.utilities.common.server.Server import fromServer [as 别名]
    def setup(self):
        self.res_fname = "result.txt"
        self.temp_files = []
        # Post failover script executed to detect failover events (by creating
        # a specific directory).
        if os.name == 'posix':
            self.fail_event_script = os.path.normpath("./std_data/"
                                                      "fail_event.sh")
        else:
            self.fail_event_script = os.path.normpath("./std_data/"
                                                      "fail_event.bat")

        # Directory created by the post failover script.
        self.failover_dir = os.path.normpath("./fail_event")

        # Remove log files (leftover from previous test).
        for log in self.log_range:
            try:
                os.unlink(_FAILOVER_LOG.format(log))
            except OSError:
                pass

        # Spawn servers
        self.server0 = self.servers.get_server(0)
        mysqld = _DEFAULT_MYSQL_OPTS.format(port=self.servers.view_next_port())
        self.server1 = self.servers.spawn_server("rep_master_gtid", mysqld,
                                                 True)
        mysqld = _DEFAULT_MYSQL_OPTS.format(port=self.servers.view_next_port())
        self.server2 = self.servers.spawn_server("rep_slave1_gtid", mysqld,
                                                 True)
        mysqld = _DEFAULT_MYSQL_OPTS.format(port=self.servers.view_next_port())
        self.server3 = self.servers.spawn_server("rep_slave2_gtid", mysqld,
                                                 True)
        # Spawn server with --master-info-repository=TABLE and
        # --relay-log-info-repository=TABLE.
        mysqld = _MYSQL_OPTS_INFO_REPO_TABLE.format(
            port=self.servers.view_next_port()
        )
        self.server4 = self.servers.spawn_server("rep_slave3_gtid", mysqld,
                                                 True)
        # Spawn a server with MIR=FILE
        mysqld = _DEFAULT_MYSQL_OPTS_FILE.format(
            port=self.servers.view_next_port()
        )
        self.server5 = self.servers.spawn_server("rep_slave4_gtid", mysqld,
                                                 True)

        self.m_port = self.server1.port
        self.s1_port = self.server2.port
        self.s2_port = self.server3.port
        self.s3_port = self.server4.port
        self.s4_port = self.server5.port

        servers = [self.server1, self.server2, self.server3,
                   self.server4, self.server5]
        for server in servers:
            try:
                grant_proxy_ssl_privileges(server, ssl_user, ssl_pass)
            except UtilError as err:
                raise MUTLibError("{0} on:{1}".format(err.errmsg,
                                                      server.role))
        conn_info = {
            'user': ssl_user,
            'passwd': ssl_pass,
            'host': self.server0.host,
            'port': self.server0.port,
            'ssl_ca': ssl_c_ca,
            'ssl_cert': ssl_c_cert,
            'ssl_key': ssl_c_key,
        }

        conn_info['port'] = self.server1.port
        conn_info['port'] = self.server1.port
        self.server1 = Server.fromServer(self.server1, conn_info)
        self.server1.connect()

        conn_info['port'] = self.server2.port
        conn_info['port'] = self.server2.port
        self.server2 = Server.fromServer(self.server2, conn_info)
        self.server2.connect()

        conn_info['port'] = self.server3.port
        conn_info['port'] = self.server3.port
        self.server3 = Server.fromServer(self.server3, conn_info)
        self.server3.connect()

        conn_info['port'] = self.server4.port
        conn_info['port'] = self.server4.port
        self.server4 = Server.fromServer(self.server4, conn_info)
        self.server4.connect()

        conn_info['port'] = self.server5.port
        conn_info['port'] = self.server5.port
        self.server5 = Server.fromServer(self.server5, conn_info)
        self.server5.connect()

        # Update server list prior to check.
        servers = [self.server1, self.server2, self.server3,
                   self.server4, self.server5]

#.........这里部分代码省略.........
开发者ID:abooitt,项目名称:mysql-utilities,代码行数:103,代码来源:failover_daemon_ssl.py

示例5: setup

# 需要导入模块: from mysql.utilities.common.server import Server [as 别名]
# 或者: from mysql.utilities.common.server.Server import fromServer [as 别名]
    def setup(self):
        self.res_fname = "result.txt"
        self.config_file_path = 'rpl_admin_b_ssl.cnf'

        # Spawn servers
        self.server0 = self.servers.get_server(0)
        mysqld = _DEFAULT_MYSQL_OPTS.format(self.servers.view_next_port())
        self.server1 = self.servers.spawn_server(
            "rep_master_gtid_ssl", mysqld, True
        )
        mysqld = _DEFAULT_MYSQL_OPTS.format(self.servers.view_next_port())
        self.server2 = self.servers.spawn_server(
            "rep_slave1_gtid_ssl", mysqld, True
        )
        mysqld = _DEFAULT_MYSQL_OPTS_DIFF_SSL.format(
            self.servers.view_next_port()
        )
        self.server3 = self.servers.spawn_server(
            "rep_slave2_gtid_ssl", mysqld, True
        )
        mysqld = _DEFAULT_MYSQL_OPTS.format(self.servers.view_next_port())
        self.server4 = self.servers.spawn_server(
            "rep_slave3_gtid_ssl", mysqld, True
        )

        self.servers_list = [self.server1, self.server2,
                             self.server3, self.server4]

        for server in self.servers_list:
            try:
                grant_proxy_ssl_privileges(server, ssl_user, ssl_pass)
            except UtilError as err:
                raise MUTLibError("{0} on:{1}".format(err.errmsg,
                                                      server.role))

        conn_info = {
            'user': ssl_user,
            'passwd': ssl_pass,
            'host': self.server0.host,
            'port': self.server0.port,
            'ssl_ca': ssl_c_ca,
            'ssl_cert': ssl_c_cert,
            'ssl_key': ssl_c_key,
        }

        conn_info['port'] = self.server1.port
        conn_info['port'] = self.server1.port
        self.server1 = Server.fromServer(self.server1, conn_info)
        self.server1.connect()

        conn_info['port'] = self.server2.port
        conn_info['port'] = self.server2.port
        self.server2 = Server.fromServer(self.server2, conn_info)
        self.server2.connect()

        conn_info['port'] = self.server3.port
        conn_info['port'] = self.server3.port
        conn_info['ssl_ca'] = ssl_c_ca_b
        conn_info['ssl_cert'] = ssl_c_cert_b
        conn_info['ssl_key'] = ssl_c_key_b
        self.server3 = Server.fromServer(self.server3, conn_info)
        self.server3.connect()

        conn_info['port'] = self.server4.port
        conn_info['port'] = self.server4.port
        conn_info['ssl_ca'] = ssl_c_ca
        conn_info['ssl_cert'] = ssl_c_cert
        conn_info['ssl_key'] = ssl_c_key
        self.server4 = Server.fromServer(self.server4, conn_info)
        self.server4.connect()

        server_n = 0
        for server in [self.server1, self.server2, self.server3,
                       self.server4]:
            server_n += 1
            res = server.exec_query("SHOW STATUS LIKE 'Ssl_cipher'")
            if not res[0][1]:
                raise MUTLibError("Cannot spawn the SSL server{0}."
                                  "".format(server_n))

        # Reset spawned servers (clear binary log and GTID_EXECUTED set)
        self.reset_master()

        # Update server list
        self.servers_list = [self.server1, self.server2,
                             self.server3, self.server4]

        # setup config_path
        config_p = ConfigParser.ConfigParser()
        self.test_server_names = []

        with open(self.config_file_path, 'w') as config_f:
            for server in self.servers_list:
                group_name = 'server_{0}'.format(server.port)
                self.test_server_names.append(group_name)
                config_p.add_section(group_name)
                config_p.set(group_name, 'user', server.user)
                config_p.set(group_name, 'password', server.passwd)
                config_p.set(group_name, 'host', server.host)
                config_p.set(group_name, 'port', server.port)
#.........这里部分代码省略.........
开发者ID:abooitt,项目名称:mysql-utilities,代码行数:103,代码来源:rpl_admin_basic_ssl_gtid_config_path.py

示例6: setup

# 需要导入模块: from mysql.utilities.common.server import Server [as 别名]
# 或者: from mysql.utilities.common.server.Server import fromServer [as 别名]
    def setup(self):
        self.res_fname = "result.txt"

        # Spawn servers
        self.server0 = self.servers.get_server(0)
        mysqld = _DEFAULT_MYSQL_OPTS.format(self.servers.view_next_port())
        self.server1 = self.servers.spawn_server(
            "rep_master_gtid_ssl", mysqld, True
        )
        mysqld = _DEFAULT_MYSQL_OPTS.format(self.servers.view_next_port())
        self.server2 = self.servers.spawn_server(
            "rep_slave1_gtid_ssl", mysqld, True
        )
        mysqld = _DEFAULT_MYSQL_OPTS.format(self.servers.view_next_port())
        self.server3 = self.servers.spawn_server(
            "rep_slave2_gtid_ssl", mysqld, True
        )
        mysqld = _DEFAULT_MYSQL_OPTS.format(self.servers.view_next_port())
        self.server4 = self.servers.spawn_server(
            "rep_slave3_gtid_ssl", mysqld, True
        )

        for server in [self.server1, self.server2, self.server3,
                       self.server4]:
            try:
                grant_proxy_ssl_privileges(server, ssl_user, ssl_pass)
            except UtilError as err:
                raise MUTLibError("{0} on:{1}".format(err.errmsg,
                                                      server.role))

        conn_info = {
            'user': ssl_user,
            'passwd': ssl_pass,
            'host': self.server0.host,
            'port': self.server0.port,
            'ssl_ca': ssl_c_ca,
            'ssl_cert': ssl_c_cert,
            'ssl_key': ssl_c_key,
        }

        conn_info['port'] = self.server1.port
        conn_info['port'] = self.server1.port
        self.server1 = Server.fromServer(self.server1, conn_info)
        self.server1.connect()

        conn_info['port'] = self.server2.port
        conn_info['port'] = self.server2.port
        self.server2 = Server.fromServer(self.server2, conn_info)
        self.server2.connect()

        conn_info['port'] = self.server3.port
        conn_info['port'] = self.server3.port
        self.server3 = Server.fromServer(self.server3, conn_info)
        self.server3.connect()

        conn_info['port'] = self.server4.port
        conn_info['port'] = self.server4.port
        self.server4 = Server.fromServer(self.server4, conn_info)
        self.server4.connect()

        server_n = 0
        for server in [self.server1, self.server2, self.server3,
                       self.server4]:
            server_n += 1
            res = server.exec_query("SHOW STATUS LIKE 'Ssl_cipher'")
            if not res[0][1]:
                raise MUTLibError("Cannot spawn the SSL server{0}."
                                  "".format(server_n))

        # Reset spawned servers (clear binary log and GTID_EXECUTED set)
        self.reset_master()

        self.m_port = self.server1.port
        self.s1_port = self.server2.port
        self.s2_port = self.server3.port
        self.s3_port = self.server4.port

        rpl_admin.test.reset_topology(self)

        return True
开发者ID:abooitt,项目名称:mysql-utilities,代码行数:82,代码来源:rpl_admin_basic_ssl_gtid.py

示例7: setup

# 需要导入模块: from mysql.utilities.common.server import Server [as 别名]
# 或者: from mysql.utilities.common.server.Server import fromServer [as 别名]
    def setup(self):
        # Remove previews configuration files (leftover from previous test).
        try:
            os.unlink(self.config_file_path)
        except OSError:
            pass
        # use --log-error option in order to normalize serverinfo
        # output between 5.6 and 5.7 servers by setting log_err to stderr
        startup_opts = "{0} --log-error=error_log".format(ssl_server_opts())
        try:
            self.servers.spawn_server('ssl_server',
                                      startup_opts, kill=False)
        except MUTLibError as err:
            raise MUTLibError("Cannot spawn needed servers: {0}"
                              "".format(err.errmsg))

        index = self.servers.find_server_by_name('ssl_server')
        self.server1 = self.servers.get_server(index)

        for server in [self.server1]:
            try:
                grant_proxy_ssl_privileges(server, ssl_user, ssl_pass)
            except UtilError as err:
                raise MUTLibError("{0} on: {1}".format(err.errmsg,
                                                       server.role))

        conn_info = {
            'user': ssl_user,
            'passwd': ssl_pass,
            'host': self.server1.host,
            'port': self.server1.port,
            'ssl_ca': ssl_c_ca,
            'ssl_cert': ssl_c_cert,
            'ssl_key': ssl_c_key,
        }

        self.server2 = Server.fromServer(self.server1, conn_info)
        self.server2.connect()

        res = self.server2.exec_query("SHOW STATUS LIKE 'Ssl_cipher'")
        if not res[0][1]:
            raise MUTLibError('Cannot setup SSL server for test')

        config_p = ConfigParser.ConfigParser()
        with open(self.config_file_path, 'w') as config_f:

            config_p.add_section('client')
            config_p.set('client', 'user', self.server1.user)
            config_p.set('client', 'password', self.server1.passwd)
            config_p.set('client', 'host', self.server1.host)
            config_p.set('client', 'port', self.server1.port)

            self.test_group_names.append(('simple group name', 'simple_login'))
            config_p.add_section('simple_login')
            config_p.set('simple_login', 'user', self.server1.user)
            config_p.set('simple_login', 'password', self.server1.passwd)
            config_p.set('simple_login', 'host', self.server1.host)
            config_p.set('simple_login', 'port', self.server1.port)

            group_name = 'very_loooooooooooooooooooooooong_group_name'
            self.test_group_names.append(('long group name ', group_name))
            config_p.add_section(group_name)
            config_p.set(group_name, 'user', self.server1.user)
            config_p.set(group_name, 'password', self.server1.passwd)
            config_p.set(group_name, 'host', self.server1.host)

            config_p.set(group_name, 'port', self.server1.port)

            group_name = 'c0Mpl1-cat3d//name_group'
            self.test_group_names.append(('complicated group name ',
                                          group_name))
            config_p.add_section(group_name)
            config_p.set(group_name, 'user', self.server1.user)
            config_p.set(group_name, 'password', self.server1.passwd)
            config_p.set(group_name, 'host', self.server1.host)
            config_p.set(group_name, 'port', self.server1.port)

            config_p.add_section('ssl-login')
            self.test_group_names.append(('login with ssl', 'ssl-login'))
            config_p.set('ssl-login', 'user', self.server2.user)
            config_p.set('ssl-login', 'password', self.server2.passwd)
            config_p.set('ssl-login', 'host', self.server2.host)
            config_p.set('ssl-login', 'port', self.server2.port)
            config_p.set('ssl-login', 'ssl-ca', self.server2.ssl_ca)
            config_p.set('ssl-login', 'ssl-cert', self.server2.ssl_cert)
            config_p.set('ssl-login', 'ssl-key', self.server2.ssl_key)
            config_p.write(config_f)

        return True
开发者ID:abooitt,项目名称:mysql-utilities,代码行数:91,代码来源:parser_config.py

示例8: setup

# 需要导入模块: from mysql.utilities.common.server import Server [as 别名]
# 或者: from mysql.utilities.common.server.Server import fromServer [as 别名]
    def setup(self):
        self.res_fname = "result.txt"

        # Spawn servers
        self.server0 = self.servers.get_server(0)
        mysqld = _DEFAULT_MYSQL_OPTS.format(port=self.servers.view_next_port())
        self.server1 = self.servers.spawn_server("rep_slave", mysqld, True)
        mysqld = _DEFAULT_MYSQL_OPTS.format(port=self.servers.view_next_port())
        self.server2 = self.servers.spawn_server("rep_master1", mysqld, True)
        mysqld = _DEFAULT_MYSQL_OPTS.format(port=self.servers.view_next_port())
        self.server3 = self.servers.spawn_server("rep_master2", mysqld, True)
        self.total_masters = 2

        for server in [self.server1, self.server2, self.server3]:
            try:
                grant_proxy_ssl_privileges(server, ssl_user, ssl_pass)
            except UtilError as err:
                raise MUTLibError("{0} on:{1}".format(err.errmsg,
                                                      server.role))
        conn_info = {
            'user': ssl_user,
            'passwd': ssl_pass,
            'host': self.server0.host,
            'port': self.server0.port,
            'ssl_ca': ssl_c_ca,
            'ssl_cert': ssl_c_cert,
            'ssl_key': ssl_c_key,
        }

        conn_info['port'] = self.server1.port
        conn_info['port'] = self.server1.port
        self.server1 = Server.fromServer(self.server1, conn_info)
        self.server1.connect()

        conn_info['port'] = self.server2.port
        conn_info['port'] = self.server2.port
        self.server2 = Server.fromServer(self.server2, conn_info)
        self.server2.connect()

        conn_info['port'] = self.server3.port
        conn_info['port'] = self.server3.port
        self.server3 = Server.fromServer(self.server3, conn_info)
        self.server3.connect()

        # Drop all
        self.drop_all()

        # Reset topology
        self.reset_ms_topology()

        # Create data
        self.create_all()

        # Remove log files (leftover from previous test).
        self.cleanup_logs()

        # setup config_path
        config_p = ConfigParser.ConfigParser()
        self.test_server_names = []
        servers_ = [self.server1, self.server2, self.server3]
        with open(self.config_file_path, 'w') as config_f:
            for server in servers_:
                group_name = 'server_{0}'.format(server.port)
                self.test_server_names.append(group_name)
                config_p.add_section(group_name)
                config_p.set(group_name, 'user', server.user)
                config_p.set(group_name, 'password', server.passwd)
                config_p.set(group_name, 'host', server.host)
                config_p.set(group_name, 'port', server.port)
                config_p.set(group_name, 'ssl-ca', server.ssl_ca)
                config_p.set(group_name, 'ssl-cert', server.ssl_cert)
                config_p.set(group_name, 'ssl-key', server.ssl_key)
            config_p.write(config_f)

        server_n = 0
        for server in servers_:
            server_n += 1
            res = server.exec_query("SHOW STATUS LIKE 'Ssl_cipher'")
            if not res[0][1]:
                raise MUTLibError("Cannot spawn the SSL server{0}."
                                  "".format(server_n))

        return True
开发者ID:abooitt,项目名称:mysql-utilities,代码行数:85,代码来源:replicate_ms_ssl.py

示例9: setup

# 需要导入模块: from mysql.utilities.common.server import Server [as 别名]
# 或者: from mysql.utilities.common.server.Server import fromServer [as 别名]
    def setup(self):
        self.config_file_path = 'replicate_ssl.cnf'
        self.server0 = self.servers.get_server(0)

        mysqld = ("--log-bin=mysql-bin --report-port={0} {1}"
                  ).format(self.servers.view_next_port(), SSL_OPTS)
        self.server1 = self.servers.spawn_server(
            "rep_server1_ssl", mysqld, True)
        mysqld = ("--log-bin=mysql-bin --report-port={0} {1}"
                  ).format(self.servers.view_next_port(), SSL_OPTS)
        self.server2 = self.servers.spawn_server(
            "rep_server2_ssl", mysqld, True)

        for server in [self.server1, self.server2]:
            try:
                grant_proxy_ssl_privileges(server, ssl_user, ssl_pass)
            except UtilError as err:
                raise MUTLibError("{0} on:{1}".format(err.errmsg,
                                                      server.role))

        conn_info = {
            'user': ssl_user,
            'passwd': ssl_pass,
            'host': self.server0.host,
            'port': self.server0.port,
            'ssl_ca': ssl_c_ca,
            'ssl_cert': ssl_c_cert,
            'ssl_key': ssl_c_key,
        }

        conn_info['port'] = self.server1.port
        conn_info['port'] = self.server1.port
        self.server1 = Server.fromServer(self.server1, conn_info)
        self.server1.connect()
        res = self.server1.exec_query("SHOW STATUS LIKE 'Ssl_cipher'")
        if not res[0][1]:
            raise MUTLibError("Cannot spawn a SSL server1.")

        conn_info['port'] = self.server2.port
        conn_info['port'] = self.server2.port
        self.server2 = Server.fromServer(self.server2, conn_info)
        self.server2.connect()
        res = self.server2.exec_query("SHOW STATUS LIKE 'Ssl_cipher'")
        if not res[0][1]:
            raise MUTLibError("Cannot spawn a SSL server2.")

        # setup config_path
        config_p = ConfigParser.ConfigParser()
        self.test_server_names = []
        servers_ = [self.server1, self.server2]
        with open(self.config_file_path, 'w') as config_f:
            for server in servers_:
                group_name = 'server_{0}'.format(server.port)
                self.test_server_names.append(group_name)
                config_p.add_section(group_name)
                config_p.set(group_name, 'user', server.user)
                config_p.set(group_name, 'password', server.passwd)
                config_p.set(group_name, 'host', server.host)
                config_p.set(group_name, 'port', server.port)
                config_p.set(group_name, 'ssl-ca', server.ssl_ca)
                config_p.set(group_name, 'ssl-cert', server.ssl_cert)
                config_p.set(group_name, 'ssl-key', server.ssl_key)
            # rpl_user group
            group_name = _RPL_USER_GROUP_NAME
            self.test_server_names.append(group_name)
            config_p.add_section(group_name)
            config_p.set(group_name, 'user', group_name)
            config_p.set(group_name, 'password', "rpl_user_pass")
            config_p.write(config_f)

        self.s1_serverid = 'server_{0}'.format(self.server1.port)
        self.s2_serverid = 'server_{0}'.format(self.server2.port)
        return True
开发者ID:abooitt,项目名称:mysql-utilities,代码行数:75,代码来源:replicate_ssl.py


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