Add missing returns and remove superfluous ones
Some methods which should have returned objects dit not return and some methods which don't return anything used return ... Fixed all that and added tests to detect two returns which were missing. Fixes bug 892058 Change-Id: If59468cfe1c7b1ab74ed0bfc6f81590dfd5dd668
This commit is contained in:
parent
b8e6ec895e
commit
d18954f4a8
1
AUTHORS
1
AUTHORS
@ -13,6 +13,7 @@ Dean Troyer <dtroyer@gmail.com>
|
|||||||
Ed Leafe <ed@leafe.com>
|
Ed Leafe <ed@leafe.com>
|
||||||
Edouard Thuleau <edouard1.thuleau@orange.com>
|
Edouard Thuleau <edouard1.thuleau@orange.com>
|
||||||
Eldar Nugaev <eldr@ya.ru>
|
Eldar Nugaev <eldr@ya.ru>
|
||||||
|
François Charlier <francois.charlier@enovance.com>
|
||||||
Gabriel Hurley <gabriel@strikeawe.com>
|
Gabriel Hurley <gabriel@strikeawe.com>
|
||||||
Gaurav Gupta <gaurav@denali-systems.com>
|
Gaurav Gupta <gaurav@denali-systems.com>
|
||||||
Ilya Alekseyev <ilyaalekseyev@acm.org>
|
Ilya Alekseyev <ilyaalekseyev@acm.org>
|
||||||
|
@ -80,5 +80,5 @@ class FloatingIPDNSManager(base.ManagerWithFind):
|
|||||||
qparams = {'name': name}
|
qparams = {'name': name}
|
||||||
params = "?%s" % urllib.urlencode(qparams) if qparams else ""
|
params = "?%s" % urllib.urlencode(qparams) if qparams else ""
|
||||||
|
|
||||||
return self._delete("/os-floating-ip-dns/%s%s" %
|
self._delete("/os-floating-ip-dns/%s%s" %
|
||||||
(_quote_zone(zone), params))
|
(_quote_zone(zone), params))
|
||||||
|
@ -45,7 +45,7 @@ class FloatingIPManager(base.ManagerWithFind):
|
|||||||
|
|
||||||
:param key: The :class:`Keypair` (or its ID) to delete.
|
:param key: The :class:`Keypair` (or its ID) to delete.
|
||||||
"""
|
"""
|
||||||
return self._delete("/os-floating-ips/%s" % base.getid(floating_ip))
|
self._delete("/os-floating-ips/%s" % base.getid(floating_ip))
|
||||||
|
|
||||||
def get(self, floating_ip):
|
def get(self, floating_ip):
|
||||||
"""
|
"""
|
||||||
|
@ -17,7 +17,7 @@ class Image(base.Resource):
|
|||||||
"""
|
"""
|
||||||
Delete this image.
|
Delete this image.
|
||||||
"""
|
"""
|
||||||
return self.manager.delete(self)
|
self.manager.delete(self)
|
||||||
|
|
||||||
|
|
||||||
class ImageManager(base.ManagerWithFind):
|
class ImageManager(base.ManagerWithFind):
|
||||||
|
@ -54,7 +54,7 @@ class QuotaSetManager(base.ManagerWithFind):
|
|||||||
if body['quota_set'][key] == None:
|
if body['quota_set'][key] == None:
|
||||||
body['quota_set'].pop(key)
|
body['quota_set'].pop(key)
|
||||||
|
|
||||||
return self._update('/os-quota-sets/%s' % (tenant_id), body)
|
self._update('/os-quota-sets/%s' % (tenant_id), body)
|
||||||
|
|
||||||
def defaults(self, tenant_id):
|
def defaults(self, tenant_id):
|
||||||
return self._get('/os-quota-sets/%s/defaults' % tenant_id,
|
return self._get('/os-quota-sets/%s/defaults' % tenant_id,
|
||||||
|
@ -60,4 +60,4 @@ class SecurityGroupRuleManager(base.ManagerWithFind):
|
|||||||
|
|
||||||
:param rule: The security group rule to delete (ID or Class)
|
:param rule: The security group rule to delete (ID or Class)
|
||||||
"""
|
"""
|
||||||
return self._delete('/os-security-group-rules/%s' % base.getid(rule))
|
self._delete('/os-security-group-rules/%s' % base.getid(rule))
|
||||||
|
@ -52,7 +52,7 @@ class SecurityGroupManager(base.ManagerWithFind):
|
|||||||
:param group: The security group to delete (group or ID)
|
:param group: The security group to delete (group or ID)
|
||||||
:rtype: None
|
:rtype: None
|
||||||
"""
|
"""
|
||||||
return self._delete('/os-security-groups/%s' % base.getid(group))
|
self._delete('/os-security-groups/%s' % base.getid(group))
|
||||||
|
|
||||||
def get(self, id):
|
def get(self, id):
|
||||||
"""
|
"""
|
||||||
|
@ -117,11 +117,11 @@ class Server(base.Resource):
|
|||||||
|
|
||||||
def diagnostics(self):
|
def diagnostics(self):
|
||||||
"""Diagnostics -- Retrieve server diagnostics."""
|
"""Diagnostics -- Retrieve server diagnostics."""
|
||||||
self.manager.diagnostics(self)
|
return self.manager.diagnostics(self)
|
||||||
|
|
||||||
def actions(self):
|
def actions(self):
|
||||||
"""Actions -- Retrieve server actions."""
|
"""Actions -- Retrieve server actions."""
|
||||||
self.manager.actions(self)
|
return self.manager.actions(self)
|
||||||
|
|
||||||
def migrate(self):
|
def migrate(self):
|
||||||
"""
|
"""
|
||||||
|
@ -31,7 +31,7 @@ class Snapshot(base.Resource):
|
|||||||
"""
|
"""
|
||||||
Delete this snapshot.
|
Delete this snapshot.
|
||||||
"""
|
"""
|
||||||
return self.manager.delete(self)
|
self.manager.delete(self)
|
||||||
|
|
||||||
|
|
||||||
class SnapshotManager(base.ManagerWithFind):
|
class SnapshotManager(base.ManagerWithFind):
|
||||||
|
@ -31,7 +31,7 @@ class Volume(base.Resource):
|
|||||||
"""
|
"""
|
||||||
Delete this volume.
|
Delete this volume.
|
||||||
"""
|
"""
|
||||||
return self.manager.delete(self)
|
self.manager.delete(self)
|
||||||
|
|
||||||
|
|
||||||
class VolumeManager(base.ManagerWithFind):
|
class VolumeManager(base.ManagerWithFind):
|
||||||
@ -128,5 +128,5 @@ class VolumeManager(base.ManagerWithFind):
|
|||||||
:param server_id: The ID of the server
|
:param server_id: The ID of the server
|
||||||
:param attachment_id: The ID of the attachment
|
:param attachment_id: The ID of the attachment
|
||||||
"""
|
"""
|
||||||
return self._delete("/servers/%s/os-volume_attachments/%s" %
|
self._delete("/servers/%s/os-volume_attachments/%s" %
|
||||||
(server_id, attachment_id,))
|
(server_id, attachment_id,))
|
||||||
|
@ -240,6 +240,23 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||||||
def post_servers_1234_metadata(self, **kw):
|
def post_servers_1234_metadata(self, **kw):
|
||||||
return (204, {'metadata': {'test_key': 'test_value'}})
|
return (204, {'metadata': {'test_key': 'test_value'}})
|
||||||
|
|
||||||
|
def get_servers_1234_diagnostics(self, **kw):
|
||||||
|
return (200, 'Fake diagnostics')
|
||||||
|
|
||||||
|
def get_servers_1234_actions(self, **kw):
|
||||||
|
return (200, {'actions': [
|
||||||
|
{
|
||||||
|
'action': 'rebuild',
|
||||||
|
'error': None,
|
||||||
|
'created_at': '2011-12-30 11:45:36'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'action': 'reboot',
|
||||||
|
'error': 'Failed!',
|
||||||
|
'created_at': '2011-12-30 11:40:29'
|
||||||
|
},
|
||||||
|
]})
|
||||||
|
|
||||||
#
|
#
|
||||||
# Server Addresses
|
# Server Addresses
|
||||||
#
|
#
|
||||||
|
@ -223,3 +223,27 @@ class ServersTest(utils.TestCase):
|
|||||||
cs.servers.get_console_output(s, length=50)
|
cs.servers.get_console_output(s, length=50)
|
||||||
self.assertEqual(cs.servers.get_console_output(s, length=50), success)
|
self.assertEqual(cs.servers.get_console_output(s, length=50), success)
|
||||||
cs.assert_called('POST', '/servers/1234/action')
|
cs.assert_called('POST', '/servers/1234/action')
|
||||||
|
|
||||||
|
def test_get_server_actions(self):
|
||||||
|
s = cs.servers.get(1234)
|
||||||
|
actions = s.actions()
|
||||||
|
self.assertTrue(actions is not None)
|
||||||
|
cs.assert_called('GET', '/servers/1234/actions')
|
||||||
|
|
||||||
|
actions_from_manager = cs.servers.actions(1234)
|
||||||
|
self.assertTrue(actions_from_manager is not None)
|
||||||
|
cs.assert_called('GET', '/servers/1234/actions')
|
||||||
|
|
||||||
|
self.assertEqual(actions, actions_from_manager)
|
||||||
|
|
||||||
|
def test_get_server_diagnostics(self):
|
||||||
|
s = cs.servers.get(1234)
|
||||||
|
diagnostics = s.diagnostics()
|
||||||
|
self.assertTrue(diagnostics is not None)
|
||||||
|
cs.assert_called('GET', '/servers/1234/diagnostics')
|
||||||
|
|
||||||
|
diagnostics_from_manager = cs.servers.diagnostics(1234)
|
||||||
|
self.assertTrue(diagnostics_from_manager is not None)
|
||||||
|
cs.assert_called('GET', '/servers/1234/diagnostics')
|
||||||
|
|
||||||
|
self.assertEqual(diagnostics, diagnostics_from_manager)
|
||||||
|
Loading…
Reference in New Issue
Block a user