Fix log exception

When running the test
...test_cluster.ClusteredAPITestCase.test_cluster_proxy_stale_revision
we get the exception below:

Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 851, in emit
    msg = self.format(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 724, in format
    return fmt.format(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 464, in format
    record.message = record.getMessage()
  File "/usr/lib/python2.7/logging/__init__.py", line 328, in getMessage
    msg = msg % self.args
  File "/home/gkotton/vmware-nsx/.tox/py27/local/lib/python2.7/site-packages/neutron_lib/exceptions.py", line 48, in __unicode__
    return unicode(self.msg)
AttributeError: 'StaleRevision' object has no attribute 'msg'
Logged from file cluster.py, line 418

Change-Id: I4ce6b90b3dbd2fd1a2987fafb1034fdd0cd05a60
This commit is contained in:
Gary Kotton 2016-02-15 01:38:09 -08:00
parent c2e7627625
commit 640ac29a1e
2 changed files with 3 additions and 1 deletions

View File

@ -136,6 +136,7 @@ class ManagerError(NsxPluginException):
if 'details' in kwargs
else '')
super(ManagerError, self).__init__(**kwargs)
self.msg = self.message % kwargs
class ResourceNotFound(ManagerError):

View File

@ -196,7 +196,8 @@ class ClusteredAPITestCase(nsxlib_testcase.NsxClientTestCase):
def test_cluster_proxy_stale_revision(self):
def stale_revision():
raise nsx_exc.StaleRevision()
raise nsx_exc.StaleRevision(manager='1.1.1.1',
operation='whatever')
api = self.mock_nsx_clustered_api(session_response=stale_revision)
self.assertRaises(nsx_exc.StaleRevision,