summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Riedemann <mriedem.os@gmail.com>2018-06-05 19:57:49 +0000
committerMatt Riedemann <mriedem.os@gmail.com>2018-06-05 19:57:49 +0000
commitabaa86fd86d4beca0082ff1768d5306e5e86302e (patch)
treeb838d9cda69dabd72115b021978d0a7ba88e3399
parenteff607ccef91d09052d58f6798f68d67404f51ce (diff)
downloadpython-novaclient-abaa86fd86d4beca0082ff1768d5306e5e86302e.tar.gz
Revert "Fix listing of instances above API max_limit"
This reverts commit eff607ccef91d09052d58f6798f68d67404f51ce. There was no apparent need for the change being reverted since user can list all servers by specifying --limit=1 when running the nova list command. The change introduced a problem whereby the first pass to list instances from the server would get up to [api]/max_limit (default 1000) results and then call again with a marker. If the last instance in the list (the marker) is corrupted in the instance_mappings table in the API DB by not having an associated cell mapping, listing instances will always fail with a MarkerNotFound error even though the CLI user is not passing a marker nor specifying --limit=-1. The corrupted instance mapping record resulting in the MarkerNotFound error is something else that should be fixed on the server side (and likely result in a 500) but the change in behavior of the CLI makes it always fail if you hit this even if you're not passing a marker. Change-Id: Ibb43f500a74733b85bd3242592d36985bfb45856 Closes-Bug: #1773945
-rw-r--r--novaclient/tests/unit/fixture_data/servers.py32
-rw-r--r--novaclient/tests/unit/utils.py12
-rw-r--r--novaclient/tests/unit/v2/fakes.py4
-rw-r--r--novaclient/tests/unit/v2/test_servers.py58
-rw-r--r--novaclient/tests/unit/v2/test_shell.py265
-rw-r--r--novaclient/v2/servers.py5
-rw-r--r--novaclient/v2/shell.py4
7 files changed, 100 insertions, 280 deletions
diff --git a/novaclient/tests/unit/fixture_data/servers.py b/novaclient/tests/unit/fixture_data/servers.py
index 3950158d..2402cd10 100644
--- a/novaclient/tests/unit/fixture_data/servers.py
+++ b/novaclient/tests/unit/fixture_data/servers.py
@@ -32,16 +32,6 @@ class Base(base.Fixture):
self.requests_mock.get(self.url(),
json=get_servers,
- headers=self.json_headers,
- complete_qs=True)
-
- self.requests_mock.get(self.url(name='sample-server'),
- json=get_servers,
- headers=self.json_headers,
- complete_qs=True)
-
- self.requests_mock.get(self.url(marker='5678'),
- json={"servers": []},
headers=self.json_headers)
self.server_1234 = {
@@ -170,31 +160,13 @@ class Base(base.Fixture):
self.requests_mock.get(
self.url('detail', marker=self.server_1234["id"]),
- json={"servers": [self.server_5678, self.server_9012]},
- headers=self.json_headers, complete_qs=True)
-
- self.requests_mock.get(
- self.url('detail', marker=self.server_1234["id"], limit=2),
- json={"servers": [self.server_5678, self.server_9012]},
- headers=self.json_headers, complete_qs=True)
-
- # simulate max_limit=2 by returning 2 items when limit=3
- # another request should be triggered with limit=1 to get complete
- # result
- self.requests_mock.get(
- self.url('detail', limit=3),
json={"servers": [self.server_1234, self.server_5678]},
headers=self.json_headers, complete_qs=True)
self.requests_mock.get(
- self.url('detail', marker=self.server_5678["id"], limit=1),
- json={"servers": [self.server_9012]},
- headers=self.json_headers, complete_qs=True)
-
- self.requests_mock.get(
- self.url('detail', marker=self.server_9012["id"]),
+ self.url('detail', marker=self.server_5678["id"]),
json={"servers": []},
- headers=self.json_headers)
+ headers=self.json_headers, complete_qs=True)
self.server_1235 = self.server_1234.copy()
self.server_1235['id'] = 1235
diff --git a/novaclient/tests/unit/utils.py b/novaclient/tests/unit/utils.py
index f036497a..49d3631f 100644
--- a/novaclient/tests/unit/utils.py
+++ b/novaclient/tests/unit/utils.py
@@ -93,16 +93,12 @@ class FixturedTestCase(testscenarios.TestWithScenarios, TestCase):
fix = self.data_fixture_class(self.requests_mock)
self.data_fixture = self.useFixture(fix)
- def assert_called(self, method, path, body=None, pos=-1):
- self.assertEqual(
- self.requests_mock.request_history[pos].method,
- method)
- self.assertEqual(
- self.requests_mock.request_history[pos].path_url,
- path)
+ def assert_called(self, method, path, body=None):
+ self.assertEqual(self.requests_mock.last_request.method, method)
+ self.assertEqual(self.requests_mock.last_request.path_url, path)
if body:
- req_data = self.requests_mock.request_history[pos].body
+ req_data = self.requests_mock.last_request.body
if isinstance(req_data, six.binary_type):
req_data = req_data.decode('utf-8')
if not isinstance(body, six.string_types):
diff --git a/novaclient/tests/unit/v2/fakes.py b/novaclient/tests/unit/v2/fakes.py
index e853ef22..803dc41e 100644
--- a/novaclient/tests/unit/v2/fakes.py
+++ b/novaclient/tests/unit/v2/fakes.py
@@ -392,8 +392,6 @@ class FakeSessionClient(base_client.SessionClient):
#
def get_servers(self, **kw):
- if kw.get('marker') == '9014':
- return (200, {}, {"servers": []})
return (200, {}, {"servers": [
{'id': '1234', 'name': 'sample-server'},
{'id': '5678', 'name': 'sample-server2'},
@@ -401,8 +399,6 @@ class FakeSessionClient(base_client.SessionClient):
]})
def get_servers_detail(self, **kw):
- if kw.get('marker') == '9014':
- return (200, {}, {"servers": []})
return (200, {}, {"servers": [
{
"id": '1234',
diff --git a/novaclient/tests/unit/v2/test_servers.py b/novaclient/tests/unit/v2/test_servers.py
index dfa1b6fd..07ad1497 100644
--- a/novaclient/tests/unit/v2/test_servers.py
+++ b/novaclient/tests/unit/v2/test_servers.py
@@ -47,64 +47,48 @@ class ServersTest(utils.FixturedTestCase):
"""
return None
- def test_list_all_servers(self):
+ def test_list_servers(self):
sl = self.cs.servers.list()
self.assert_request_id(sl, fakes.FAKE_REQUEST_ID_LIST)
- self.assert_called('GET', '/servers/detail', pos=-2)
- self.assert_called('GET', '/servers/detail?marker=9012')
+ self.assert_called('GET', '/servers/detail')
for s in sl:
self.assertIsInstance(s, servers.Server)
def test_filter_servers_unicode(self):
sl = self.cs.servers.list(search_opts={'name': u't€sting'})
self.assert_request_id(sl, fakes.FAKE_REQUEST_ID_LIST)
- self.assert_called(
- 'GET',
- '/servers/detail?name=t%E2%82%ACsting',
- pos=-2)
- self.assert_called(
- 'GET',
- '/servers/detail?marker=9012&name=t%E2%82%ACsting')
+ self.assert_called('GET', '/servers/detail?name=t%E2%82%ACsting')
for s in sl:
self.assertIsInstance(s, servers.Server)
- def test_list_servers_undetailed(self):
- sl = self.cs.servers.list(detailed=False)
- self.assert_request_id(sl, fakes.FAKE_REQUEST_ID_LIST)
- self.assert_called('GET', '/servers', pos=-2)
- self.assert_called('GET', '/servers?marker=5678')
- for s in sl:
- self.assertIsInstance(s, servers.Server)
-
- def test_list_servers_with_marker(self):
- sl = self.cs.servers.list(marker=1234)
+ def test_list_all_servers(self):
+ # use marker just to identify this call in fixtures
+ sl = self.cs.servers.list(limit=-1, marker=1234)
self.assert_request_id(sl, fakes.FAKE_REQUEST_ID_LIST)
self.assertEqual(2, len(sl))
- self.assert_called('GET', '/servers/detail?marker=1234', pos=-2)
- self.assert_called('GET', '/servers/detail?marker=9012')
+ self.assertEqual(self.requests_mock.request_history[-2].method, 'GET')
+ self.assertEqual(self.requests_mock.request_history[-2].path_url,
+ '/servers/detail?marker=1234')
+ self.assert_called('GET', '/servers/detail?marker=5678')
for s in sl:
self.assertIsInstance(s, servers.Server)
- def test_list_servers_with_marker_limit(self):
- sl = self.cs.servers.list(marker=1234, limit=2)
+ def test_list_servers_undetailed(self):
+ sl = self.cs.servers.list(detailed=False)
self.assert_request_id(sl, fakes.FAKE_REQUEST_ID_LIST)
- self.assert_called('GET', '/servers/detail?limit=2&marker=1234')
+ self.assert_called('GET', '/servers')
for s in sl:
self.assertIsInstance(s, servers.Server)
- self.assertEqual(2, len(sl))
- def test_list_servers_with_limit_above_max_limit(self):
- # use limit=3 to trigger paging simulation on backend fixture side
- sl = self.cs.servers.list(limit=3)
+ def test_list_servers_with_marker_limit(self):
+ sl = self.cs.servers.list(marker=1234, limit=2)
self.assert_request_id(sl, fakes.FAKE_REQUEST_ID_LIST)
- self.assert_called('GET', '/servers/detail?limit=3', pos=-2)
- self.assert_called('GET', '/servers/detail?limit=1&marker=5678')
+ self.assert_called('GET', '/servers/detail?limit=2&marker=1234')
for s in sl:
self.assertIsInstance(s, servers.Server)
- self.assertEqual(3, len(sl))
def test_list_servers_sort_single(self):
sl = self.cs.servers.list(sort_keys=['display_name'],
@@ -112,10 +96,7 @@ class ServersTest(utils.FixturedTestCase):
self.assert_request_id(sl, fakes.FAKE_REQUEST_ID_LIST)
self.assert_called(
'GET',
- '/servers/detail?sort_dir=asc&sort_key=display_name', pos=-2)
- self.assert_called(
- 'GET',
- '/servers/detail?marker=9012&sort_dir=asc&sort_key=display_name')
+ '/servers/detail?sort_dir=asc&sort_key=display_name')
for s in sl:
self.assertIsInstance(s, servers.Server)
@@ -126,11 +107,6 @@ class ServersTest(utils.FixturedTestCase):
self.assert_called(
'GET',
('/servers/detail?sort_dir=asc&sort_dir=desc&'
- 'sort_key=display_name&sort_key=id'),
- pos=-2)
- self.assert_called(
- 'GET',
- ('/servers/detail?marker=9012&sort_dir=asc&sort_dir=desc&'
'sort_key=display_name&sort_key=id'))
for s in sl:
self.assertIsInstance(s, servers.Server)
diff --git a/novaclient/tests/unit/v2/test_shell.py b/novaclient/tests/unit/v2/test_shell.py
index dfa798b8..785b9683 100644
--- a/novaclient/tests/unit/v2/test_shell.py
+++ b/novaclient/tests/unit/v2/test_shell.py
@@ -1324,99 +1324,63 @@ class ShellTest(utils.TestCase):
def test_list(self):
self.run_command('list')
- self.assert_called('GET', '/servers/detail', pos=0)
- self.assert_called('GET', '/servers/detail?marker=9014')
+ self.assert_called('GET', '/servers/detail')
def test_list_minimal(self):
self.run_command('list --minimal')
- self.assert_called('GET', '/servers', pos=0)
- self.assert_called('GET', '/servers?marker=9014')
+ self.assert_called('GET', '/servers')
def test_list_deleted(self):
self.run_command('list --deleted')
- self.assert_called(
- 'GET',
- '/servers/detail?deleted=True',
- pos=0)
- self.assert_called(
- 'GET',
- '/servers/detail?deleted=True&marker=9014')
+ self.assert_called('GET', '/servers/detail?deleted=True')
def test_list_with_images(self):
self.run_command('list --image %s' % FAKE_UUID_1)
- self.assert_called(
- 'GET',
- '/servers/detail?image=%s' % FAKE_UUID_1,
- pos=1)
- self.assert_called(
- 'GET',
- '/servers/detail?image=%s&marker=9014' % FAKE_UUID_1)
+ self.assert_called('GET', '/servers/detail?image=%s' % FAKE_UUID_1)
def test_list_with_flavors(self):
self.run_command('list --flavor 1')
- self.assert_called('GET', '/servers/detail?flavor=1', pos=1)
- self.assert_called('GET', '/servers/detail?flavor=1&marker=9014')
+ self.assert_called('GET', '/servers/detail?flavor=1')
def test_list_by_tenant(self):
self.run_command('list --tenant fake_tenant')
self.assert_called(
'GET',
- '/servers/detail?all_tenants=1&tenant_id=fake_tenant', pos=0)
- self.assert_called(
- 'GET',
- '/servers/detail?all_tenants=1&marker=9014&tenant_id=fake_tenant')
+ '/servers/detail?all_tenants=1&tenant_id=fake_tenant')
def test_list_by_user(self):
self.run_command('list --user fake_user')
self.assert_called(
'GET',
- '/servers/detail?all_tenants=1&user_id=fake_user', pos=0)
- self.assert_called(
- 'GET',
- '/servers/detail?all_tenants=1&marker=9014&user_id=fake_user')
+ '/servers/detail?all_tenants=1&user_id=fake_user')
def test_list_with_single_sort_key_no_dir(self):
self.run_command('list --sort 1')
self.assert_called(
- 'GET', ('/servers/detail?sort_dir=desc&sort_key=1'), pos=0)
- self.assert_called(
- 'GET',
- '/servers/detail?marker=9014&sort_dir=desc&sort_key=1')
+ 'GET', ('/servers/detail?sort_dir=desc&sort_key=1'))
def test_list_with_single_sort_key_and_dir(self):
self.run_command('list --sort 1:asc')
self.assert_called(
- 'GET', ('/servers/detail?sort_dir=asc&sort_key=1'), pos=0)
- self.assert_called(
- 'GET',
- '/servers/detail?marker=9014&sort_dir=asc&sort_key=1')
+ 'GET', ('/servers/detail?sort_dir=asc&sort_key=1'))
def test_list_with_sort_keys_no_dir(self):
self.run_command('list --sort 1,2')
self.assert_called(
'GET', ('/servers/detail?sort_dir=desc&sort_dir=desc&'
- 'sort_key=1&sort_key=2'), pos=0)
- self.assert_called(
- 'GET', ('/servers/detail?marker=9014&sort_dir=desc&sort_dir=desc&'
'sort_key=1&sort_key=2'))
def test_list_with_sort_keys_and_dirs(self):
self.run_command('list --sort 1:asc,2:desc')
self.assert_called(
'GET', ('/servers/detail?sort_dir=asc&sort_dir=desc&'
- 'sort_key=1&sort_key=2'), pos=0)
- self.assert_called(
- 'GET', ('/servers/detail?marker=9014&sort_dir=asc&sort_dir=desc&'
'sort_key=1&sort_key=2'))
def test_list_with_sort_keys_and_some_dirs(self):
self.run_command('list --sort 1,2:asc')
self.assert_called(
'GET', ('/servers/detail?sort_dir=desc&sort_dir=asc&'
- 'sort_key=1&sort_key=2'), pos=0)
- self.assert_called(
- 'GET', ('/servers/detail?marker=9014&sort_dir=desc&'
- 'sort_dir=asc&sort_key=1&sort_key=2'))
+ 'sort_key=1&sort_key=2'))
def test_list_with_invalid_sort_dir_one(self):
cmd = 'list --sort 1:foo'
@@ -1448,8 +1412,7 @@ class ShellTest(utils.TestCase):
output, _err = self.run_command(
'list --fields '
'host,security_groups,OS-EXT-MOD:some_thing')
- self.assert_called('GET', '/servers/detail', pos=0)
- self.assert_called('GET', '/servers/detail?marker=9014')
+ self.assert_called('GET', '/servers/detail')
self.assertIn('computenode1', output)
self.assertIn('securitygroup1', output)
self.assertIn('OS-EXT-MOD: Some Thing', output)
@@ -1491,8 +1454,7 @@ class ShellTest(utils.TestCase):
def test_list_with_marker(self):
self.run_command('list --marker some-uuid')
- self.assert_called('GET', '/servers/detail?marker=some-uuid', pos=0)
- self.assert_called('GET', '/servers/detail?marker=9014')
+ self.assert_called('GET', '/servers/detail?marker=some-uuid')
def test_list_with_limit(self):
self.run_command('list --limit 3')
@@ -1501,13 +1463,7 @@ class ShellTest(utils.TestCase):
def test_list_with_changes_since(self):
self.run_command('list --changes-since 2016-02-29T06:23:22')
self.assert_called(
- 'GET',
- '/servers/detail?changes-since=2016-02-29T06%3A23%3A22',
- pos=0)
- self.assert_called(
- 'GET',
- ('/servers/detail?changes-since=2016-02-29T06%3A23%3A22&'
- 'marker=9014'))
+ 'GET', '/servers/detail?changes-since=2016-02-29T06%3A23%3A22')
def test_list_with_changes_since_invalid_value(self):
self.assertRaises(exceptions.CommandError,
@@ -1545,14 +1501,12 @@ class ShellTest(utils.TestCase):
output, _err = self.run_command('rebuild sample-server %s'
% FAKE_UUID_1)
self.assert_called('GET', '/servers?name=sample-server', pos=0)
- self.assert_called('GET', '/servers?marker=9014&name=sample-server',
- pos=1)
- self.assert_called('GET', '/servers/1234', pos=2)
- self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_1, pos=3)
+ self.assert_called('GET', '/servers/1234', pos=1)
+ self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_1, pos=2)
self.assert_called('POST', '/servers/1234/action',
- {'rebuild': {'imageRef': FAKE_UUID_1}}, pos=4)
- self.assert_called('GET', '/flavors/1', pos=5)
- self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_2, pos=6)
+ {'rebuild': {'imageRef': FAKE_UUID_1}}, pos=3)
+ self.assert_called('GET', '/flavors/1', pos=4)
+ self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_2, pos=5)
self.assertIn('adminPass', output)
def test_rebuild_password(self):
@@ -1560,73 +1514,63 @@ class ShellTest(utils.TestCase):
' --rebuild-password asdf'
% FAKE_UUID_1)
self.assert_called('GET', '/servers?name=sample-server', pos=0)
- self.assert_called('GET', '/servers?marker=9014&name=sample-server',
- pos=1)
- self.assert_called('GET', '/servers/1234', pos=2)
- self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_1, pos=3)
+ self.assert_called('GET', '/servers/1234', pos=1)
+ self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_1, pos=2)
self.assert_called('POST', '/servers/1234/action',
{'rebuild': {'imageRef': FAKE_UUID_1,
- 'adminPass': 'asdf'}}, pos=4)
- self.assert_called('GET', '/flavors/1', pos=5)
- self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_2, pos=6)
+ 'adminPass': 'asdf'}}, pos=3)
+ self.assert_called('GET', '/flavors/1', pos=4)
+ self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_2, pos=5)
self.assertIn('adminPass', output)
def test_rebuild_preserve_ephemeral(self):
self.run_command('rebuild sample-server %s --preserve-ephemeral'
% FAKE_UUID_1)
self.assert_called('GET', '/servers?name=sample-server', pos=0)
- self.assert_called('GET', '/servers?marker=9014&name=sample-server',
- pos=1)
- self.assert_called('GET', '/servers/1234', pos=2)
- self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_1, pos=3)
+ self.assert_called('GET', '/servers/1234', pos=1)
+ self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_1, pos=2)
self.assert_called('POST', '/servers/1234/action',
{'rebuild': {'imageRef': FAKE_UUID_1,
- 'preserve_ephemeral': True}}, pos=4)
- self.assert_called('GET', '/flavors/1', pos=5)
- self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_2, pos=6)
+ 'preserve_ephemeral': True}}, pos=3)
+ self.assert_called('GET', '/flavors/1', pos=4)
+ self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_2, pos=5)
def test_rebuild_name_meta(self):
self.run_command('rebuild sample-server %s --name asdf --meta '
'foo=bar' % FAKE_UUID_1)
self.assert_called('GET', '/servers?name=sample-server', pos=0)
- self.assert_called('GET', '/servers?marker=9014&name=sample-server',
- pos=1)
- self.assert_called('GET', '/servers/1234', pos=2)
- self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_1, pos=3)
+ self.assert_called('GET', '/servers/1234', pos=1)
+ self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_1, pos=2)
self.assert_called('POST', '/servers/1234/action',
{'rebuild': {'imageRef': FAKE_UUID_1,
'name': 'asdf',
- 'metadata': {'foo': 'bar'}}}, pos=4)
- self.assert_called('GET', '/flavors/1', pos=5)
- self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_2, pos=6)
+ 'metadata': {'foo': 'bar'}}}, pos=3)
+ self.assert_called('GET', '/flavors/1', pos=4)
+ self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_2, pos=5)
def test_rebuild_reset_keypair(self):
self.run_command('rebuild sample-server %s --key-name test_keypair' %
FAKE_UUID_1, api_version='2.54')
self.assert_called('GET', '/servers?name=sample-server', pos=0)
- self.assert_called('GET', '/servers?marker=9014&name=sample-server',
- pos=1)
- self.assert_called('GET', '/servers/1234', pos=2)
- self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_1, pos=3)
+ self.assert_called('GET', '/servers/1234', pos=1)
+ self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_1, pos=2)
self.assert_called('POST', '/servers/1234/action',
{'rebuild': {'imageRef': FAKE_UUID_1,
'key_name': 'test_keypair',
- 'description': None}}, pos=4)
- self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_2, pos=5)
+ 'description': None}}, pos=3)
+ self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_2, pos=4)
def test_rebuild_unset_keypair(self):
self.run_command('rebuild sample-server %s --key-unset' %
FAKE_UUID_1, api_version='2.54')
self.assert_called('GET', '/servers?name=sample-server', pos=0)
- self.assert_called('GET', '/servers?marker=9014&name=sample-server',
- pos=1)
- self.assert_called('GET', '/servers/1234', pos=2)
- self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_1, pos=3)
+ self.assert_called('GET', '/servers/1234', pos=1)
+ self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_1, pos=2)
self.assert_called('POST', '/servers/1234/action',
{'rebuild': {'imageRef': FAKE_UUID_1,
'key_name': None,
- 'description': None}}, pos=4)
- self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_2, pos=5)
+ 'description': None}}, pos=3)
+ self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_2, pos=4)
def test_rebuild_unset_keypair_with_key_name(self):
ex = self.assertRaises(
@@ -1668,29 +1612,25 @@ class ShellTest(utils.TestCase):
FAKE_UUID_1, api_version='2.57')
user_data = servers.ServerManager.transform_userdata('test')
self.assert_called('GET', '/servers?name=sample-server', pos=0)
- self.assert_called('GET', '/servers?marker=9014&name=sample-server',
- pos=1)
- self.assert_called('GET', '/servers/1234', pos=2)
- self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_1, pos=3)
+ self.assert_called('GET', '/servers/1234', pos=1)
+ self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_1, pos=2)
self.assert_called('POST', '/servers/1234/action',
{'rebuild': {'imageRef': FAKE_UUID_1,
'user_data': user_data,
- 'description': None}}, pos=4)
- self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_2, pos=5)
+ 'description': None}}, pos=3)
+ self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_2, pos=4)
def test_rebuild_unset_user_data(self):
self.run_command('rebuild sample-server %s --user-data-unset' %
FAKE_UUID_1, api_version='2.57')
self.assert_called('GET', '/servers?name=sample-server', pos=0)
- self.assert_called('GET', '/servers?marker=9014&name=sample-server',
- pos=1)
- self.assert_called('GET', '/servers/1234', pos=2)
- self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_1, pos=3)
+ self.assert_called('GET', '/servers/1234', pos=1)
+ self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_1, pos=2)
self.assert_called('POST', '/servers/1234/action',
{'rebuild': {'imageRef': FAKE_UUID_1,
'user_data': None,
- 'description': None}}, pos=4)
- self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_2, pos=5)
+ 'description': None}}, pos=3)
+ self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_2, pos=4)
def test_rebuild_user_data_and_unset_user_data(self):
"""Tests that trying to set --user-data and --unset-user-data in the
@@ -1711,11 +1651,7 @@ class ShellTest(utils.TestCase):
self.run_command('start sample-server --all-tenants')
self.assert_called('GET',
'/servers?all_tenants=1&name=sample-server', pos=0)
- self.assert_called('GET',
- ('/servers?all_tenants=1&marker=9014&'
- 'name=sample-server'),
- pos=1)
- self.assert_called('GET', '/servers/1234', pos=2)
+ self.assert_called('GET', '/servers/1234', pos=1)
self.assert_called('POST', '/servers/1234/action', {'os-start': None})
def test_stop(self):
@@ -1726,11 +1662,7 @@ class ShellTest(utils.TestCase):
self.run_command('stop sample-server --all-tenants')
self.assert_called('GET',
'/servers?all_tenants=1&name=sample-server', pos=0)
- self.assert_called('GET',
- ('/servers?all_tenants=1&marker=9014&'
- 'name=sample-server'),
- pos=1)
- self.assert_called('GET', '/servers/1234', pos=2)
+ self.assert_called('GET', '/servers/1234', pos=1)
self.assert_called('POST', '/servers/1234/action', {'os-stop': None})
def test_pause(self):
@@ -1833,12 +1765,10 @@ class ShellTest(utils.TestCase):
def test_show(self):
self.run_command('show 1234')
self.assert_called('GET', '/servers?name=1234', pos=0)
- self.assert_called('GET', '/servers?marker=9014&name=1234', pos=1)
- self.assert_called('GET', '/servers?name=1234', pos=2)
- self.assert_called('GET', '/servers?marker=9014&name=1234', pos=3)
- self.assert_called('GET', '/servers/1234', pos=4)
- self.assert_called('GET', '/flavors/1', pos=5)
- self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_2, pos=6)
+ self.assert_called('GET', '/servers?name=1234', pos=1)
+ self.assert_called('GET', '/servers/1234', pos=2)
+ self.assert_called('GET', '/flavors/1', pos=3)
+ self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_2, pos=4)
def test_show_no_image(self):
self.run_command('show 9012')
@@ -1897,31 +1827,21 @@ class ShellTest(utils.TestCase):
self.run_command('restore sample-server')
self.assert_called('GET',
'/servers?deleted=True&name=sample-server', pos=0)
- self.assert_called('GET',
- ('/servers?deleted=True&marker=9014&'
- 'name=sample-server'),
- pos=1)
- self.assert_called('GET', '/servers/1234', pos=2)
+ self.assert_called('GET', '/servers/1234', pos=1)
self.assert_called('POST', '/servers/1234/action', {'restore': None},
- pos=3)
+ pos=2)
def test_delete_two_with_two_existent(self):
self.run_command('delete 1234 5678')
- self.assert_called('DELETE', '/servers/1234', pos=-7)
+ self.assert_called('DELETE', '/servers/1234', pos=-5)
self.assert_called('DELETE', '/servers/5678', pos=-1)
self.run_command('delete sample-server sample-server2')
self.assert_called('GET',
- '/servers?name=sample-server', pos=-8)
- self.assert_called('GET',
- '/servers?marker=9014&name=sample-server',
- pos=-7)
- self.assert_called('GET', '/servers/1234', pos=-6)
- self.assert_called('DELETE', '/servers/1234', pos=-5)
+ '/servers?name=sample-server', pos=-6)
+ self.assert_called('GET', '/servers/1234', pos=-5)
+ self.assert_called('DELETE', '/servers/1234', pos=-4)
self.assert_called('GET',
'/servers?name=sample-server2',
- pos=-4)
- self.assert_called('GET',
- '/servers?marker=9014&name=sample-server2',
pos=-3)
self.assert_called('GET', '/servers/5678', pos=-2)
self.assert_called('DELETE', '/servers/5678', pos=-1)
@@ -1930,21 +1850,13 @@ class ShellTest(utils.TestCase):
self.run_command('delete sample-server sample-server2 --all-tenants')
self.assert_called('GET',
'/servers?all_tenants=1&name=sample-server', pos=0)
- self.assert_called('GET',
- ('/servers?all_tenants=1&marker=9014&'
- 'name=sample-server'),
- pos=1)
- self.assert_called('GET', '/servers/1234', pos=2)
- self.assert_called('DELETE', '/servers/1234', pos=3)
+ self.assert_called('GET', '/servers/1234', pos=1)
+ self.assert_called('DELETE', '/servers/1234', pos=2)
self.assert_called('GET',
'/servers?all_tenants=1&name=sample-server2',
- pos=4)
- self.assert_called('GET',
- ('/servers?all_tenants=1&marker=9014&'
- 'name=sample-server2'),
- pos=5)
- self.assert_called('GET', '/servers/5678', pos=6)
- self.assert_called('DELETE', '/servers/5678', pos=7)
+ pos=3)
+ self.assert_called('GET', '/servers/5678', pos=4)
+ self.assert_called('DELETE', '/servers/5678', pos=5)
def test_delete_two_with_one_nonexistent(self):
cmd = 'delete 1234 123456789'
@@ -2591,25 +2503,21 @@ class ShellTest(utils.TestCase):
self.run_command('reset-state sample-server --all-tenants')
self.assert_called('GET',
'/servers?all_tenants=1&name=sample-server', pos=0)
- self.assert_called('GET',
- ('/servers?all_tenants=1&marker=9014&'
- 'name=sample-server'),
- pos=1)
- self.assert_called('GET', '/servers/1234', pos=2)
+ self.assert_called('GET', '/servers/1234', pos=1)
self.assert_called('POST', '/servers/1234/action',
{'os-resetState': {'state': 'error'}})
def test_reset_state_multiple(self):
self.run_command('reset-state sample-server sample-server2')
self.assert_called('POST', '/servers/1234/action',
- {'os-resetState': {'state': 'error'}}, pos=-5)
+ {'os-resetState': {'state': 'error'}}, pos=-4)
self.assert_called('POST', '/servers/5678/action',
{'os-resetState': {'state': 'error'}}, pos=-1)
def test_reset_state_active_multiple(self):
self.run_command('reset-state --active sample-server sample-server2')
self.assert_called('POST', '/servers/1234/action',
- {'os-resetState': {'state': 'active'}}, pos=-5)
+ {'os-resetState': {'state': 'active'}}, pos=-4)
self.assert_called('POST', '/servers/5678/action',
{'os-resetState': {'state': 'active'}}, pos=-1)
@@ -3625,8 +3533,7 @@ class ShellTest(utils.TestCase):
def test_list_v2_10(self):
self.run_command('list', api_version='2.10')
- self.assert_called('GET', '/servers/detail', pos=0)
- self.assert_called('GET', '/servers/detail?marker=9014')
+ self.assert_called('GET', '/servers/detail')
def test_server_tag_add(self):
self.run_command('server-tag-add sample-server tag',
@@ -3669,43 +3576,19 @@ class ShellTest(utils.TestCase):
def test_list_v2_26_tags(self):
self.run_command('list --tags tag1,tag2', api_version='2.26')
- self.assert_called(
- 'GET',
- '/servers/detail?tags=tag1%2Ctag2',
- pos=0)
- self.assert_called(
- 'GET',
- '/servers/detail?marker=9014&tags=tag1%2Ctag2')
+ self.assert_called('GET', '/servers/detail?tags=tag1%2Ctag2')
def test_list_v2_26_tags_any(self):
self.run_command('list --tags-any tag1,tag2', api_version='2.26')
- self.assert_called(
- 'GET',
- '/servers/detail?tags-any=tag1%2Ctag2',
- pos=0)
- self.assert_called(
- 'GET',
- '/servers/detail?marker=9014&tags-any=tag1%2Ctag2')
+ self.assert_called('GET', '/servers/detail?tags-any=tag1%2Ctag2')
def test_list_v2_26_not_tags(self):
self.run_command('list --not-tags tag1,tag2', api_version='2.26')
- self.assert_called(
- 'GET',
- '/servers/detail?not-tags=tag1%2Ctag2',
- pos=0)
- self.assert_called(
- 'GET',
- '/servers/detail?marker=9014&not-tags=tag1%2Ctag2')
+ self.assert_called('GET', '/servers/detail?not-tags=tag1%2Ctag2')
def test_list_v2_26_not_tags_any(self):
self.run_command('list --not-tags-any tag1,tag2', api_version='2.26')
- self.assert_called(
- 'GET',
- '/servers/detail?not-tags-any=tag1%2Ctag2',
- pos=0)
- self.assert_called(
- 'GET',
- '/servers/detail?marker=9014&not-tags-any=tag1%2Ctag2')
+ self.assert_called('GET', '/servers/detail?not-tags-any=tag1%2Ctag2')
class PollForStatusTestCase(utils.TestCase):
diff --git a/novaclient/v2/servers.py b/novaclient/v2/servers.py
index 805dd454..79ab0cdc 100644
--- a/novaclient/v2/servers.py
+++ b/novaclient/v2/servers.py
@@ -855,10 +855,7 @@ class ServerManager(base.BootingManagerWithFind):
result.extend(servers)
result.append_request_ids(servers.request_ids)
- if limit and limit != -1:
- limit = max(limit - len(servers), 0)
-
- if not servers or limit == 0:
+ if not servers or limit != -1:
break
marker = result[-1].id
return result
diff --git a/novaclient/v2/shell.py b/novaclient/v2/shell.py
index 53230645..e73bd504 100644
--- a/novaclient/v2/shell.py
+++ b/novaclient/v2/shell.py
@@ -1441,8 +1441,8 @@ def _print_flavor(flavor):
default=None,
help=_("Maximum number of servers to display. If limit == -1, all servers "
"will be displayed. If limit is bigger than 'CONF.api.max_limit' "
- "option of Nova API, multiple requests will be sent and results "
- "will be merged."))
+ "option of Nova API, limit 'CONF.api.max_limit' will be used "
+ "instead."))
@utils.arg(
'--changes-since',
dest='changes_since',