Merge "Added limit/marker support for config group lists"
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
features:
|
||||||
|
- Added pagination support (limit and marker) to the CLI for
|
||||||
|
configuration-list and configuration-instances.
|
@@ -96,11 +96,13 @@ class ConfigurationsTest(testtools.TestCase):
|
|||||||
self.assertRaises(Exception, self.configurations.delete, 34)
|
self.assertRaises(Exception, self.configurations.delete, 34)
|
||||||
|
|
||||||
def test_list(self):
|
def test_list(self):
|
||||||
def side_effect_func(path, user, limit, marker):
|
page_mock = mock.Mock()
|
||||||
return path
|
self.configurations._paginated = page_mock
|
||||||
|
limit = "test-limit"
|
||||||
self.configurations._list = mock.Mock(side_effect=side_effect_func)
|
marker = "test-marker"
|
||||||
self.assertEqual('/configurations', self.configurations.list(1))
|
self.configurations.list(limit, marker)
|
||||||
|
page_mock.assert_called_with("/configurations", "configurations",
|
||||||
|
limit, marker)
|
||||||
|
|
||||||
def test_get(self):
|
def test_get(self):
|
||||||
def side_effect_func(path, config):
|
def side_effect_func(path, config):
|
||||||
@@ -111,11 +113,15 @@ class ConfigurationsTest(testtools.TestCase):
|
|||||||
self.configurations.get(123))
|
self.configurations.get(123))
|
||||||
|
|
||||||
def test_instances(self):
|
def test_instances(self):
|
||||||
def side_effect_func(path, config, limit, marker):
|
page_mock = mock.Mock()
|
||||||
return path
|
self.configurations._paginated = page_mock
|
||||||
self.configurations._list = mock.Mock(side_effect=side_effect_func)
|
limit = "test-limit"
|
||||||
self.assertEqual('/configurations/configuration1/instances',
|
marker = "test-marker"
|
||||||
self.configurations.instances(123))
|
configuration = "configuration1"
|
||||||
|
self.configurations.instances(configuration, limit, marker)
|
||||||
|
page_mock.assert_called_with(
|
||||||
|
"/configurations/" + configuration + "/instances",
|
||||||
|
"instances", limit, marker)
|
||||||
|
|
||||||
def test_update(self):
|
def test_update(self):
|
||||||
self.configurations.api.client.put = self._get_mock_method()
|
self.configurations.api.client.put = self._get_mock_method()
|
||||||
|
@@ -43,16 +43,17 @@ class Configurations(base.ManagerWithFind):
|
|||||||
|
|
||||||
:rtype: :class:`Configurations`
|
:rtype: :class:`Configurations`
|
||||||
"""
|
"""
|
||||||
return self._list("/configurations/%s/instances" %
|
return self._paginated("/configurations/%s/instances" %
|
||||||
base.getid(configuration),
|
base.getid(configuration),
|
||||||
"instances", limit, marker)
|
"instances", limit, marker)
|
||||||
|
|
||||||
def list(self, limit=None, marker=None):
|
def list(self, limit=None, marker=None):
|
||||||
"""Get a list of all configurations.
|
"""Get a list of all configurations.
|
||||||
|
|
||||||
:rtype: list of :class:`Configurations`.
|
:rtype: list of :class:`Configurations`.
|
||||||
"""
|
"""
|
||||||
return self._list("/configurations", "configurations", limit, marker)
|
return self._paginated("/configurations", "configurations",
|
||||||
|
limit, marker)
|
||||||
|
|
||||||
def create(self, name, values, description=None, datastore=None,
|
def create(self, name, values, description=None, datastore=None,
|
||||||
datastore_version=None):
|
datastore_version=None):
|
||||||
|
@@ -1594,18 +1594,32 @@ def do_configuration_patch(cs, args):
|
|||||||
|
|
||||||
@utils.arg('configuration_group', metavar='<configuration_group>',
|
@utils.arg('configuration_group', metavar='<configuration_group>',
|
||||||
help=_('ID or name of the configuration group.'))
|
help=_('ID or name of the configuration group.'))
|
||||||
|
@utils.arg('--limit', metavar='<limit>', type=int, default=None,
|
||||||
|
help=_('Limit the number of results displayed.'))
|
||||||
|
@utils.arg('--marker', metavar='<ID>', type=str, default=None,
|
||||||
|
help=_('Begin displaying the results for IDs greater than the '
|
||||||
|
'specified marker. When used with --limit, set this to '
|
||||||
|
'the last ID displayed in the previous run.'))
|
||||||
@utils.service_type('database')
|
@utils.service_type('database')
|
||||||
def do_configuration_instances(cs, args):
|
def do_configuration_instances(cs, args):
|
||||||
"""Lists all instances associated with a configuration group."""
|
"""Lists all instances associated with a configuration group."""
|
||||||
configuration = _find_configuration(cs, args.configuration_group)
|
configuration = _find_configuration(cs, args.configuration_group)
|
||||||
params = cs.configurations.instances(configuration)
|
params = cs.configurations.instances(configuration,
|
||||||
|
limit=args.limit,
|
||||||
|
marker=args.marker)
|
||||||
utils.print_list(params, ['id', 'name'])
|
utils.print_list(params, ['id', 'name'])
|
||||||
|
|
||||||
|
|
||||||
|
@utils.arg('--limit', metavar='<limit>', type=int, default=None,
|
||||||
|
help=_('Limit the number of results displayed.'))
|
||||||
|
@utils.arg('--marker', metavar='<ID>', type=str, default=None,
|
||||||
|
help=_('Begin displaying the results for IDs greater than the '
|
||||||
|
'specified marker. When used with --limit, set this to '
|
||||||
|
'the last ID displayed in the previous run.'))
|
||||||
@utils.service_type('database')
|
@utils.service_type('database')
|
||||||
def do_configuration_list(cs, args):
|
def do_configuration_list(cs, args):
|
||||||
"""Lists all configuration groups."""
|
"""Lists all configuration groups."""
|
||||||
config_grps = cs.configurations.list()
|
config_grps = cs.configurations.list(limit=args.limit, marker=args.marker)
|
||||||
utils.print_list(config_grps, [
|
utils.print_list(config_grps, [
|
||||||
'id', 'name', 'description',
|
'id', 'name', 'description',
|
||||||
'datastore_name', 'datastore_version_name'])
|
'datastore_name', 'datastore_version_name'])
|
||||||
|
Reference in New Issue
Block a user