Merge "Add configuration-parameter-show to OSC"
This commit is contained in:
commit
26a9ff544f
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- The command ``trove configuration-parameter-show`` is now available to
|
||||
use in the python-openstackclient CLI as ``openstack database
|
||||
configuration parameter show``
|
@ -38,6 +38,7 @@ openstack.database.v1 =
|
||||
database_cluster_show = troveclient.osc.v1.database_clusters:ShowDatabaseCluster
|
||||
database_configuration_list = troveclient.osc.v1.database_configurations:ListDatabaseConfigurations
|
||||
database_configuration_parameter_list = troveclient.osc.v1.database_configurations:ListDatabaseConfigurationParameters
|
||||
database_configuration_parameter_show = troveclient.osc.v1.database_configurations:ShowDatabaseConfigurationParameter
|
||||
database_configuration_show = troveclient.osc.v1.database_configurations:ShowDatabaseConfiguration
|
||||
database_db_delete = troveclient.osc.v1.databases:DeleteDatabase
|
||||
database_flavor_list = troveclient.osc.v1.database_flavors:ListDatabaseFlavors
|
||||
|
@ -130,3 +130,51 @@ class ListDatabaseConfigurationParameters(command.Lister):
|
||||
params = [osc_utils.get_item_properties(p, self.columns)
|
||||
for p in params]
|
||||
return self.columns, params
|
||||
|
||||
|
||||
class ShowDatabaseConfigurationParameter(command.ShowOne):
|
||||
_description = _("Shows details of a database configuration parameter.")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(ShowDatabaseConfigurationParameter, self).\
|
||||
get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'datastore_version',
|
||||
metavar='<datastore_version>',
|
||||
help=_('Datastore version name or ID assigned to the'
|
||||
' configuration group.'),
|
||||
)
|
||||
parser.add_argument(
|
||||
'parameter',
|
||||
metavar='<parameter>',
|
||||
help=_('Name of the configuration parameter.'),
|
||||
)
|
||||
parser.add_argument(
|
||||
'--datastore',
|
||||
metavar='<datastore>',
|
||||
default=None,
|
||||
help=_('ID or name of the datastore to list configuration'
|
||||
' parameters for. Optional if the ID of the'
|
||||
' datastore_version is provided.'),
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
db_configuration_parameters = self.app.client_manager.database.\
|
||||
configuration_parameters
|
||||
if parsed_args.datastore:
|
||||
param = db_configuration_parameters.get_parameter(
|
||||
parsed_args.datastore,
|
||||
parsed_args.datastore_version,
|
||||
parsed_args.parameter)
|
||||
elif utils.is_uuid_like(parsed_args.datastore_version):
|
||||
param = db_configuration_parameters.get_parameter_by_version(
|
||||
parsed_args.datastore_version,
|
||||
parsed_args.parameter)
|
||||
else:
|
||||
raise exceptions.NoUniqueMatch(_('The datastore name or id is'
|
||||
' required to retrieve the'
|
||||
' parameter for the'
|
||||
' configuration group'
|
||||
' by name.'))
|
||||
return zip(*sorted(six.iteritems(param._info)))
|
||||
|
@ -121,3 +121,51 @@ class TestConfigurationParameterList(TestConfigurations):
|
||||
self.assertRaises(exceptions.NoUniqueMatch,
|
||||
self.cmd.take_action,
|
||||
parsed_args)
|
||||
|
||||
|
||||
class TestConfigurationParameterShow(TestConfigurations):
|
||||
|
||||
values = ('d-123', 31536000, 2, 'connect_timeout', 'false', 'integer')
|
||||
|
||||
def setUp(self):
|
||||
super(TestConfigurationParameterShow, self).setUp()
|
||||
self.cmd = database_configurations. \
|
||||
ShowDatabaseConfigurationParameter(self.app, None)
|
||||
data = self.fake_configuration_params.get_params_connect_timeout()
|
||||
self.configuration_params_client.get_parameter.return_value = data
|
||||
self.configuration_params_client.\
|
||||
get_parameter_by_version.return_value = data
|
||||
self.columns = (
|
||||
'datastore_version_id',
|
||||
'max',
|
||||
'min',
|
||||
'name',
|
||||
'restart_required',
|
||||
'type',
|
||||
)
|
||||
|
||||
def test_configuration_parameter_show_defaults(self):
|
||||
args = ['d-123', 'connect_timeout', '--datastore', 'mysql']
|
||||
verifylist = [
|
||||
('datastore_version', 'd-123'),
|
||||
('parameter', 'connect_timeout'),
|
||||
('datastore', 'mysql'),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, args, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.values, data)
|
||||
|
||||
def test_configuration_parameter_show_with_version_id_exception(self):
|
||||
args = [
|
||||
'd-123',
|
||||
'connect_timeout',
|
||||
]
|
||||
verifylist = [
|
||||
('datastore_version', 'd-123'),
|
||||
('parameter', 'connect_timeout'),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, args, verifylist)
|
||||
self.assertRaises(exceptions.NoUniqueMatch,
|
||||
self.cmd.take_action,
|
||||
parsed_args)
|
||||
|
Loading…
Reference in New Issue
Block a user