Support to remove datastore config parameters

CLI:
trove-manage db_remove_datastore_config_parameters mysql 5.7.29

Change-Id: Ia8b5828dfabd595d0ac33a2fdf1d9959f2d1d9ba
This commit is contained in:
Lingxian Kong 2020-05-29 23:31:11 +12:00
parent 0421c1e406
commit a7af0e4df9
3 changed files with 33 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
features:
- Trove admin user is able to remove the default configuration parameters for
datastore version, e.g.
``trove-manage db_remove_datastore_config_parameters mysql 5.7.29``

View File

@ -87,6 +87,13 @@ class Commands(object):
config_models.load_datastore_configuration_parameters(
datastore, datastore_version, config_file_location)
def db_remove_datastore_config_parameters(self, datastore,
datastore_version):
print("Removing config parameters for datastore (%s) version (%s)"
% (datastore, datastore_version))
config_models.remove_datastore_configuration_parameters(
datastore, datastore_version)
def datastore_version_flavor_add(self, datastore_name,
datastore_version_name, flavor_ids):
"""Adds flavors for a given datastore version id."""
@ -230,6 +237,17 @@ def main():
help='Fully qualified file path to the configuration group '
'parameter validation rules.')
parser = subparser.add_parser(
'db_remove_datastore_config_parameters',
description='Remove configuration group parameter validation '
'rules for a datastore version from the database.')
parser.add_argument(
'datastore',
help='Name of the datastore.')
parser.add_argument(
'datastore_version',
help='Name of the datastore version.')
parser = subparser.add_parser(
'datastore_version_flavor_add', help='Adds flavor association to '
'a given datastore and datastore version.')

View File

@ -378,10 +378,19 @@ def load_datastore_configuration_parameters(datastore,
)
def remove_datastore_configuration_parameters(datastore, datastore_version):
get_db_api().configure_db(CONF)
(ds, ds_version) = dstore_models.get_datastore_version(
type=datastore, version=datastore_version, return_inactive=True)
db_params = DatastoreConfigurationParameters.load_parameters(ds_version.id)
for db_param in db_params:
db_param.delete()
def persisted_models():
return {
'configurations': DBConfiguration,
'configuration_parameters': DBConfigurationParameter,
'datastore_configuration_parameters':
DBDatastoreConfigurationParameters,
DBDatastoreConfigurationParameters,
}