Merge "Add aodh actions to mistral"

This commit is contained in:
Jenkins 2016-12-22 14:06:16 +00:00 committed by Gerrit Code Review
commit 8464dcd310
7 changed files with 72 additions and 2 deletions

View File

@ -20,7 +20,7 @@ from mistral.actions.openstack.action_generator import base
SUPPORTED_MODULES = [
'Nova', 'Glance', 'Keystone', 'Heat', 'Neutron', 'Cinder', 'Ceilometer',
'Trove', 'Ironic', 'Baremetal Introspection', 'Swift', 'Zaqar', 'Barbican',
'Mistral', 'Designate', 'Magnum', 'Murano', 'Tacker'
'Mistral', 'Designate', 'Magnum', 'Murano', 'Tacker', 'Aodh'
]

View File

@ -21,6 +21,7 @@ from oslo_utils import importutils
from keystoneclient.auth import identity
from keystoneclient import httpclient
aodhclient = importutils.try_import('aodhclient.v2.client')
barbicanclient = importutils.try_import('barbicanclient.client')
ceilometerclient = importutils.try_import('ceilometerclient.v2.client')
cinderclient = importutils.try_import('cinderclient.v2.client')
@ -797,3 +798,35 @@ class SenlinAction(base.OpenStackAction):
@classmethod
def _get_fake_client(cls):
return cls._get_client_class()("http://127.0.0.1:8778")
class AodhAction(base.OpenStackAction):
@classmethod
def _get_client_class(cls):
return aodhclient.Client
def _create_client(self):
ctx = context.ctx()
LOG.debug("Aodh action security context: %s" % ctx)
aodh_endpoint = keystone_utils.get_endpoint_for_project(
'aodh'
)
endpoint_url = keystone_utils.format_url(
aodh_endpoint.url,
{'tenant_id': ctx.project_id}
)
return self._get_client_class()(
endpoint_url,
region_name=aodh_endpoint.region,
token=ctx.auth_token,
username=ctx.user_name
)
@classmethod
def _get_fake_client(cls):
return cls._get_client_class()()

View File

@ -521,6 +521,20 @@
"trait_descriptions_list": "trait_descriptions.list",
"traits_list": "traits.list"
},
"aodh": {
"_comment": "It uses aodhclient.v2.",
"capabilities_list": "capabilities.list",
"alarm_create": "alarm.create",
"alarm_delete": "alarm.delete",
"alarm_get": "alarm.get",
"alarm_get_state": "alarm.get_state",
"alarm_list": "alarm.list",
"alarm_set_state": "alarm.set_state",
"alarm_update": "alarm.update",
"alarm_query": "alarm.query",
"alarm_history_get": "alarm_history.get",
"alarm_history_search": "alarm_history.search"
},
"neutron": {
"_comment": "It uses neutronclient.v2_0.",
"add_gateway_router": "add_gateway_router",

View File

@ -36,7 +36,8 @@ MODULE_MAPPING = {
'magnum': ['magnum.bays_list', actions.MagnumAction],
'murano': ['murano.deployments_list', actions.MuranoAction],
'tacker': ['tacker.list_vims', actions.TackerAction],
'senlin': ['senlin.get_profile', actions.SenlinAction]
'senlin': ['senlin.get_profile', actions.SenlinAction],
'aodh': ['aodh.alarm_list', actions.AodhAction]
}
EXTRA_MODULES = ['neutron', 'swift', 'zaqar', 'tacker']

View File

@ -373,3 +373,15 @@ class OpenStackActionTest(base.BaseTestCase):
mocked().get_cluster.assert_called_once_with(
cluster_id="1234-abcd"
)
@mock.patch.object(actions.AodhAction, '_get_client')
def test_aodh_action(self, mocked):
method_name = "alarm.get"
action_class = actions.AodhAction
action_class.client_method_name = method_name
params = {'alarm_id': '1234-abcd'}
action = action_class(**params)
action.run()
self.assertTrue(mocked().alarm.get.called)
mocked().alarm.get.assert_called_once_with(alarm_id="1234-abcd")

View File

@ -3,6 +3,7 @@
# process, which may cause wedges in the gate later.
alembic>=0.8.4 # MIT
aodhclient>=0.7.0 # Apache-2.0
Babel>=2.3.4 # BSD
croniter>=0.3.4 # MIT License
cachetools>=1.1.0 # MIT License

View File

@ -18,6 +18,8 @@ import inspect
import json
import os
from aodhclient.v2 import base as aodh_base
from aodhclient.v2 import client as aodhclient
from barbicanclient import base as barbican_base
from barbicanclient import client as barbicanclient
from ceilometerclient.v2 import client as ceilometerclient
@ -86,6 +88,7 @@ BASE_IRONIC_MANAGER = ironic_base.Manager
BASE_BARBICAN_MANAGER = barbican_base.BaseEntityManager
BASE_MAGNUM_MANAGER = magnum_base.Manager
BASE_MURANO_MANAGER = murano_base.Manager
BASE_AODH_MANAGER = aodh_base.Manager
def get_parser():
@ -199,6 +202,10 @@ def get_murano_client(**kwargs):
return muranoclient.Client('')
def get_aodh_client(**kwargs):
return aodhclient.Client('')
CLIENTS = {
'nova': get_nova_client,
'heat': get_heat_client,
@ -213,6 +220,7 @@ CLIENTS = {
'designate': get_designate_client,
'magnum': get_magnum_client,
'murano': get_murano_client,
'aodh': get_aodh_client,
# 'neutron': get_nova_client
# 'baremetal_introspection': ...
# 'swift': ...
@ -232,6 +240,7 @@ BASE_MANAGERS = {
'designate': None,
'magnum': BASE_MAGNUM_MANAGER,
'murano': BASE_MURANO_MANAGER,
'aodh': BASE_AODH_MANAGER,
# 'neutron': BASE_NOVA_MANAGER
# 'baremetal_introspection': ...
# 'swift': ...