@@ -734,36 +734,33 @@ REGISTER_HELP(DBA_CHECKINSTANCECONFIGURATION_DETAIL13, "@li sslKey: The path to
734
734
REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL14, " The options dictionary may contain the following options:" );
735
735
REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL15, " @li mycnfPath: The path of the MySQL configuration file for the instance." );
736
736
REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL16, " @li password: The password to get connected to the instance." );
737
- REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL17, " @li clusterAdmin: The name of the InnoDB cluster administrator user." );
738
- REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL18, " @li clusterAdminPassword: The password for the InnoDB cluster " \
739
- " administrator account." );
740
- REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL19, " The connection password may be contained on the instance " \
737
+ REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL17, " The connection password may be contained on the instance " \
741
738
" definition, however, it can be overwritten " \
742
739
" if it is specified on the options." );
743
740
744
- REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL20 , " The returned JSON object contains the following attributes:" );
745
- REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL21 , " @li status: the final status of the command, either \" ok\" or \" error\" " );
746
- REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL22 , " @li config_errors: a list of dictionaries containing the failed requirements" );
747
- REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL23 , " @li errors: a list of errors of the operation" );
748
- REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL24 , " @li restart_required: a boolean value indicating whether a " \
741
+ REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL18 , " The returned JSON object contains the following attributes:" );
742
+ REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL19 , " @li status: the final status of the command, either \" ok\" or \" error\" " );
743
+ REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL20 , " @li config_errors: a list of dictionaries containing the failed requirements" );
744
+ REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL21 , " @li errors: a list of errors of the operation" );
745
+ REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL22 , " @li restart_required: a boolean value indicating whether a " \
749
746
" restart is required" );
750
747
751
- REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL25 , " Each dictionary of the list of config_errors includes the " \
748
+ REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL23 , " Each dictionary of the list of config_errors includes the " \
752
749
" following attributes:" );
753
- REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL26 , " @li option: The configuration option for which the requirement " \
750
+ REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL24 , " @li option: The configuration option for which the requirement " \
754
751
" wasn't met" );
755
- REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL27 , " @li current: The current value of the configuration option" );
756
- REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL28 , " @li required: The configuration option required value" );
757
- REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL29 , " @li action: The action to be taken in order to meet the requirement" );
752
+ REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL25 , " @li current: The current value of the configuration option" );
753
+ REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL26 , " @li required: The configuration option required value" );
754
+ REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL27 , " @li action: The action to be taken in order to meet the requirement" );
758
755
759
- REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL30 , " The action can be one of the following:" );
760
- REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL31 , " @li server_update+config_update: Both the server and the " \
756
+ REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL28 , " The action can be one of the following:" );
757
+ REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL29 , " @li server_update+config_update: Both the server and the " \
761
758
" configuration need to be updated" );
762
- REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL32 , " @li config_update+restart: The configuration needs to be " \
759
+ REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL30 , " @li config_update+restart: The configuration needs to be " \
763
760
" updated and the server restarted" );
764
- REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL33 , " @li config_update: The configuration needs to be updated" );
765
- REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL34 , " @li server_update: The server needs to be updated" );
766
- REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL35 , " @li restart: The server needs to be restarted" );
761
+ REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL31 , " @li config_update: The configuration needs to be updated" );
762
+ REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL32 , " @li server_update: The server needs to be updated" );
763
+ REGISTER_HELP (DBA_CHECKINSTANCECONFIGURATION_DETAIL33 , " @li restart: The server needs to be restarted" );
767
764
768
765
/* *
769
766
* $(DBA_CHECKINSTANCECONFIGURATION_BRIEF)
@@ -823,8 +820,6 @@ REGISTER_HELP(DBA_CHECKINSTANCECONFIGURATION_DETAIL35, "@li restart: The server
823
820
* $(DBA_CHECKINSTANCECONFIGURATION_DETAIL31)
824
821
* $(DBA_CHECKINSTANCECONFIGURATION_DETAIL32)
825
822
* $(DBA_CHECKINSTANCECONFIGURATION_DETAIL33)
826
- * $(DBA_CHECKINSTANCECONFIGURATION_DETAIL34)
827
- * $(DBA_CHECKINSTANCECONFIGURATION_DETAIL35)
828
823
*/
829
824
#if DOXYGEN_JS
830
825
Undefined Dba::checkInstanceConfiguration (InstanceDef instance, Dictionary options) {}
@@ -1486,7 +1481,6 @@ std::shared_ptr<mysqlsh::mysql::ClassicSession> Dba::get_session(const shcore::A
1486
1481
shcore::Value::Map_type_ref Dba::_check_instance_configuration (const shcore::Argument_list &args, bool allow_update) {
1487
1482
shcore::Value::Map_type_ref ret_val (new shcore::Value::Map_type ());
1488
1483
shcore::Value::Array_type_ref errors (new shcore::Value::Array_type ());
1489
- std::set<std::string> check_options;
1490
1484
1491
1485
// Validates the connection options
1492
1486
shcore::Value::Map_type_ref instance_def = get_instance_options_map (args, mysqlsh::dba::PasswordFormat::OPTIONS);
@@ -1509,16 +1503,14 @@ shcore::Value::Map_type_ref Dba::_check_instance_configuration(const shcore::Arg
1509
1503
validate_options = args.map_at (1 );
1510
1504
shcore::Argument_map tmp_map (*validate_options);
1511
1505
1506
+ std::set<std::string> check_options {" password" , " dbPassword" , " mycnfPath" };
1512
1507
// The clearReadOnly option is only available in configureLocalInstance
1513
1508
// i.e. with allow_update set as true
1514
1509
if (allow_update) {
1515
- check_options = {" password" , " dbPassword" , " mycnfPath" , " clusterAdmin" ,
1516
- " clusterAdminPassword" , " clearReadOnly" };
1517
- } else {
1518
- check_options = {" password" , " dbPassword" , " mycnfPath" , " clusterAdmin" ,
1519
- " clusterAdminPassword" };
1510
+ check_options.insert (" clusterAdmin" );
1511
+ check_options.insert (" clusterAdminPassword" );
1512
+ check_options.insert (" clearReadOnly" );
1520
1513
}
1521
-
1522
1514
tmp_map.ensure_keys ({}, check_options, " validation options" );
1523
1515
validate_opt_map = tmp_map;
1524
1516
@@ -1549,6 +1541,19 @@ shcore::Value::Map_type_ref Dba::_check_instance_configuration(const shcore::Arg
1549
1541
new_args.push_back (shcore::Value (instance_def));
1550
1542
auto session = Dba::get_session (new_args);
1551
1543
1544
+ // Validate the permissions of the user running the operation.
1545
+ if (!validate_cluster_admin_user_privileges (session, session->get_user (),
1546
+ session->get_host ())) {
1547
+ std::string error_msg =
1548
+ " Account '" + session->get_user () + " '@'" +
1549
+ session->get_host () +
1550
+ " ' does not have all the required privileges to execute this "
1551
+ " operation. For more information, see the online documentation." ;
1552
+ log_error (" %s" , error_msg.c_str ());
1553
+ throw std::runtime_error (error_msg);
1554
+ }
1555
+
1556
+ // Now validates the instance GR status itself
1552
1557
std::string uri = session->uri ();
1553
1558
1554
1559
GRInstanceType type = get_gr_instance_type (session->connection ());
0 commit comments