Merge "Provide user with coherent interface to get request_ids"
This commit is contained in:
commit
f9360ae6d4
@ -73,21 +73,21 @@ class HostsTest(utils.FixturedTestCase):
|
|||||||
|
|
||||||
def test_host_startup(self):
|
def test_host_startup(self):
|
||||||
host = self.cs.hosts.get('sample_host')[0]
|
host = self.cs.hosts.get('sample_host')[0]
|
||||||
resp, result = host.startup()
|
result = host.startup()
|
||||||
self.assert_request_id(result, fakes.FAKE_REQUEST_ID_LIST)
|
self.assert_request_id(result, fakes.FAKE_REQUEST_ID_LIST)
|
||||||
self.assert_called(
|
self.assert_called(
|
||||||
'GET', '/os-hosts/sample_host/startup')
|
'GET', '/os-hosts/sample_host/startup')
|
||||||
|
|
||||||
def test_host_reboot(self):
|
def test_host_reboot(self):
|
||||||
host = self.cs.hosts.get('sample_host')[0]
|
host = self.cs.hosts.get('sample_host')[0]
|
||||||
resp, result = host.reboot()
|
result = host.reboot()
|
||||||
self.assert_request_id(result, fakes.FAKE_REQUEST_ID_LIST)
|
self.assert_request_id(result, fakes.FAKE_REQUEST_ID_LIST)
|
||||||
self.assert_called(
|
self.assert_called(
|
||||||
'GET', '/os-hosts/sample_host/reboot')
|
'GET', '/os-hosts/sample_host/reboot')
|
||||||
|
|
||||||
def test_host_shutdown(self):
|
def test_host_shutdown(self):
|
||||||
host = self.cs.hosts.get('sample_host')[0]
|
host = self.cs.hosts.get('sample_host')[0]
|
||||||
resp, result = host.shutdown()
|
result = host.shutdown()
|
||||||
self.assert_request_id(result, fakes.FAKE_REQUEST_ID_LIST)
|
self.assert_request_id(result, fakes.FAKE_REQUEST_ID_LIST)
|
||||||
self.assert_called(
|
self.assert_called(
|
||||||
'GET', '/os-hosts/sample_host/shutdown')
|
'GET', '/os-hosts/sample_host/shutdown')
|
||||||
|
@ -597,28 +597,28 @@ class ServersTest(utils.FixturedTestCase):
|
|||||||
|
|
||||||
def test_stop(self):
|
def test_stop(self):
|
||||||
s = self.cs.servers.get(1234)
|
s = self.cs.servers.get(1234)
|
||||||
resp, ret = s.stop()
|
ret = s.stop()
|
||||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||||
self.assert_called('POST', '/servers/1234/action')
|
self.assert_called('POST', '/servers/1234/action')
|
||||||
resp, ret = self.cs.servers.stop(s)
|
ret = self.cs.servers.stop(s)
|
||||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||||
self.assert_called('POST', '/servers/1234/action')
|
self.assert_called('POST', '/servers/1234/action')
|
||||||
|
|
||||||
def test_force_delete(self):
|
def test_force_delete(self):
|
||||||
s = self.cs.servers.get(1234)
|
s = self.cs.servers.get(1234)
|
||||||
resp, ret = s.force_delete()
|
ret = s.force_delete()
|
||||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||||
self.assert_called('POST', '/servers/1234/action')
|
self.assert_called('POST', '/servers/1234/action')
|
||||||
resp, ret = self.cs.servers.force_delete(s)
|
ret = self.cs.servers.force_delete(s)
|
||||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||||
self.assert_called('POST', '/servers/1234/action')
|
self.assert_called('POST', '/servers/1234/action')
|
||||||
|
|
||||||
def test_restore(self):
|
def test_restore(self):
|
||||||
s = self.cs.servers.get(1234)
|
s = self.cs.servers.get(1234)
|
||||||
resp, ret = s.restore()
|
ret = s.restore()
|
||||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||||
self.assert_called('POST', '/servers/1234/action')
|
self.assert_called('POST', '/servers/1234/action')
|
||||||
resp, ret = self.cs.servers.restore(s)
|
ret = self.cs.servers.restore(s)
|
||||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||||
self.assert_called('POST', '/servers/1234/action')
|
self.assert_called('POST', '/servers/1234/action')
|
||||||
|
|
||||||
@ -633,31 +633,31 @@ class ServersTest(utils.FixturedTestCase):
|
|||||||
|
|
||||||
def test_rescue(self):
|
def test_rescue(self):
|
||||||
s = self.cs.servers.get(1234)
|
s = self.cs.servers.get(1234)
|
||||||
resp, ret = s.rescue()
|
ret = s.rescue()
|
||||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||||
self.assert_called('POST', '/servers/1234/action')
|
self.assert_called('POST', '/servers/1234/action')
|
||||||
resp, ret = self.cs.servers.rescue(s)
|
ret = self.cs.servers.rescue(s)
|
||||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||||
self.assert_called('POST', '/servers/1234/action')
|
self.assert_called('POST', '/servers/1234/action')
|
||||||
|
|
||||||
def test_rescue_password(self):
|
def test_rescue_password(self):
|
||||||
s = self.cs.servers.get(1234)
|
s = self.cs.servers.get(1234)
|
||||||
resp, ret = s.rescue(password='asdf')
|
ret = s.rescue(password='asdf')
|
||||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||||
self.assert_called('POST', '/servers/1234/action',
|
self.assert_called('POST', '/servers/1234/action',
|
||||||
{'rescue': {'adminPass': 'asdf'}})
|
{'rescue': {'adminPass': 'asdf'}})
|
||||||
resp, ret = self.cs.servers.rescue(s, password='asdf')
|
ret = self.cs.servers.rescue(s, password='asdf')
|
||||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||||
self.assert_called('POST', '/servers/1234/action',
|
self.assert_called('POST', '/servers/1234/action',
|
||||||
{'rescue': {'adminPass': 'asdf'}})
|
{'rescue': {'adminPass': 'asdf'}})
|
||||||
|
|
||||||
def test_rescue_image(self):
|
def test_rescue_image(self):
|
||||||
s = self.cs.servers.get(1234)
|
s = self.cs.servers.get(1234)
|
||||||
resp, ret = s.rescue(image=1)
|
ret = s.rescue(image=1)
|
||||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||||
self.assert_called('POST', '/servers/1234/action',
|
self.assert_called('POST', '/servers/1234/action',
|
||||||
{'rescue': {'rescue_image_ref': 1}})
|
{'rescue': {'rescue_image_ref': 1}})
|
||||||
resp, ret = self.cs.servers.rescue(s, image=1)
|
ret = self.cs.servers.rescue(s, image=1)
|
||||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||||
self.assert_called('POST', '/servers/1234/action',
|
self.assert_called('POST', '/servers/1234/action',
|
||||||
{'rescue': {'rescue_image_ref': 1}})
|
{'rescue': {'rescue_image_ref': 1}})
|
||||||
@ -768,18 +768,18 @@ class ServersTest(utils.FixturedTestCase):
|
|||||||
|
|
||||||
def test_get_server_diagnostics(self):
|
def test_get_server_diagnostics(self):
|
||||||
s = self.cs.servers.get(1234)
|
s = self.cs.servers.get(1234)
|
||||||
resp, diagnostics = s.diagnostics()
|
diagnostics = s.diagnostics()
|
||||||
self.assert_request_id(diagnostics, fakes.FAKE_REQUEST_ID_LIST)
|
self.assert_request_id(diagnostics, fakes.FAKE_REQUEST_ID_LIST)
|
||||||
self.assertIsNotNone(diagnostics)
|
self.assertIsNotNone(diagnostics)
|
||||||
self.assert_called('GET', '/servers/1234/diagnostics')
|
self.assert_called('GET', '/servers/1234/diagnostics')
|
||||||
|
|
||||||
resp, diagnostics_from_manager = self.cs.servers.diagnostics(1234)
|
diagnostics_from_manager = self.cs.servers.diagnostics(1234)
|
||||||
self.assert_request_id(diagnostics_from_manager,
|
self.assert_request_id(diagnostics_from_manager,
|
||||||
fakes.FAKE_REQUEST_ID_LIST)
|
fakes.FAKE_REQUEST_ID_LIST)
|
||||||
self.assertIsNotNone(diagnostics_from_manager)
|
self.assertIsNotNone(diagnostics_from_manager)
|
||||||
self.assert_called('GET', '/servers/1234/diagnostics')
|
self.assert_called('GET', '/servers/1234/diagnostics')
|
||||||
|
|
||||||
self.assertEqual(diagnostics, diagnostics_from_manager)
|
self.assertEqual(diagnostics[1], diagnostics_from_manager[1])
|
||||||
|
|
||||||
def test_get_vnc_console(self):
|
def test_get_vnc_console(self):
|
||||||
s = self.cs.servers.get(1234)
|
s = self.cs.servers.get(1234)
|
||||||
@ -908,11 +908,11 @@ class ServersTest(utils.FixturedTestCase):
|
|||||||
|
|
||||||
def test_evacuate(self):
|
def test_evacuate(self):
|
||||||
s = self.cs.servers.get(1234)
|
s = self.cs.servers.get(1234)
|
||||||
resp, ret = s.evacuate('fake_target_host', 'True')
|
ret = s.evacuate('fake_target_host', 'True')
|
||||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||||
self.assert_called('POST', '/servers/1234/action')
|
self.assert_called('POST', '/servers/1234/action')
|
||||||
resp, ret = self.cs.servers.evacuate(s, 'fake_target_host',
|
ret = self.cs.servers.evacuate(s, 'fake_target_host',
|
||||||
'False', 'NewAdminPassword')
|
'False', 'NewAdminPassword')
|
||||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||||
self.assert_called('POST', '/servers/1234/action')
|
self.assert_called('POST', '/servers/1234/action')
|
||||||
|
|
||||||
|
@ -74,13 +74,11 @@ class HostManager(base.ManagerWithFind):
|
|||||||
|
|
||||||
:param host: The host to perform an action
|
:param host: The host to perform an action
|
||||||
:param actiob: The action to perform
|
:param actiob: The action to perform
|
||||||
:returns: A Response object and an instance of
|
returns: An instance of novaclient.base.TupleWithMeta
|
||||||
novaclient.base.DictWithMeta
|
|
||||||
"""
|
"""
|
||||||
url = '/os-hosts/{0}/{1}'.format(host, action)
|
url = '/os-hosts/{0}/{1}'.format(host, action)
|
||||||
resp, body = self.api.client.get(url)
|
resp, body = self.api.client.get(url)
|
||||||
# For compatibility, return Response object as a first return value
|
return base.TupleWithMeta((resp, body), resp)
|
||||||
return resp, self.convert_into_with_meta(body, resp)
|
|
||||||
|
|
||||||
def list(self, zone=None):
|
def list(self, zone=None):
|
||||||
url = '/os-hosts'
|
url = '/os-hosts'
|
||||||
|
@ -166,8 +166,7 @@ class Server(base.Resource):
|
|||||||
"""
|
"""
|
||||||
Stop -- Stop the running server.
|
Stop -- Stop the running server.
|
||||||
|
|
||||||
:returns: A Response object and an instance of
|
:returns: An instance of novaclient.base.TupleWithMeta
|
||||||
novaclient.base.TupleWithMeta
|
|
||||||
"""
|
"""
|
||||||
return self.manager.stop(self)
|
return self.manager.stop(self)
|
||||||
|
|
||||||
@ -175,8 +174,7 @@ class Server(base.Resource):
|
|||||||
"""
|
"""
|
||||||
Force delete -- Force delete a server.
|
Force delete -- Force delete a server.
|
||||||
|
|
||||||
:returns: A Response object and an instance of
|
:returns: An instance of novaclient.base.TupleWithMeta
|
||||||
novaclient.base.TupleWithMeta
|
|
||||||
"""
|
"""
|
||||||
return self.manager.force_delete(self)
|
return self.manager.force_delete(self)
|
||||||
|
|
||||||
@ -184,8 +182,7 @@ class Server(base.Resource):
|
|||||||
"""
|
"""
|
||||||
Restore -- Restore a server in 'soft-deleted' state.
|
Restore -- Restore a server in 'soft-deleted' state.
|
||||||
|
|
||||||
:returns: A Response object and an instance of
|
:returns: An instance of novaclient.base.TupleWithMeta
|
||||||
novaclient.base.TupleWithMeta
|
|
||||||
"""
|
"""
|
||||||
return self.manager.restore(self)
|
return self.manager.restore(self)
|
||||||
|
|
||||||
@ -251,8 +248,7 @@ class Server(base.Resource):
|
|||||||
|
|
||||||
:param password: The admin password to be set in the rescue instance.
|
:param password: The admin password to be set in the rescue instance.
|
||||||
:param image: The :class:`Image` to rescue with.
|
:param image: The :class:`Image` to rescue with.
|
||||||
:returns: A Response object and an instance of
|
:returns: An instance of novaclient.base.TupleWithMeta
|
||||||
novaclient.base.DictWithMeta
|
|
||||||
"""
|
"""
|
||||||
return self.manager.rescue(self, password, image)
|
return self.manager.rescue(self, password, image)
|
||||||
|
|
||||||
@ -494,8 +490,7 @@ class Server(base.Resource):
|
|||||||
parameter must have its default value of None.
|
parameter must have its default value of None.
|
||||||
:param password: string to set as admin password on the evacuated
|
:param password: string to set as admin password on the evacuated
|
||||||
server.
|
server.
|
||||||
:returns: A Response object and an instance of
|
:returns: An instance of novaclient.base.TupleWithMeta
|
||||||
novaclient.base.TupleWithMeta
|
|
||||||
"""
|
"""
|
||||||
if api_versions.APIVersion("2.14") <= self.manager.api_version:
|
if api_versions.APIVersion("2.14") <= self.manager.api_version:
|
||||||
if on_shared_storage is not None:
|
if on_shared_storage is not None:
|
||||||
@ -974,34 +969,31 @@ class ServerManager(base.BootingManagerWithFind):
|
|||||||
Stop the server.
|
Stop the server.
|
||||||
|
|
||||||
:param server: The :class:`Server` (or its ID) to stop
|
:param server: The :class:`Server` (or its ID) to stop
|
||||||
:returns: A Response object and an instance of
|
:returns: An instance of novaclient.base.TupleWithMeta
|
||||||
novaclient.base.TupleWithMeta
|
|
||||||
"""
|
"""
|
||||||
resp, body = self._action_return_resp_and_body('os-stop', server, None)
|
resp, body = self._action_return_resp_and_body('os-stop', server, None)
|
||||||
return resp, self.convert_into_with_meta(body, resp)
|
return base.TupleWithMeta((resp, body), resp)
|
||||||
|
|
||||||
def force_delete(self, server):
|
def force_delete(self, server):
|
||||||
"""
|
"""
|
||||||
Force delete the server.
|
Force delete the server.
|
||||||
|
|
||||||
:param server: The :class:`Server` (or its ID) to force delete
|
:param server: The :class:`Server` (or its ID) to force delete
|
||||||
:returns: A Response object and an instance of
|
:returns: An instance of novaclient.base.TupleWithMeta
|
||||||
novaclient.base.TupleWithMeta
|
|
||||||
"""
|
"""
|
||||||
resp, body = self._action_return_resp_and_body('forceDelete', server,
|
resp, body = self._action_return_resp_and_body('forceDelete', server,
|
||||||
None)
|
None)
|
||||||
return resp, self.convert_into_with_meta(body, resp)
|
return base.TupleWithMeta((resp, body), resp)
|
||||||
|
|
||||||
def restore(self, server):
|
def restore(self, server):
|
||||||
"""
|
"""
|
||||||
Restore soft-deleted server.
|
Restore soft-deleted server.
|
||||||
|
|
||||||
:param server: The :class:`Server` (or its ID) to restore
|
:param server: The :class:`Server` (or its ID) to restore
|
||||||
:returns: A Response object and an instance of
|
:returns: An instance of novaclient.base.TupleWithMeta
|
||||||
novaclient.base.TupleWithMeta
|
|
||||||
"""
|
"""
|
||||||
resp, body = self._action_return_resp_and_body('restore', server, None)
|
resp, body = self._action_return_resp_and_body('restore', server, None)
|
||||||
return resp, self.convert_into_with_meta(body, resp)
|
return base.TupleWithMeta((resp, body), resp)
|
||||||
|
|
||||||
def start(self, server):
|
def start(self, server):
|
||||||
"""
|
"""
|
||||||
@ -1073,8 +1065,7 @@ class ServerManager(base.BootingManagerWithFind):
|
|||||||
:param server: The :class:`Server` to rescue.
|
:param server: The :class:`Server` to rescue.
|
||||||
:param password: The admin password to be set in the rescue instance.
|
:param password: The admin password to be set in the rescue instance.
|
||||||
:param image: The :class:`Image` to rescue with.
|
:param image: The :class:`Image` to rescue with.
|
||||||
:returns: A Response object and an instance of
|
:returns: An instance of novaclient.base.TupleWithMeta
|
||||||
novaclient.base.DictWithMeta
|
|
||||||
"""
|
"""
|
||||||
info = {}
|
info = {}
|
||||||
if password:
|
if password:
|
||||||
@ -1083,8 +1074,7 @@ class ServerManager(base.BootingManagerWithFind):
|
|||||||
info['rescue_image_ref'] = base.getid(image)
|
info['rescue_image_ref'] = base.getid(image)
|
||||||
resp, body = self._action_return_resp_and_body('rescue', server,
|
resp, body = self._action_return_resp_and_body('rescue', server,
|
||||||
info or None)
|
info or None)
|
||||||
# For compatibility, return Response object as a first return value
|
return base.TupleWithMeta((resp, body), resp)
|
||||||
return resp, base.DictWithMeta(body, resp)
|
|
||||||
|
|
||||||
def unrescue(self, server):
|
def unrescue(self, server):
|
||||||
"""
|
"""
|
||||||
@ -1142,13 +1132,11 @@ class ServerManager(base.BootingManagerWithFind):
|
|||||||
|
|
||||||
:param server: The :class:`Server` (or its ID) for which
|
:param server: The :class:`Server` (or its ID) for which
|
||||||
diagnostics to be returned
|
diagnostics to be returned
|
||||||
:returns: A Respose object and an instance of
|
:returns: An instance of novaclient.base.TupleWithMeta
|
||||||
novaclient.base.DictWithMeta
|
|
||||||
"""
|
"""
|
||||||
resp, body = self.api.client.get("/servers/%s/diagnostics" %
|
resp, body = self.api.client.get("/servers/%s/diagnostics" %
|
||||||
base.getid(server))
|
base.getid(server))
|
||||||
# For compatibility, return Response object as a first return value
|
return base.TupleWithMeta((resp, body), resp)
|
||||||
return resp, base.DictWithMeta(body, resp)
|
|
||||||
|
|
||||||
def create(self, name, image, flavor, meta=None, files=None,
|
def create(self, name, image, flavor, meta=None, files=None,
|
||||||
reservation_id=None, min_count=None,
|
reservation_id=None, min_count=None,
|
||||||
@ -1605,8 +1593,7 @@ class ServerManager(base.BootingManagerWithFind):
|
|||||||
:param on_shared_storage: Specifies whether instance files located
|
:param on_shared_storage: Specifies whether instance files located
|
||||||
on shared storage
|
on shared storage
|
||||||
:param password: string to set as password on the evacuated server.
|
:param password: string to set as password on the evacuated server.
|
||||||
:returns: A Response object and an instance of
|
:returns: An instance of novaclient.base.TupleWithMeta
|
||||||
novaclient.base.TupleWithMeta
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
body = {'onSharedStorage': on_shared_storage}
|
body = {'onSharedStorage': on_shared_storage}
|
||||||
@ -1618,7 +1605,7 @@ class ServerManager(base.BootingManagerWithFind):
|
|||||||
|
|
||||||
resp, body = self._action_return_resp_and_body('evacuate', server,
|
resp, body = self._action_return_resp_and_body('evacuate', server,
|
||||||
body)
|
body)
|
||||||
return resp, self.convert_into_with_meta(body, resp)
|
return base.TupleWithMeta((resp, body), resp)
|
||||||
|
|
||||||
@api_versions.wraps("2.14")
|
@api_versions.wraps("2.14")
|
||||||
def evacuate(self, server, host=None, password=None):
|
def evacuate(self, server, host=None, password=None):
|
||||||
@ -1628,6 +1615,7 @@ class ServerManager(base.BootingManagerWithFind):
|
|||||||
:param server: The :class:`Server` (or its ID) to share onto.
|
:param server: The :class:`Server` (or its ID) to share onto.
|
||||||
:param host: Name of the target host.
|
:param host: Name of the target host.
|
||||||
:param password: string to set as password on the evacuated server.
|
:param password: string to set as password on the evacuated server.
|
||||||
|
:returns: An instance of novaclient.base.TupleWithMeta
|
||||||
"""
|
"""
|
||||||
|
|
||||||
body = {}
|
body = {}
|
||||||
@ -1639,7 +1627,7 @@ class ServerManager(base.BootingManagerWithFind):
|
|||||||
|
|
||||||
resp, body = self._action_return_resp_and_body('evacuate', server,
|
resp, body = self._action_return_resp_and_body('evacuate', server,
|
||||||
body)
|
body)
|
||||||
return resp, self.convert_into_with_meta(body, resp)
|
return base.TupleWithMeta((resp, body), resp)
|
||||||
|
|
||||||
def interface_list(self, server):
|
def interface_list(self, server):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user