MySQL 9.1.0
Source Code Documentation
config_generator.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2016, 2024, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#ifndef ROUTER_CONFIG_GENERATOR_INCLUDED
27#define ROUTER_CONFIG_GENERATOR_INCLUDED
28
29#include <chrono>
30#include <functional>
31#include <iostream> // cerr
32#include <map>
33#include <set>
34#include <stdexcept>
35#include <string>
36#include <vector>
37
38#include "auto_cleaner.h"
45#include "mysqlrouter/uri.h"
46#include "random_generator.h"
47#include "tcp_address.h"
48#include "unique_ptr.h"
49
50namespace mysql_harness {
51class Path;
52}
53
54namespace mysqlrouter {
55class ClusterMetadata;
56class MySQLSession;
57class SysUserOperationsBase;
58class SysUserOperations;
59struct ClusterInfo;
60
62 public:
64 std::ostream &out_stream = std::cout, std::ostream &err_stream = std::cerr
65#ifndef _WIN32
66 ,
68#endif
69 );
71
72 /** @brief first part of the bootstrap process
73 *
74 * This function does a lot of initialisation before bootstrap starts making
75 * changes.
76 *
77 * @param server_url server to bootstrap from
78 * @param bootstrap_options bootstrap options
79 *
80 * @throws std::runtime_error
81 */
82 void init(const std::string &server_url,
83 const std::map<std::string, std::string> &bootstrap_options);
84
85 /** @brief logs warning and returns false if SSL mode is set to PREFERRED and
86 * SSL is not being used, true otherwise
87 *
88 * @param options map of commandline options
89 *
90 * @returns false if SSL mode is set to PREFERRED and SSL is not being used,
91 * true otherwise
92 *
93 * @throws std::runtime_error
94 */
95 bool warn_on_no_ssl(const std::map<std::string, std::string> &options);
96
98 const std::string &program_name, const std::string &config_file_path,
99 const std::string &state_file_path,
100 const std::map<std::string, std::string> &options,
101 const std::map<std::string, std::vector<std::string>> &multivalue_options,
102 const std::map<std::string, std::string> &default_paths);
103
105 const std::string &program_name, const std::string &directory,
106 const std::map<std::string, std::string> &options,
107 const std::map<std::string, std::vector<std::string>> &multivalue_options,
108 const std::map<std::string, std::string> &default_paths);
109
110 void set_keyring_info(const KeyringInfo &keyring_info) {
111 keyring_info_ = keyring_info;
112 }
113
114 void set_plugin_folder(const std::string &val) { plugin_folder_ = val; }
115
116 struct Options {
117 struct Endpoint {
118 int port;
119 std::string socket;
120 Endpoint() : port(0) {}
121 Endpoint(const std::string &path) : port(0), socket(path) {}
122 Endpoint(int port_) : port(port_) {}
123
124 operator bool() const { return port > 0 || !socket.empty(); }
125 };
126 Options() = default;
127
134
135 std::string override_logdir;
137 std::string override_rundir;
138 std::string override_datadir;
139 std::string socketsdir;
140
141 std::string keyring_file_path;
144
145 std::string bind_address;
146
149
151
152 std::chrono::milliseconds ttl;
154
155 bool disable_rest{false};
156 std::string https_port_str;
157
158 std::string client_ssl_cert;
159 std::string client_ssl_cipher;
160 std::string client_ssl_curves;
161 std::string client_ssl_mode;
162 std::string client_ssl_key;
164
165 std::string server_ssl_cipher;
166 std::string server_ssl_curves;
167 std::string server_ssl_mode;
168 std::string server_ssl_ca;
169 std::string server_ssl_capath;
170 std::string server_ssl_crl;
172 std::string server_ssl_verify;
173
174 // only relevant for ClusterSet
175 std::string target_cluster;
177 };
178
179 void set_file_owner(
180 const std::map<std::string, std::string> &options,
181 const std::string &owner) const; // throws std::runtime_error
182
183 private:
184 /**
185 * init() calls this to read and validate several command-line options;
186 * results are stored in member fields.
187 *
188 * @param bootstrap_options options map to process
189 *
190 * @throws std::runtime_error on an invalid option
191 */
193 const std::map<std::string, std::string> &bootstrap_options);
194
195 /**
196 * init() calls this to validate and extract metadata server info from server
197 * URI, including user credentials. It will also:
198 * - set user name to "root" if not provided in the URI
199 * - prompt for user password if not provided in the URI
200 *
201 * @param server_uri server URI (--bootstrap|-B argument)
202 * @param bootstrap_socket bootstrap (unix) socket (--bootstrap-socket
203 * argumenent)
204 *
205 * @returns URI with required information
206 *
207 * @throws std::runtime_error on an invalid data
208 */
209 URI parse_server_uri(const std::string &server_uri,
210 const std::string &bootstrap_socket);
211
212 /**
213 * init() calls this to connect to metadata server; sets mysql_ (connection)
214 * object.
215 *
216 * @param u parsed server URL (--bootstrap|-B argument)
217 * @param bootstrap_socket bootstrap (unix) socket (--bootstrap-socket
218 * argumenent)
219 * @param bootstrap_options bootstrap command-line options
220 *
221 * @throws std::runtime_error
222 * @throws std::logic_error
223 */
225 const URI &u, const std::string &bootstrap_socket,
226 const std::map<std::string, std::string> &bootstrap_options);
227
228 /**
229 * init() calls this to set GR-related member fields.
230 *
231 * @param u parsed server URL (--bootstrap|-B argument)
232 * @param bootstrap_socket bootstrap (unix) socket (--bootstrap-socket
233 * argumenent)
234 *
235 * @throws TODO
236 */
237 void init_gr_data(const URI &u, const std::string &bootstrap_socket);
238
240 bool valid{false};
241 uint32_t router_id{0};
242 std::string username;
243 uint16_t rw_x_port{0};
244 uint16_t ro_x_port{0};
245 };
246
247 Options fill_options(const std::map<std::string, std::string> &user_options,
248 const std::map<std::string, std::string> &default_paths,
249 const ExistingConfigOptions &existing_config_options);
250
251 void create_start_script(const std::string &program_name,
252 const std::string &directory,
253 bool interactive_master_key,
254 const std::map<std::string, std::string> &options);
255
256 void create_stop_script(const std::string &directory,
257 const std::map<std::string, std::string> &options);
258
259 // virtual so we can disable it in unit tests
260 virtual void set_script_permissions(
261 const std::string &script_path,
262 const std::map<std::string, std::string> &options);
263
264 // returns bootstrap report (several lines of human-readable text) if desired
265 std::string bootstrap_deployment(
266 const std::string &program_name, std::ofstream &config_file,
267 std::ofstream &state_file, const mysql_harness::Path &config_file_path,
268 const mysql_harness::Path &state_file_path, const std::string &name,
269 const std::map<std::string, std::string> &options,
270 const std::map<std::string, std::vector<std::string>> &multivalue_options,
271 const std::map<std::string, std::string> &default_paths,
272 bool directory_deployment, AutoCleaner &auto_clean);
273
274 std::tuple<std::string> try_bootstrap_deployment(
275 uint32_t &router_id, std::string &username, std::string &password,
276 const std::string &router_name, const ClusterInfo &cluster_info,
277 const std::map<std::string, std::string> &user_options,
278 const std::map<std::string, std::vector<std::string>> &multivalue_options,
279 const Options &options);
280
281 void create_config(
282 std::ostream &config_file, std::ostream &state_file, uint32_t router_id,
283 const std::string &router_name, const std::string &system_username,
284 const ClusterInfo &cluster_info, const std::string &username,
285 const Options &options,
286 const std::map<std::string, std::string> &default_paths,
287 const std::map<std::string, std::string> &config_overwrites,
288 const std::string &state_file_name, const bool full);
289
290 void print_bootstrap_start_msg(uint32_t router_id, bool directory_deployment,
291 const mysql_harness::Path &config_file_path);
292
293 std::string get_bootstrap_report_text(
294 const std::string &program_name, const std::string &config_file_name,
295 const std::string &router_name, const std::string &metadata_cluster,
296 const std::string &cluster_type_name, const std::string &hostname,
297 bool is_system_deployment, const Options &options);
298
300 const std::map<std::string, std::string> &default_paths,
301 const std::map<std::string, std::string> &user_options,
302 const Options &options);
303
304 /** @brief Deletes Router accounts just created
305 *
306 * This method runs as a cleanup after something goes wrong. Its purpose is
307 * to undo CREATE USER [IF NOT EXISTS] for accounts that got created during
308 * bootstrap. Note that it will drop only those accounts which did not exist
309 * prior to bootstrap (it may be a subset of account names passed to
310 * CREATE USER [IF NOT EXISTS]). If it is not able to determine what this
311 * (sub)set is, it will not drop anything - instead it will advise user on
312 * how to clean those up manually.
313 */
314 void undo_create_user_for_new_accounts() noexcept;
315
316 /** @brief Finds all hostnames given on command-line
317 *
318 * MySQL accounts are of form `<username>@<hostname>`. This function returns
319 * all `<hostname>` parts that were provided via --account-host switches
320 *
321 * @param multivalue_options key/list-of-values map of bootstrap config;
322 * carries --account-host inside
323 */
324 static std::set<std::string> get_account_host_args(
325 const std::map<std::string, std::vector<std::string>>
326 &multivalue_options) noexcept;
327
328 /** @brief Creates Router accounts
329 *
330 * Creates Router accounts for all hostnames (ie. `someuser@host1`,
331 * `someuser@host2`, `someuser@%`, etc). It will create such accounts for
332 * all hosts that appear in hostnames_cmdline, but not in hostnames_db.
333 *
334 * @note This is the higher-level method, which drives calls to lower-level
335 * methods like create_account_with_compliant_password() and
336 * create_accounts().
337 *
338 * @param user_options key/value map of bootstrap config options
339 * @param hostnames hostnames provided as --account-host arguments
340 * @param username Router account to be created (without the hostname part)
341 * @param password_change_ok password is allowed to be changed if needed
342 * @param password Router account password, will be overwritten if empty
343 *
344 * @returns auto-generated password
345 *
346 * @throws std::logic_error on not connected
347 * std::runtime_error on bad password or Server's password policy
348 * changing during bootstrap
349 * MySQLSession::Error on other (unexpected) SQL error
350 */
352 const std::map<std::string, std::string> &user_options,
353 const std::set<std::string> &hostnames, const std::string &username,
354 const std::string &password, bool password_change_ok);
355
356 /** @brief Creates Router account with compliant password
357 *
358 * Creates Router account with a (self-generated) password that will pass
359 * Server's password policy. It first tries creating a hashed password using
360 * mysql_native_password plugin. If that fails, it falls back to using
361 * plaintext password, which the Server may reject for not being strong
362 * enough. If that's the case, it will generate another password and try again
363 * 2 more times (for a total of 3 password-generation attempts), after which
364 * it will give up.
365 *
366 * @note This is a higher-level method, with smart logic that drives calls to
367 * lower-level create_accounts() method.
368 *
369 * @param user_options key/value map of bootstrap config options
370 * @param username Router account to be created - the username part
371 * @param hostnames Router accounts to be created - the hostname part
372 * @param password Password for the account
373 * @param password_change_ok password is allowed to be changed if needed
374 * @param if_not_exists if true, CREATE USER IF NOT EXISTS will be used
375 * instead of CREATE USER
376 *
377 * @returns password
378 *
379 * @throws std::logic_error on not connected
380 * std::runtime_error on bad password
381 * MySQLSession::Error on other (unexpected) SQL error
382 */
384 const std::map<std::string, std::string> &user_options,
385 const std::string &username, const std::set<std::string> &hostnames,
386 const std::string &password, bool password_change_ok, bool if_not_exists);
387
388 /** @brief Creates Router account (low-level function)
389 *
390 * Creates Router account using CREATE USER [IF NOT EXISTS] and gives it
391 * GRANTs.
392 *
393 * @param username Router account to be created - the username part
394 * @param hostnames Router accounts to be created - the hostnames part
395 * @param password Password for the account
396 * @param if_not_exists if true, CREATE USER IF NOT EXISTS will be used
397 * instead of CREATE USER
398 *
399 * @throws std::logic_error on not connected
400 * password_too_weak on Server not liking the password
401 * account_exists if running without IF NOT EXISTS and account exists
402 * already MySQLSession::Error on other (unexpected) SQL error
403 */
404 void create_accounts(const std::string &username,
405 const std::set<std::string> &hostnames,
406 const std::string &password, bool if_not_exists = false);
407
408 void create_users(const std::string &username,
409 const std::set<std::string> &hostnames,
410 const std::string &password, bool if_not_exists);
411
413 const std::string &username);
414
416 const std::string &username, const std::set<std::string> &hostnames,
417 bool if_not_exists);
418
419 void give_grants_to_users(const std::string &new_accounts);
420
421 std::string make_account_list(const std::string username,
422 const std::set<std::string> &hostnames);
423
424 ExistingConfigOptions get_options_from_config_if_it_exists(
425 const std::string &config_file_path,
426 const mysqlrouter::ClusterInfo &cluster_info, bool forcing_overwrite);
427
428 void update_router_info(uint32_t router_id, const Options &options);
429
431 const mysql_harness::Path &config_path, const std::string &new_file_path,
432 const std::map<std::string, std::string> &options,
433 AutoCleaner *auto_cleaner = nullptr);
434
435 void set_keyring_info_real_paths(std::map<std::string, std::string> &options,
436 const mysql_harness::Path &path);
437
439 AutoCleaner &auto_clean,
440 const std::map<std::string, std::string> &user_options,
441 uint32_t router_id, const std::string &username,
442 const std::string &password, Options &options);
443
444 std::string fetch_password_from_keyring(const std::string &username,
445 uint32_t router_id);
446
448 AutoCleaner &auto_clean,
449 const std::map<std::string, std::string> &user_options,
450 uint32_t router_id);
451
452 void init_keyring_file(uint32_t router_id, bool create_if_needed = true);
453
454 static void set_ssl_options(
455 MySQLSession *sess, const std::map<std::string, std::string> &options);
456
457 void ensure_router_id_is_ours(uint32_t &router_id,
458 const std::string &hostname_override);
459
460 uint32_t register_router(const std::string &router_name,
461 const std::string &hostname_override, bool force);
462
463 void verify_router_account(const std::string &username,
464 const std::string &password, bool strict);
465
466 /**
467 * @brief Prepare X.509 certificates for the Router.
468 *
469 * If user provides Router certificate and key files they are used in the
470 * first place so no action is taken in this method. If there are no existing
471 * certificate files then CA certificate and key along with Router certificate
472 * and key will be created.
473 *
474 * @param[in] user_options Key/value map of bootstrap config options.
475 * @param[in] default_paths Map of predefined default paths.
476 * @param[in,out] auto_cleaner Automatic file cleanup object that guarantees
477 * file cleanup if bootstrap fails at any point.
478 *
479 * @throws std::runtime_error Data directory contains some certificate files
480 * but Router certificate and/or key is missing.
481 */
483 const std::map<std::string, std::string> &user_options,
484 const std::map<std::string, std::string> &default_paths,
485 AutoCleaner *auto_cleaner) const;
486
487 /**
488 * @brief Check if datadir directory contains only files that are allowed
489 * before the bootstrap.
490 *
491 * @param[in] dir Data directory representation.
492 *
493 * @retval false - datadir contains files that are not allowed before the
494 * bootstrap.
495 * @retval true - datadir does not contain files that are not allowed before
496 * the bootstrap.
497 */
499 const mysql_harness::Directory &dir) const;
500
501 private:
506
507 // For GR cluster Group Replication ID, for AR cluster cluster_id from the
508 // metadata, for ClusterSet clusterset_id
515
518
519 std::ostream &out_stream_;
520 std::ostream &err_stream_;
521
523 enum {
524 kNotSet = 1, // =1 is not a requirement, just defensive programming
526 kNewAccounts
527 } type = kNotSet;
528 std::string accounts;
530
531 const struct TLS_filenames {
532 std::string ca_key{"ca-key.pem"};
533 std::string ca_cert{"ca.pem"};
534 std::string router_key{"router-key.pem"};
535 std::string router_cert{"router-cert.pem"};
537
538#ifndef _WIN32
540#endif
541
543
544 std::string plugin_folder_;
545};
546} // namespace mysqlrouter
547#endif // ROUTER_CONFIG_GENERATOR_INCLUDED
The ClusterMetadata class encapsulates a connection to the Metadata server.
Definition: cluster_metadata.h:63
Class representing an error.
Definition: error.h:48
KeyringInfo class encapsulates loading and storing master key using master-key-reader and master-key-...
Definition: keyring_info.h:76
A helper class for handling file paths.
Definition: path.h:38
Class representing a path in a file system.
Definition: filesystem.h:63
Automatic cleanup on scope exit utility class.
Definition: auto_cleaner.h:62
Definition: cluster_metadata.h:59
Definition: config_generator.h:61
std::string plugin_folder_
Definition: config_generator.h:544
std::string bootstrap_deployment(const std::string &program_name, std::ofstream &config_file, std::ofstream &state_file, const mysql_harness::Path &config_file_path, const mysql_harness::Path &state_file_path, const std::string &name, const std::map< std::string, std::string > &options, const std::map< std::string, std::vector< std::string > > &multivalue_options, const std::map< std::string, std::string > &default_paths, bool directory_deployment, AutoCleaner &auto_clean)
Definition: config_generator.cc:1483
void give_grants_to_users(const std::string &new_accounts)
Definition: config_generator.cc:3244
std::string fetch_password_from_keyring(const std::string &username, uint32_t router_id)
Definition: config_generator.cc:2022
std::string cluster_initial_password_
Definition: config_generator.h:513
void connect_to_metadata_server(const URI &u, const std::string &bootstrap_socket, const std::map< std::string, std::string > &bootstrap_options)
init() calls this to connect to metadata server; sets mysql_ (connection) object.
Definition: config_generator.cc:387
SysUserOperationsBase * sys_user_operations_
Definition: config_generator.h:539
void init(const std::string &server_url, const std::map< std::string, std::string > &bootstrap_options)
first part of the bootstrap process
Definition: config_generator.cc:446
std::string cluster_initial_username_
Definition: config_generator.h:512
void create_users(const std::string &username, const std::set< std::string > &hostnames, const std::string &password, bool if_not_exists)
Definition: config_generator.cc:3077
std::unique_ptr< MySQLSession > mysql_
Definition: config_generator.h:502
void create_config(std::ostream &config_file, std::ostream &state_file, uint32_t router_id, const std::string &router_name, const std::string &system_username, const ClusterInfo &cluster_info, const std::string &username, const Options &options, const std::map< std::string, std::string > &default_paths, const std::map< std::string, std::string > &config_overwrites, const std::string &state_file_name, const bool full)
Definition: config_generator.cc:2556
std::string cluster_initial_socket_
Definition: config_generator.h:514
void create_stop_script(const std::string &directory, const std::map< std::string, std::string > &options)
Definition: config_generator.cc:3708
bool keyring_initialized_
Definition: config_generator.h:517
bool datadir_contains_allowed_files(const mysql_harness::Directory &dir) const
Check if datadir directory contains only files that are allowed before the bootstrap.
Definition: config_generator.cc:632
void set_keyring_info_real_paths(std::map< std::string, std::string > &options, const mysql_harness::Path &path)
Definition: config_generator.cc:2009
void set_file_owner(const std::map< std::string, std::string > &options, const std::string &owner) const
Definition: config_generator.cc:3812
ExistingConfigOptions get_options_from_config_if_it_exists(const std::string &config_file_path, const mysqlrouter::ClusterInfo &cluster_info, bool forcing_overwrite)
Get selected configuration options from the existing Router configuration file.
Definition: config_generator.cc:3498
void init_keyring_and_master_key(AutoCleaner &auto_clean, const std::map< std::string, std::string > &user_options, uint32_t router_id)
Definition: config_generator.cc:2073
std::ostream & out_stream_
Definition: config_generator.h:519
mysqlrouter::MetadataSchemaVersion schema_version_
Definition: config_generator.h:542
void throw_account_exists(const MySQLSession::Error &e, const std::string &username)
Definition: config_generator.cc:3023
std::string create_router_accounts(const std::map< std::string, std::string > &user_options, const std::set< std::string > &hostnames, const std::string &username, const std::string &password, bool password_change_ok)
Creates Router accounts.
Definition: config_generator.cc:2924
std::unique_ptr< ClusterMetadata > metadata_
Definition: config_generator.h:503
void bootstrap_directory_deployment(const std::string &program_name, const std::string &directory, const std::map< std::string, std::string > &options, const std::map< std::string, std::vector< std::string > > &multivalue_options, const std::map< std::string, std::string > &default_paths)
Create a self-contained deployment of the Router in a directory.
Definition: config_generator.cc:649
std::string get_bootstrap_report_text(const std::string &program_name, const std::string &config_file_name, const std::string &router_name, const std::string &metadata_cluster, const std::string &cluster_type_name, const std::string &hostname, bool is_system_deployment, const Options &options)
Definition: config_generator.cc:2800
int connect_timeout_
Definition: config_generator.h:504
void print_bootstrap_start_msg(uint32_t router_id, bool directory_deployment, const mysql_harness::Path &config_file_path)
Definition: config_generator.cc:2777
void init_gr_data(const URI &u, const std::string &bootstrap_socket)
init() calls this to set GR-related member fields.
Definition: config_generator.cc:434
std::string make_account_list(const std::string username, const std::set< std::string > &hostnames)
Definition: config_generator.cc:3275
void undo_create_user_for_new_accounts() noexcept
Deletes Router accounts just created.
Definition: config_generator.cc:3344
std::string cluster_specific_id_
Definition: config_generator.h:509
void update_router_info(uint32_t router_id, const Options &options)
std::ostream & err_stream_
Definition: config_generator.h:520
bool warn_on_no_ssl(const std::map< std::string, std::string > &options)
logs warning and returns false if SSL mode is set to PREFERRED and SSL is not being used,...
Definition: config_generator.cc:240
ConfigGenerator(std::ostream &out_stream=std::cout, std::ostream &err_stream=std::cerr, SysUserOperationsBase *sys_user_operations=SysUserOperations::instance())
Definition: config_generator.cc:189
int read_timeout_
Definition: config_generator.h:505
void verify_router_account(const std::string &username, const std::string &password, bool strict)
Definition: config_generator.cc:1724
URI parse_server_uri(const std::string &server_uri, const std::string &bootstrap_socket)
init() calls this to validate and extract metadata server info from server URI, including user creden...
Definition: config_generator.cc:329
struct mysqlrouter::ConfigGenerator::UndoCreateAccountList undo_create_account_list_
void set_log_file_permissions(const std::map< std::string, std::string > &default_paths, const std::map< std::string, std::string > &user_options, const Options &options)
Definition: config_generator.cc:1309
void set_plugin_folder(const std::string &val)
Definition: config_generator.h:114
void init_keyring_file(uint32_t router_id, bool create_if_needed=true)
Definition: config_generator.cc:2101
std::set< std::string > get_hostnames_of_created_accounts(const std::string &username, const std::set< std::string > &hostnames, bool if_not_exists)
Definition: config_generator.cc:3134
void bootstrap_system_deployment(const std::string &program_name, const std::string &config_file_path, const std::string &state_file_path, const std::map< std::string, std::string > &options, const std::map< std::string, std::vector< std::string > > &multivalue_options, const std::map< std::string, std::string > &default_paths)
Definition: config_generator.cc:539
void parse_bootstrap_options(const std::map< std::string, std::string > &bootstrap_options)
init() calls this to read and validate several command-line options; results are stored in member fie...
Definition: config_generator.cc:284
const struct mysqlrouter::ConfigGenerator::TLS_filenames tls_filenames_
void create_start_script(const std::string &program_name, const std::string &directory, bool interactive_master_key, const std::map< std::string, std::string > &options)
Definition: config_generator.cc:3613
std::string cluster_initial_hostname_
Definition: config_generator.h:510
Options fill_options(const std::map< std::string, std::string > &user_options, const std::map< std::string, std::string > &default_paths, const ExistingConfigOptions &existing_config_options)
Definition: config_generator.cc:879
void prepare_ssl_certificate_files(const std::map< std::string, std::string > &user_options, const std::map< std::string, std::string > &default_paths, AutoCleaner *auto_cleaner) const
Prepare X.509 certificates for the Router.
Definition: config_generator.cc:1343
KeyringInfo keyring_info_
Definition: config_generator.h:516
virtual void set_script_permissions(const std::string &script_path, const std::map< std::string, std::string > &options)
Definition: config_generator.cc:3595
unsigned int cluster_initial_port_
Definition: config_generator.h:511
uint32_t register_router(const std::string &router_name, const std::string &hostname_override, bool force)
Definition: config_generator.cc:1665
void create_accounts(const std::string &username, const std::set< std::string > &hostnames, const std::string &password, bool if_not_exists=false)
Creates Router account (low-level function)
Definition: config_generator.cc:3295
void ensure_router_id_is_ours(uint32_t &router_id, const std::string &hostname_override)
Definition: config_generator.cc:1642
void store_credentials_in_keyring(AutoCleaner &auto_clean, const std::map< std::string, std::string > &user_options, uint32_t router_id, const std::string &username, const std::string &password, Options &options)
Definition: config_generator.cc:2050
static std::set< std::string > get_account_host_args(const std::map< std::string, std::vector< std::string > > &multivalue_options) noexcept
Finds all hostnames given on command-line.
Definition: config_generator.cc:1706
static void set_ssl_options(MySQLSession *sess, const std::map< std::string, std::string > &options)
Definition: config_generator.cc:211
std::tuple< std::string > try_bootstrap_deployment(uint32_t &router_id, std::string &username, std::string &password, const std::string &router_name, const ClusterInfo &cluster_info, const std::map< std::string, std::string > &user_options, const std::map< std::string, std::vector< std::string > > &multivalue_options, const Options &options)
Definition: config_generator.cc:1928
bool backup_config_file_if_different(const mysql_harness::Path &config_path, const std::string &new_file_path, const std::map< std::string, std::string > &options, AutoCleaner *auto_cleaner=nullptr)
Definition: config_generator.cc:3781
std::string create_accounts_with_compliant_password(const std::map< std::string, std::string > &user_options, const std::string &username, const std::set< std::string > &hostnames, const std::string &password, bool password_change_ok, bool if_not_exists)
Creates Router account with compliant password.
Definition: config_generator.cc:2974
void set_keyring_info(const KeyringInfo &keyring_info)
Definition: config_generator.h:110
Definition: mysql_session.h:154
Base class to allow multiple SysUserOperations implementations.
Definition: sys_user_operations.h:45
static SysUserOperations * instance()
Definition: sys_user_operations.cc:49
Parse and create URIs according to RFC3986.
Definition: uri.h:70
static std::map< string, enum_variable_source > default_paths
Defines mapping between config files names and its corresponding enum values.
Definition: my_default.cc:120
static char * password
Definition: mysql_secure_installation.cc:58
static char * path
Definition: mysqldump.cc:149
std::string dir
Double write files location.
Definition: buf0dblwr.cc:77
constexpr pos_type Options
Definition: method.h:48
const std::string config_file_name
Definition: config.cc:60
Definition: common.h:42
Definition: base64.h:43
Definition: options.cc:57
Definition: gcs_xcom_synode.h:64
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2876
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2884
std::map< Key, Value, Compare, ut::allocator< std::pair< const Key, Value > > > map
Specialization of map which uses ut_allocator.
Definition: ut0new.h:2894
std::conditional_t< !std::is_array< T >::value, std::unique_ptr< T, detail::Deleter< T > >, std::conditional_t< detail::is_unbounded_array_v< T >, std::unique_ptr< T, detail::Array_deleter< std::remove_extent_t< T > > >, void > > unique_ptr
The following is a common type that is returned by all the ut::make_unique (non-aligned) specializati...
Definition: ut0new.h:2440
required string type
Definition: replication_group_member_actions.proto:34
case opt name
Definition: sslopt-case.h:29
Definition: cluster_metadata.h:40
Definition: config_generator.h:239
uint32_t router_id
Definition: config_generator.h:241
bool valid
Definition: config_generator.h:240
uint16_t ro_x_port
Definition: config_generator.h:244
std::string username
Definition: config_generator.h:242
uint16_t rw_x_port
Definition: config_generator.h:243
Definition: config_generator.h:117
std::string socket
Definition: config_generator.h:119
int port
Definition: config_generator.h:118
Endpoint(const std::string &path)
Definition: config_generator.h:121
Endpoint()
Definition: config_generator.h:120
Endpoint(int port_)
Definition: config_generator.h:122
Definition: config_generator.h:116
std::string target_cluster_by_name
Definition: config_generator.h:176
Endpoint ro_x_endpoint
Definition: config_generator.h:132
std::string server_ssl_curves
Definition: config_generator.h:166
std::string client_ssl_dh_params
Definition: config_generator.h:163
std::string server_ssl_verify
Definition: config_generator.h:172
std::string target_cluster
Definition: config_generator.h:175
std::string keyring_master_key_file_path
Definition: config_generator.h:143
std::string override_logfilename
Definition: config_generator.h:136
Endpoint rw_split_endpoint
Definition: config_generator.h:130
std::string client_ssl_mode
Definition: config_generator.h:161
std::string keyring_master_key
Definition: config_generator.h:142
Endpoint ro_endpoint
Definition: config_generator.h:129
std::string bind_address
Definition: config_generator.h:145
mysqlrouter::SSLOptions ssl_options
Definition: config_generator.h:150
int connect_timeout
Definition: config_generator.h:147
bool disable_rw_split_endpoint
Definition: config_generator.h:133
std::string client_ssl_curves
Definition: config_generator.h:160
bool disable_rest
Definition: config_generator.h:155
std::string client_ssl_key
Definition: config_generator.h:162
std::string override_datadir
Definition: config_generator.h:138
std::string override_logdir
Definition: config_generator.h:135
Endpoint rw_x_endpoint
Definition: config_generator.h:131
std::string server_ssl_mode
Definition: config_generator.h:167
Endpoint rw_endpoint
Definition: config_generator.h:128
std::string server_ssl_cipher
Definition: config_generator.h:165
std::string client_ssl_cert
Definition: config_generator.h:158
int read_timeout
Definition: config_generator.h:148
std::string server_ssl_capath
Definition: config_generator.h:169
std::string https_port_str
Definition: config_generator.h:156
std::string keyring_file_path
Definition: config_generator.h:141
std::chrono::milliseconds ttl
Definition: config_generator.h:152
std::string socketsdir
Definition: config_generator.h:139
bool use_gr_notifications
Definition: config_generator.h:153
std::string override_rundir
Definition: config_generator.h:137
std::string client_ssl_cipher
Definition: config_generator.h:159
std::string server_ssl_crlpath
Definition: config_generator.h:171
std::string server_ssl_crl
Definition: config_generator.h:170
std::string server_ssl_ca
Definition: config_generator.h:168
Definition: config_generator.h:531
std::string router_key
Definition: config_generator.h:534
std::string router_cert
Definition: config_generator.h:535
std::string ca_key
Definition: config_generator.h:532
std::string ca_cert
Definition: config_generator.h:533
Definition: config_generator.h:522
std::string accounts
Definition: config_generator.h:528
@ kAllAccounts
Definition: config_generator.h:525
Definition: cluster_metadata.h:42
SSL connection related options.
Definition: datatypes.h:34