Merge "Add action check function to senlin plugin"
This commit is contained in:
commit
90bc7ccbda
@ -44,6 +44,17 @@ class SenlinClientPlugin(client_plugin.ClientPlugin):
|
|||||||
spec['type'], spec['version'] = spec_type.split('-')
|
spec['type'], spec['version'] = spec_type.split('-')
|
||||||
return spec
|
return spec
|
||||||
|
|
||||||
|
def check_action_status(self, action_id):
|
||||||
|
action = self.client().get_action(action_id)
|
||||||
|
if action.status == 'SUCCEEDED':
|
||||||
|
return True
|
||||||
|
elif action.status == 'FAILED':
|
||||||
|
raise exception.ResourceInError(
|
||||||
|
status_reason=action.status_reason,
|
||||||
|
resource_status=action.status,
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
def is_not_found(self, ex):
|
def is_not_found(self, ex):
|
||||||
return isinstance(ex, exc.sdkexc.ResourceNotFound)
|
return isinstance(ex, exc.sdkexc.ResourceNotFound)
|
||||||
|
|
||||||
|
@ -20,22 +20,30 @@ from senlinclient.common import exc
|
|||||||
|
|
||||||
|
|
||||||
class SenlinClientPluginTest(common.HeatTestCase):
|
class SenlinClientPluginTest(common.HeatTestCase):
|
||||||
|
def setUp(self):
|
||||||
|
super(SenlinClientPluginTest, self).setUp()
|
||||||
|
context = utils.dummy_context()
|
||||||
|
self.plugin = context.clients.client_plugin('senlin')
|
||||||
|
self.client = self.plugin.client()
|
||||||
|
|
||||||
def test_cluster_get(self):
|
def test_cluster_get(self):
|
||||||
context = utils.dummy_context()
|
self.assertIsNotNone(self.client.clusters)
|
||||||
plugin = context.clients.client_plugin('senlin')
|
|
||||||
client = plugin.client()
|
|
||||||
self.assertIsNotNone(client.clusters)
|
|
||||||
|
|
||||||
def test_is_bad_request(self):
|
def test_is_bad_request(self):
|
||||||
context = utils.dummy_context()
|
self.assertTrue(self.plugin.is_bad_request(
|
||||||
plugin = context.clients.client_plugin('senlin')
|
|
||||||
self.assertTrue(plugin.is_bad_request(
|
|
||||||
exc.sdkexc.HttpException(http_status=400)))
|
exc.sdkexc.HttpException(http_status=400)))
|
||||||
self.assertFalse(plugin.is_bad_request(Exception))
|
self.assertFalse(self.plugin.is_bad_request(Exception))
|
||||||
self.assertFalse(plugin.is_bad_request(
|
self.assertFalse(self.plugin.is_bad_request(
|
||||||
exc.sdkexc.HttpException(http_status=404)))
|
exc.sdkexc.HttpException(http_status=404)))
|
||||||
|
|
||||||
|
def test_check_action_success(self):
|
||||||
|
mock_action = mock.MagicMock()
|
||||||
|
mock_action.status = 'SUCCEEDED'
|
||||||
|
mock_get = self.patchobject(self.client, 'get_action')
|
||||||
|
mock_get.return_value = mock_action
|
||||||
|
self.assertTrue(self.plugin.check_action_status('fake_id'))
|
||||||
|
mock_get.assert_called_once_with('fake_id')
|
||||||
|
|
||||||
|
|
||||||
class ProfileConstraintTest(common.HeatTestCase):
|
class ProfileConstraintTest(common.HeatTestCase):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user