Merge "Revert "Fix listing of instances above API max_limit""
This commit is contained in:
commit
0cb0ffa32d
@ -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
|
||||
|
@ -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):
|
||||
|
@ -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',
|
||||
|
@ -47,44 +47,39 @@ 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_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.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_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)
|
||||
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.assert_called('GET', '/servers')
|
||||
for s in sl:
|
||||
self.assertIsInstance(s, servers.Server)
|
||||
|
||||
@ -94,17 +89,6 @@ class ServersTest(utils.FixturedTestCase):
|
||||
self.assert_called('GET', '/servers/detail?limit=2&marker=1234')
|
||||
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)
|
||||
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')
|
||||
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)
|
||||
|
@ -1345,99 +1345,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'
|
||||
@ -1469,8 +1433,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)
|
||||
@ -1512,8 +1475,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')
|
||||
@ -1522,13 +1484,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,
|
||||
@ -1566,14 +1522,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):
|
||||
@ -1581,73 +1535,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(
|
||||
@ -1689,29 +1633,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
|
||||
@ -1732,11 +1672,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):
|
||||
@ -1747,11 +1683,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):
|
||||
@ -1854,12 +1786,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')
|
||||
@ -1918,31 +1848,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)
|
||||
@ -1951,21 +1871,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'
|
||||
@ -2619,25 +2531,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)
|
||||
|
||||
@ -3659,8 +3567,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',
|
||||
@ -3703,43 +3610,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¬-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¬-tags-any=tag1%2Ctag2')
|
||||
self.assert_called('GET', '/servers/detail?not-tags-any=tag1%2Ctag2')
|
||||
|
||||
|
||||
class PollForStatusTestCase(utils.TestCase):
|
||||
|
@ -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
|
||||
|
@ -1443,8 +1443,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',
|
||||
|
Loading…
Reference in New Issue
Block a user