Added Vitrage actions into Mistral

Implements: blueprint mistral-vitrage-actions

Change-Id: I11068c1f1a0d7ee6973e7c736ba92c475f7d0902
This commit is contained in:
Jaewook Oh 2018-04-23 21:56:16 +09:00
parent 59467da7a8
commit f25fb43177
8 changed files with 73 additions and 2 deletions

View File

@ -127,6 +127,7 @@ python-subunit==1.0.0
python-swiftclient==3.2.0
python-tackerclient==0.8.0
python-troveclient==2.2.0
python-vitrageclient==2.0.0
python-zaqarclient==1.0.0
pytz==2013.6
PyYAML==3.12

View File

@ -21,7 +21,7 @@ SUPPORTED_MODULES = [
'Nova', 'Glance', 'Keystone', 'Heat', 'Neutron', 'Cinder',
'Trove', 'Ironic', 'Baremetal Introspection', 'Swift', 'SwiftService',
'Zaqar', 'Barbican', 'Mistral', 'Designate', 'Magnum', 'Murano', 'Tacker',
'Aodh', 'Gnocchi', 'Glare'
'Aodh', 'Gnocchi', 'Glare', 'Vitrage'
]

View File

@ -70,6 +70,7 @@ swift_client = _try_import('swiftclient.client')
swiftservice = _try_import('swiftclient.service')
tackerclient = _try_import('tackerclient.v1_0.client')
troveclient = _try_import('troveclient.v1.client')
vitrageclient = _try_import('vitrageclient.v1.client')
zaqarclient = _try_import('zaqarclient.queues.client')
@ -908,3 +909,33 @@ class GlareAction(base.OpenStackAction):
@classmethod
def _get_fake_client(cls):
return cls._get_client_class()("http://127.0.0.1:9494/")
class VitrageAction(base.OpenStackAction):
_service_type = 'rca'
@classmethod
def _get_client_class(cls):
return vitrageclient.Client
def _create_client(self, context):
LOG.debug("Vitrage action security context: %s", context)
vitrage_endpoint = self.get_service_endpoint()
endpoint_url = keystone_utils.format_url(
vitrage_endpoint.url,
{'tenant_id': context.project_id}
)
session_and_auth = self.get_session_and_auth(context)
return vitrageclient.Client(
session=session_and_auth['session'],
endpoint_override=endpoint_url
)
@classmethod
def _get_fake_client(cls):
return cls._get_client_class()()

View File

@ -1247,5 +1247,26 @@
"artifacts_upload_blob": "artifacts.upload_blob",
"artifacts_download_blob": "artifacts.download_blob",
"artifacts_add_external_location": "artifacts.add_external_location"
},
"vitrage": {
"_comment": "It uses vitrageclient.v1.",
"alarm_list": "alarm.list",
"alarm_get": "alarm.get",
"alarm_count": "alarm.count",
"event_post": "event.post",
"healthcheck_get": "healthcheck.get",
"rca_get": "rca.get",
"resource_list": "resource.list",
"resource_get": "resource.get",
"template_list": "template.list",
"template_show": "template.show",
"template_add": "template.add",
"template_delete": "template.delete",
"template_validate": "template.validate",
"topology_get": "topology.get",
"webhook_list": "webhook.list",
"webhook_show": "webhook.show",
"webhook_add": "webhook.add",
"webhook_delete": "webhook.delete"
}
}

View File

@ -54,7 +54,8 @@ MODULE_MAPPING = {
'senlin': ['senlin.get_profile', actions.SenlinAction],
'aodh': ['aodh.alarm_list', actions.AodhAction],
'gnocchi': ['gnocchi.metric_list', actions.GnocchiAction],
'glare': ['glare.artifacts_list', actions.GlareAction]
'glare': ['glare.artifacts_list', actions.GlareAction],
'vitrage': ['vitrage.alarm_get', actions.VitrageAction]
}
EXTRA_MODULES = ['neutron', 'swift', 'zaqar', 'tacker']

View File

@ -346,3 +346,16 @@ class OpenStackActionTest(base.BaseTestCase):
self.assertTrue(mocked().artifacts.get.called)
mocked().artifacts.get.assert_called_once_with(artifact_id="1234-abcd")
@mock.patch.object(actions.VitrageAction, '_get_client')
def test_vitrage_action(self, mocked):
mock_ctx = mock.Mock()
method_name = "alarm.get"
action_class = actions.VitrageAction
action_class.client_method_name = method_name
params = {'vitrage_id': '1234-abcd'}
action = action_class(**params)
action.run(mock_ctx)
self.assertTrue(mocked().alarm.get.called)
mocked().alarm.get.assert_called_once_with(vitrage_id="1234-abcd")

View File

@ -0,0 +1,3 @@
---
features:
- Add Mistral actions for OpenStack Vitrage, the RCA service

View File

@ -48,6 +48,7 @@ python-tackerclient>=0.8.0 # Apache-2.0
python-troveclient>=2.2.0 # Apache-2.0
python-ironicclient>=2.3.0 # Apache-2.0
python-ironic-inspector-client>=1.5.0 # Apache-2.0
python-vitrageclient>=2.0.0 # Apache-2.0
python-zaqarclient>=1.0.0 # Apache-2.0
PyJWT>=1.0.1 # MIT
PyYAML>=3.12 # MIT