Merge "Optimize EResourceOperation"

This commit is contained in:
Jenkins
2016-09-11 01:28:51 +00:00
committed by Gerrit Code Review
3 changed files with 17 additions and 5 deletions

View File

@@ -244,8 +244,20 @@ class EResourceDeletion(InternalError):
class EResourceOperation(InternalError):
"""Generic exception for resource fail operation.
The op here can be 'recovering','rebuilding', 'checking' and
so on. And the op 'creating', 'updating' and 'deleting' we can
use separately class `EResourceCreation`,`EResourceUpdate` and
`EResourceDeletion`.
The type here is resource's dirver type.It can be 'server',
'stack', 'container' and so on.
The id is resource's id.
The message here can be message from class 'ResourceNotFound',
'ResourceInUse' and so on, or developer can specified message.
"""
# Used when operating resources from other services
msg_fmt = _("Failed in %(op)s %(type)s %(id)s: %(message)s")
msg_fmt = _("Failed in %(op)s %(type)s %(id)s: %(message)s.")
class InvalidPlugin(InternalError):

View File

@@ -598,7 +598,7 @@ class TestNode(base.SenlinTestCase):
mock_status.assert_called_once_with(
self.context,
node.ERROR,
'Failed in checking server %s: failed get' % node.physical_id)
'Failed in checking server %s: failed get.' % node.physical_id)
def test_node_check_no_physical_id(self):
node = nodem.Node('node1', PROFILE_ID, '')

View File

@@ -842,7 +842,7 @@ class TestNovaServerBasic(base.SenlinTestCase):
node_obj)
self.assertEqual('Failed in rebuilding server FAKE_ID: '
'FAKE_ID not found',
'FAKE_ID not found.',
six.text_type(ex))
cc.server_get.assert_called_once_with('FAKE_ID')
@@ -862,7 +862,7 @@ class TestNovaServerBasic(base.SenlinTestCase):
node_obj)
self.assertEqual('Failed in rebuilding server FAKE_ID: '
'cannot rebuild',
'cannot rebuild.',
six.text_type(ex))
cc.server_get.assert_called_once_with('FAKE_ID')
cc.server_rebuild.assert_called_once_with('FAKE_ID', '123',
@@ -885,7 +885,7 @@ class TestNovaServerBasic(base.SenlinTestCase):
profile.do_rebuild,
node_obj)
self.assertEqual('Failed in rebuilding server FAKE_ID: timeout',
self.assertEqual('Failed in rebuilding server FAKE_ID: timeout.',
six.text_type(ex))
cc.server_get.assert_called_once_with('FAKE_ID')
cc.server_rebuild.assert_called_once_with('FAKE_ID', '123',