Correct NotImplemented to NotImplementedError in rpcapi.py
NotImplemented will not return any useful info to end-user. This should be NotImplementedError. Change-Id: I4402a1f4f5fd47fd7230359a5c2eb03123f993fa Close-Bug: #1524163
This commit is contained in:
parent
1f97a7d67e
commit
1171e25d1d
@ -606,13 +606,15 @@ class ConductorAPI(object):
|
||||
:param object_versions: A dict of {objname: version} mappings
|
||||
:param args: The positional arguments to the action method
|
||||
:param kwargs: The keyword arguments to the action method
|
||||
:raises: NotImplemented when an operator makes an error during upgrade
|
||||
:raises: NotImplementedError when an operator makes an error during
|
||||
upgrade
|
||||
:returns: The result of the action method, which may (or may not)
|
||||
be an instance of the implementing VersionedObject class.
|
||||
"""
|
||||
if not self.client.can_send_version('1.31'):
|
||||
raise NotImplemented(_('Incompatible conductor version - '
|
||||
'please upgrade ironic-conductor first'))
|
||||
raise NotImplementedError(_('Incompatible conductor version - '
|
||||
'please upgrade ironic-conductor '
|
||||
'first'))
|
||||
cctxt = self.client.prepare(topic=self.topic, version='1.31')
|
||||
return cctxt.call(context, 'object_class_action_versions',
|
||||
objname=objname, objmethod=objmethod,
|
||||
@ -630,13 +632,15 @@ class ConductorAPI(object):
|
||||
:param objmethod: The name of the action method to call
|
||||
:param args: The positional arguments to the action method
|
||||
:param kwargs: The keyword arguments to the action method
|
||||
:raises: NotImplemented when an operator makes an error during upgrade
|
||||
:raises: NotImplementedError when an operator makes an error during
|
||||
upgrade
|
||||
:returns: A tuple with the updates made to the object and
|
||||
the result of the action method
|
||||
"""
|
||||
if not self.client.can_send_version('1.31'):
|
||||
raise NotImplemented(_('Incompatible conductor version - '
|
||||
'please upgrade ironic-conductor first'))
|
||||
raise NotImplementedError(_('Incompatible conductor version - '
|
||||
'please upgrade ironic-conductor '
|
||||
'first'))
|
||||
cctxt = self.client.prepare(topic=self.topic, version='1.31')
|
||||
return cctxt.call(context, 'object_action', objinst=objinst,
|
||||
objmethod=objmethod, args=args, kwargs=kwargs)
|
||||
@ -654,12 +658,14 @@ class ConductorAPI(object):
|
||||
:param context: The context within which to perform the backport
|
||||
:param objinst: An instance of a VersionedObject to be backported
|
||||
:param object_versions: A dict of {objname: version} mappings
|
||||
:raises: NotImplemented when an operator makes an error during upgrade
|
||||
:raises: NotImplementedError when an operator makes an error during
|
||||
upgrade
|
||||
:returns: The downgraded instance of objinst
|
||||
"""
|
||||
if not self.client.can_send_version('1.31'):
|
||||
raise NotImplemented(_('Incompatible conductor version - '
|
||||
'please upgrade ironic-conductor first'))
|
||||
raise NotImplementedError(_('Incompatible conductor version - '
|
||||
'please upgrade ironic-conductor '
|
||||
'first'))
|
||||
cctxt = self.client.prepare(topic=self.topic, version='1.31')
|
||||
return cctxt.call(context, 'object_backport_versions', objinst=objinst,
|
||||
object_versions=object_versions)
|
||||
|
@ -22,6 +22,7 @@ import copy
|
||||
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
import oslo_messaging as messaging
|
||||
from oslo_messaging import _utils as messaging_utils
|
||||
|
||||
from ironic.common import boot_devices
|
||||
@ -342,3 +343,31 @@ class RPCAPITestCase(base.DbTestCase):
|
||||
version='1.31',
|
||||
objinst='fake-object',
|
||||
object_versions={'fake-object': '1.0'})
|
||||
|
||||
@mock.patch.object(messaging.RPCClient, 'can_send_version', autospec=True)
|
||||
def test_object_action_invalid_version(self, mock_send):
|
||||
rpcapi = conductor_rpcapi.ConductorAPI(topic='fake-topic')
|
||||
mock_send.return_value = False
|
||||
self.assertRaises(NotImplementedError,
|
||||
rpcapi.object_action, self.context,
|
||||
objinst='fake-object', objmethod='foo',
|
||||
args=tuple(), kwargs=dict())
|
||||
|
||||
@mock.patch.object(messaging.RPCClient, 'can_send_version', autospec=True)
|
||||
def test_object_class_action_versions_invalid_version(self, mock_send):
|
||||
rpcapi = conductor_rpcapi.ConductorAPI(topic='fake-topic')
|
||||
mock_send.return_value = False
|
||||
self.assertRaises(NotImplementedError,
|
||||
rpcapi.object_class_action_versions, self.context,
|
||||
objname='fake-object', objmethod='foo',
|
||||
object_versions={'fake-object': '1.0'},
|
||||
args=tuple(), kwargs=dict())
|
||||
|
||||
@mock.patch.object(messaging.RPCClient, 'can_send_version', autospec=True)
|
||||
def test_object_backport_versions_invalid_version(self, mock_send):
|
||||
rpcapi = conductor_rpcapi.ConductorAPI(topic='fake-topic')
|
||||
mock_send.return_value = False
|
||||
self.assertRaises(NotImplementedError,
|
||||
rpcapi.object_backport_versions, self.context,
|
||||
objinst='fake-object',
|
||||
object_versions={'fake-object': '1.0'})
|
||||
|
@ -0,0 +1,7 @@
|
||||
---
|
||||
fixes:
|
||||
- In conductor/rpcapi.py, object_backport_version(),
|
||||
object_action() and object_class_action_versions()
|
||||
misspell NotImplementedError with NotImplemented
|
||||
which returns nothing useful to users.
|
||||
See https://bugs.launchpad.net/ironic/+bug/1524163.
|
Loading…
Reference in New Issue
Block a user