diff --git a/README.rst b/README.rst index 7a7116be4c..1d47642274 100644 --- a/README.rst +++ b/README.rst @@ -38,6 +38,7 @@ We have integration with * https://git.openstack.org/cgit/openstack/python-swiftclient (s3) * https://git.openstack.org/cgit/openstack/python-neutronclient (networking) * https://git.openstack.org/cgit/openstack/python-ceilometerclient (metering) +* https://git.openstack.org/cgit/openstack/python-aodhclient (alarming service) * https://git.openstack.org/cgit/openstack/python-cinderclient (storage service) * https://git.openstack.org/cgit/openstack/python-glanceclient (image service) * https://git.openstack.org/cgit/openstack/python-troveclient (database as a Service) diff --git a/heat/common/config.py b/heat/common/config.py index d4538fb570..8cdaf2e6c3 100644 --- a/heat/common/config.py +++ b/heat/common/config.py @@ -380,8 +380,8 @@ def list_opts(): yield profiler.list_opts()[0] yield 'clients', default_clients_opts - for client in ('barbican', 'ceilometer', 'cinder', 'designate', 'glance', - 'heat', 'keystone', 'magnum', 'manila', 'mistral', + for client in ('aodh', 'barbican', 'ceilometer', 'cinder', 'designate', + 'glance', 'heat', 'keystone', 'magnum', 'manila', 'mistral', 'monasca', 'neutron', 'nova', 'sahara', 'senlin', 'swift', 'trove', 'zaqar' ): diff --git a/heat/engine/clients/os/aodh.py b/heat/engine/clients/os/aodh.py new file mode 100644 index 0000000000..11e2781bd1 --- /dev/null +++ b/heat/engine/clients/os/aodh.py @@ -0,0 +1,50 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from aodhclient import client as ac +from aodhclient import exceptions + +from heat.engine.clients import client_plugin + +CLIENT_NAME = 'aodh' + + +class AodhClientPlugin(client_plugin.ClientPlugin): + + exceptions_module = exceptions + + service_types = [ALARMING] = ['alarming'] + + supported_versions = [V2] = ['2'] + + default_version = V2 + + def _create(self, version=None): + + interface = self._get_client_option(CLIENT_NAME, 'endpoint_type') + + self._keystone_session.auth = self.context.auth_plugin + return ac.Client( + version, + session=self._keystone_session, + interface=interface, + service_type=self.ALARMING) + + def is_not_found(self, ex): + return isinstance(ex, exceptions.NotFound) + + def is_over_limit(self, ex): + return isinstance(ex, exceptions.OverLimit) + + def is_conflict(self, ex): + return isinstance(ex, exceptions.Conflict) diff --git a/heat/tests/clients/test_aodh_client.py b/heat/tests/clients/test_aodh_client.py new file mode 100644 index 0000000000..42c0614d9e --- /dev/null +++ b/heat/tests/clients/test_aodh_client.py @@ -0,0 +1,24 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from heat.tests import common +from heat.tests import utils + + +class AodhClientPluginTest(common.HeatTestCase): + + def test_create(self): + context = utils.dummy_context() + plugin = context.clients.client_plugin('aodh') + client = plugin.client() + self.assertIsNotNone(client.alarm) diff --git a/heat/tests/clients/test_clients.py b/heat/tests/clients/test_clients.py index f29ac39024..c1b0b5c78f 100644 --- a/heat/tests/clients/test_clients.py +++ b/heat/tests/clients/test_clients.py @@ -11,6 +11,7 @@ # License for the specific language governing permissions and limitations # under the License. +from aodhclient import exceptions as aodh_exc from ceilometerclient import exc as ceil_exc from ceilometerclient.openstack.common.apiclient import exceptions as c_a_exc from cinderclient import exceptions as cinder_exc @@ -483,6 +484,30 @@ class TestIsNotFound(common.HeatTestCase): plugin='ceilometer', exception=lambda: ceil_exc.HTTPConflict(), )), + ('aodh_not_found', dict( + is_not_found=True, + is_over_limit=False, + is_client_exception=True, + is_conflict=False, + plugin='aodh', + exception=lambda: aodh_exc.NotFound('not found'), + )), + ('aodh_overlimit', dict( + is_not_found=False, + is_over_limit=True, + is_client_exception=True, + is_conflict=False, + plugin='aodh', + exception=lambda: aodh_exc.OverLimit('over'), + )), + ('aodh_conflict', dict( + is_not_found=False, + is_over_limit=False, + is_client_exception=True, + is_conflict=True, + plugin='aodh', + exception=lambda: aodh_exc.Conflict('conflict'), + )), ('cinder_not_found', dict( is_not_found=True, is_over_limit=False, diff --git a/requirements.txt b/requirements.txt index a9a1f40d67..00d1e710da 100644 --- a/requirements.txt +++ b/requirements.txt @@ -31,6 +31,7 @@ osprofiler>=1.3.0 # Apache-2.0 oslo.versionedobjects>=1.9.1 # Apache-2.0 PasteDeploy>=1.5.0 # MIT pycrypto>=2.6 # Public Domain +aodhclient>=0.5.0 # Apache-2.0 python-barbicanclient>=4.0.0 # Apache-2.0 python-ceilometerclient>=2.2.1 # Apache-2.0 python-cinderclient!=1.7.0,!=1.7.1,>=1.6.0 # Apache-2.0 diff --git a/setup.cfg b/setup.cfg index 8a2021b35b..3b4a3b67b2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -57,6 +57,7 @@ oslo.config.opts.defaults = heat.common.config = heat.common.config:set_config_defaults heat.clients = + aodh = heat.engine.clients.os.aodh:AodhClientPlugin barbican = heat.engine.clients.os.barbican:BarbicanClientPlugin ceilometer = heat.engine.clients.os.ceilometer:CeilometerClientPlugin cinder = heat.engine.clients.os.cinder:CinderClientPlugin