Relocate alarm service into a submodule

This patch moves the resources of the alarm service (aodh) into a
submodule of the telemetry, as a service that can be addressed using
'alarm' as service type.

Change-Id: I0c2521443225e41b4090ee7ecb5f095072b1fc95
This commit is contained in:
tengqm
2016-06-03 04:55:35 -04:00
parent 97cc2a9398
commit 93ab24b7ea
22 changed files with 284 additions and 176 deletions

View File

@@ -68,6 +68,7 @@ from openstack import module_loader
from openstack.network import network_service
from openstack.object_store import object_store_service
from openstack.orchestration import orchestration_service
from openstack.telemetry.alarm import alarm_service
from openstack.telemetry import telemetry_service
_logger = logging.getLogger(__name__)
@@ -89,23 +90,22 @@ class Profile(object):
'compute', etc.
"""
self._services = {}
self._add_service(alarm_service.AlarmService(version="v2"))
self._add_service(block_store_service.BlockStoreService(version="v2"))
self._add_service(cluster_service.ClusterService(version="v1"))
self._add_service(compute_service.ComputeService(version="v2"))
self._add_service(database_service.DatabaseService(version="v1"))
self._add_service(identity_service.IdentityService(version="v3"))
self._add_service(image_service.ImageService(version="v2"))
self._add_service(key_manager_service.KeyManagerService(version="v1"))
self._add_service(message_service.MessageService(version="v1"))
self._add_service(network_service.NetworkService(version="v2"))
self._add_service(
object_store_service.ObjectStoreService(version="v1"))
self._add_service(
orchestration_service.OrchestrationService(version="v1"))
self._add_service(key_manager_service.KeyManagerService(version="v1"))
self._add_service(telemetry_service.TelemetryService(version="v1"))
self._add_service(block_store_service.BlockStoreService(version="v2"))
self._add_service(message_service.MessageService(version="v1"))
# NOTE: The Metric service is not added here as it currently
# only retrieves the /capabilities API.
if plugins:
for plugin in plugins:

View File

@@ -188,4 +188,4 @@ class ServiceFilter(dict):
object store where the service type is `object-store` and the module
is `object_store`.
"""
return self.__class__.__module__.split('.')[1]
return self.__class__.__module__.split('.')[-2]

View File

View File

@@ -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 openstack import service_filter
class AlarmService(service_filter.ServiceFilter):
"""The alarm service."""
valid_versions = [service_filter.ValidVersion('v2')]
def __init__(self, version=None):
"""Create an alarm service."""
super(AlarmService, self).__init__(service_type='alarming',
version=version)

View File

View File

@@ -0,0 +1,129 @@
# 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 openstack import proxy
from openstack.telemetry.alarm.v2 import alarm as _alarm
from openstack.telemetry.alarm.v2 import alarm_change as _alarm_change
class Proxy(proxy.BaseProxy):
""".. caution:: This API is a work in progress and is subject to change."""
def create_alarm(self, **attrs):
"""Create a new alarm from attributes
:param dict attrs: Keyword arguments which will be used to create
a :class:`~openstack.telemetry.v2.alarm.Alarm`,
comprised of the properties on the Alarm class.
:returns: The results of alarm creation
:rtype: :class:`~openstack.telemetry.v2.alarm.Alarm`
"""
return self._create(_alarm.Alarm, **attrs)
def delete_alarm(self, alarm, ignore_missing=True):
"""Delete an alarm
:param alarm: The value can be either the ID of an alarm or a
:class:`~openstack.telemetry.v2.alarm.Alarm` instance.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the alarm does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent alarm.
:returns: ``None``
"""
self._delete(_alarm.Alarm, alarm, ignore_missing=ignore_missing)
def find_alarm(self, name_or_id, ignore_missing=True):
"""Find a single alarm
:param name_or_id: The name or ID of a alarm.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the resource does not exist.
When set to ``True``, None will be returned when
attempting to find a nonexistent resource.
:returns: One :class:`~openstack.telemetry.v2.alarm.Alarm` or None
"""
return self._find(_alarm.Alarm, name_or_id,
ignore_missing=ignore_missing)
def get_alarm(self, alarm):
"""Get a single alarm
:param alarm: The value can be the ID of an alarm or a
:class:`~openstack.telemetry.v2.alarm.Alarm` instance.
:returns: One :class:`~openstack.telemetry.v2.alarm.Alarm`
:raises: :class:`~openstack.exceptions.ResourceNotFound`
when no resource can be found.
"""
return self._get(_alarm.Alarm, alarm)
def alarms(self, **query):
"""Return a generator of alarms
:param kwargs \*\*query: Optional query parameters to be sent to limit
the resources being returned.
:returns: A generator of alarm objects
:rtype: :class:`~openstack.telemetry.v2.alarm.Alarm`
"""
# TODO(Qiming): Check the alarm service API docs/code to verify if
# the parameters need a change.
return self._list(_alarm.Alarm, paginated=False, **query)
def update_alarm(self, alarm, **attrs):
"""Update a alarm
:param alarm: Either the id of a alarm or a
:class:`~openstack.telemetry.v2.alarm.Alarm` instance.
:attrs kwargs: The attributes to update on the alarm represented
by ``value``.
:returns: The updated alarm
:rtype: :class:`~openstack.telemetry.v2.alarm.Alarm`
"""
return self._update(_alarm.Alarm, alarm, **attrs)
def find_alarm_change(self, name_or_id, ignore_missing=True):
"""Find a single alarm change
:param name_or_id: The name or ID of a alarm change.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the resource does not exist.
When set to ``True``, None will be returned when
attempting to find a nonexistent resource.
:returns: One :class:`~openstack.telemetry.v2.alarm_change.AlarmChange`
or None
"""
return self._find(_alarm_change.AlarmChange, name_or_id,
ignore_missing=ignore_missing)
def alarm_changes(self, alarm, **query):
"""Return a generator of alarm changes
:param alarm: Alarm resource or id for alarm.
:param kwargs \*\*query: Optional query parameters to be sent to limit
the resources being returned.
:returns: A generator of alarm change objects
:rtype: :class:`~openstack.telemetry.v2.alarm_change.AlarmChange`
"""
# TODO(Qiming): Check the alarm service API docs/code to verify if
# the parameters need a change.
alarm_id = _alarm.Alarm.from_id(alarm).id
return self._list(_alarm_change.AlarmChange, paginated=False,
path_args={'alarm_id': alarm_id}, **query)

View File

@@ -11,7 +11,7 @@
# under the License.
from openstack import resource
from openstack.telemetry import telemetry_service
from openstack.telemetry.alarm import alarm_service
from openstack import utils
@@ -19,7 +19,7 @@ class Alarm(resource.Resource):
""".. caution:: This API is a work in progress and is subject to change."""
id_attribute = 'alarm_id'
base_path = '/alarms'
service = telemetry_service.TelemetryService()
service = alarm_service.AlarmService()
# Supported Operations
allow_create = True
@@ -55,6 +55,7 @@ class Alarm(resource.Resource):
#: The state off the alarm
state = resource.prop('state')
#: The timestamp of the last alarm state change.
#: *Type: ISO 8601 formatted string*
state_changed_at = resource.prop('state_timestamp')
# TODO(briancurtin): undocumented
threshold_rule = resource.prop('threshold_rule', type=dict)
@@ -63,6 +64,7 @@ class Alarm(resource.Resource):
#: Explicit type specifier to select which rule to follow
type = resource.prop('type')
#: The timestamp of the last alarm definition update.
#: *Type: ISO 8601 formatted string*
updated_at = resource.prop('timestamp')
#: The ID of the user who created the alarm
user_id = resource.prop('user_id')
@@ -70,7 +72,8 @@ class Alarm(resource.Resource):
def change_state(self, session, next_state):
"""Set the state of an alarm.
The next_state may be one of: 'ok' 'insufficient data' 'alarm'
:param next_state: The valid values can be one of: ``ok``, ``alarm``,
``insufficient data``.
"""
url = utils.urljoin(self.base_path, self.id, 'state')
resp = session.put(url, endpoint_filter=self.service, json=next_state)
@@ -79,7 +82,7 @@ class Alarm(resource.Resource):
def check_state(self, session):
"""Retrieve the current state of an alarm from the service.
The properties of the alarm are not modified.
The properties of the alarm are not modified.
"""
url = utils.urljoin(self.base_path, self.id, 'state')
resp = session.get(url, endpoint_filter=self.service)

View File

@@ -11,7 +11,7 @@
# under the License.
from openstack import resource
from openstack.telemetry import telemetry_service
from openstack.telemetry.alarm import alarm_service
class AlarmChange(resource.Resource):
@@ -19,7 +19,7 @@ class AlarmChange(resource.Resource):
id_attribute = 'event_id'
resource_key = 'alarm_change'
base_path = '/alarms/%(alarm_id)s/history'
service = telemetry_service.TelemetryService()
service = alarm_service.AlarmService()
# Supported Operations
allow_list = True
@@ -36,6 +36,7 @@ class AlarmChange(resource.Resource):
#: The project ID of the initiating identity
project_id = resource.prop('project_id')
#: The time/date of the alarm change.
#: *Type: ISO 8601 formatted string*
triggered_at = resource.prop('timestamp')
#: The type of change
type = resource.prop('type')

View File

@@ -11,8 +11,6 @@
# under the License.
from openstack import proxy
from openstack.telemetry.v2 import alarm as _alarm
from openstack.telemetry.v2 import alarm_change as _alarm_change
from openstack.telemetry.v2 import capability
from openstack.telemetry.v2 import meter as _meter
from openstack.telemetry.v2 import resource as _resource
@@ -23,112 +21,6 @@ from openstack.telemetry.v2 import statistics
class Proxy(proxy.BaseProxy):
""".. caution:: This API is a work in progress and is subject to change."""
def create_alarm(self, **attrs):
"""Create a new alarm from attributes
:param dict attrs: Keyword arguments which will be used to create
a :class:`~openstack.telemetry.v2.alarm.Alarm`,
comprised of the properties on the Alarm class.
:returns: The results of alarm creation
:rtype: :class:`~openstack.telemetry.v2.alarm.Alarm`
"""
return self._create(_alarm.Alarm, **attrs)
def delete_alarm(self, alarm, ignore_missing=True):
"""Delete an alarm
:param alarm: The value can be either the ID of an alarm or a
:class:`~openstack.telemetry.v2.alarm.Alarm` instance.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the alarm does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent alarm.
:returns: ``None``
"""
self._delete(_alarm.Alarm, alarm, ignore_missing=ignore_missing)
def find_alarm(self, name_or_id, ignore_missing=True):
"""Find a single alarm
:param name_or_id: The name or ID of a alarm.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the resource does not exist.
When set to ``True``, None will be returned when
attempting to find a nonexistent resource.
:returns: One :class:`~openstack.telemetry.v2.alarm.Alarm` or None
"""
return self._find(_alarm.Alarm, name_or_id,
ignore_missing=ignore_missing)
def get_alarm(self, alarm):
"""Get a single alarm
:param alarm: The value can be the ID of an alarm or a
:class:`~openstack.telemetry.v2.alarm.Alarm` instance.
:returns: One :class:`~openstack.telemetry.v2.alarm.Alarm`
:raises: :class:`~openstack.exceptions.ResourceNotFound`
when no resource can be found.
"""
return self._get(_alarm.Alarm, alarm)
def alarms(self, **query):
"""Return a generator of alarms
:param kwargs \*\*query: Optional query parameters to be sent to limit
the resources being returned.
:returns: A generator of alarm objects
:rtype: :class:`~openstack.telemetry.v2.alarm.Alarm`
"""
return self._list(_alarm.Alarm, paginated=False, **query)
def update_alarm(self, alarm, **attrs):
"""Update a alarm
:param alarm: Either the id of a alarm or a
:class:`~openstack.telemetry.v2.alarm.Alarm` instance.
:attrs kwargs: The attributes to update on the alarm represented
by ``value``.
:returns: The updated alarm
:rtype: :class:`~openstack.telemetry.v2.alarm.Alarm`
"""
return self._update(_alarm.Alarm, alarm, **attrs)
def find_alarm_change(self, name_or_id, ignore_missing=True):
"""Find a single alarm change
:param name_or_id: The name or ID of a alarm change.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the resource does not exist.
When set to ``True``, None will be returned when
attempting to find a nonexistent resource.
:returns: One :class:`~openstack.telemetry.v2.alarm_change.AlarmChange`
or None
"""
return self._find(_alarm_change.AlarmChange, name_or_id,
ignore_missing=ignore_missing)
def alarm_changes(self, alarm, **query):
"""Return a generator of alarm changes
:param alarm: Alarm resource or id for alarm.
:param kwargs \*\*query: Optional query parameters to be sent to limit
the resources being returned.
:returns: A generator of alarm change objects
:rtype: :class:`~openstack.telemetry.v2.alarm_change.AlarmChange`
"""
alarm_id = _alarm.Alarm.from_id(alarm).id
return self._list(_alarm_change.AlarmChange, paginated=False,
path_args={'alarm_id': alarm_id}, **query)
def find_capability(self, name_or_id, ignore_missing=True):
"""Find a single capability

View File

@@ -13,11 +13,13 @@
import unittest
import uuid
from openstack.telemetry.v2 import alarm
from openstack.telemetry.alarm.v2 import alarm
from openstack.tests.functional import base
@unittest.skip("bug/1524468")
@unittest.skipUnless(base.service_exists(service_type="alarming"),
"Alarming service does not exist")
@unittest.skipUnless(base.service_exists(service_type="metering"),
"Metering service does not exist")
class TestAlarm(base.BaseFunctionalTest):
@@ -29,7 +31,7 @@ class TestAlarm(base.BaseFunctionalTest):
def setUpClass(cls):
super(TestAlarm, cls).setUpClass()
meter = next(cls.conn.telemetry.meters())
sot = cls.conn.telemetry.create_alarm(
sot = cls.conn.alarm.create_alarm(
name=cls.NAME,
type='threshold',
threshold_rule={
@@ -43,14 +45,14 @@ class TestAlarm(base.BaseFunctionalTest):
@classmethod
def tearDownClass(cls):
sot = cls.conn.telemetry.delete_alarm(cls.ID, ignore_missing=False)
sot = cls.conn.alarm.delete_alarm(cls.ID, ignore_missing=False)
cls.assertIs(None, sot)
def test_get(self):
sot = self.conn.telemetry.get_alarm(self.ID)
sot = self.conn.alarm.get_alarm(self.ID)
self.assertEqual(self.NAME, sot.name)
self.assertEqual(self.ID, sot.id)
def test_list(self):
names = [o.name for o in self.conn.telemetry.alarms()]
names = [o.name for o in self.conn.alarm.alarms()]
self.assertIn(self.NAME, names)

View File

@@ -19,6 +19,8 @@ from openstack.tests.functional import base
@unittest.skip("bug/1524468")
@unittest.skipUnless(base.service_exists(service_type="metering"),
"Metering service does not exist")
@unittest.skipUnless(base.service_exists(service_type="alarming"),
"Alarming service does not exist")
class TestAlarmChange(base.BaseFunctionalTest):
NAME = uuid.uuid4().hex
@@ -28,7 +30,7 @@ class TestAlarmChange(base.BaseFunctionalTest):
def setUpClass(cls):
super(TestAlarmChange, cls).setUpClass()
meter = next(cls.conn.telemetry.meters())
alarm = cls.conn.telemetry.create_alarm(
alarm = cls.conn.alarm.create_alarm(
name=cls.NAME,
type='threshold',
threshold_rule={
@@ -40,9 +42,9 @@ class TestAlarmChange(base.BaseFunctionalTest):
@classmethod
def tearDownClass(cls):
cls.conn.telemetry.delete_alarm(cls.alarm, ignore_missing=False)
cls.conn.alarm.delete_alarm(cls.alarm, ignore_missing=False)
def test_list(self):
change = next(self.conn.telemetry.alarm_changes(self.alarm))
change = next(self.conn.alarm.alarm_changes(self.alarm))
self.assertEqual(self.alarm.id, change.alarm_id)
self.assertEqual('creation', change.type)

View File

@@ -0,0 +1,28 @@
# 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.
import testtools
from openstack.telemetry.alarm import alarm_service
class TestAlarmService(testtools.TestCase):
def test_service(self):
sot = alarm_service.AlarmService()
self.assertEqual('alarming', sot.service_type)
self.assertEqual('public', sot.interface)
self.assertIsNone(sot.region)
self.assertIsNone(sot.service_name)
self.assertEqual(1, len(sot.valid_versions))
self.assertEqual('v2', sot.valid_versions[0].module)
self.assertEqual('v2', sot.valid_versions[0].path)

View File

@@ -13,7 +13,7 @@
import mock
import testtools
from openstack.telemetry.v2 import alarm
from openstack.telemetry.alarm.v2 import alarm
IDENTIFIER = 'IDENTIFIER'
EXAMPLE = {
@@ -31,13 +31,15 @@ EXAMPLE = {
'state': 'insufficient data',
'state_timestamp': '2015-03-09T12:15:57.233772',
'timestamp': '2015-03-09T12:15:57.233772',
'threshold_rule': {'meter_name': 'a',
'evaluation_periods:': '1',
'period': '60',
'statistic': 'avg',
'threshold': '92.6',
'comparison_operator': 'gt',
'exclude_outliers': True, },
'threshold_rule': {
'meter_name': 'a',
'evaluation_periods:': '1',
'period': '60',
'statistic': 'avg',
'threshold': '92.6',
'comparison_operator': 'gt',
'exclude_outliers': True,
},
'time_constraints': [{'name': 'a', 'duration': 'b', 'start': 'c', }],
'type': '10',
'user_id': '11',
@@ -59,7 +61,7 @@ class TestAlarm(testtools.TestCase):
self.assertIsNone(sot.resource_key)
self.assertIsNone(sot.resources_key)
self.assertEqual('/alarms', sot.base_path)
self.assertEqual('metering', sot.service.service_type)
self.assertEqual('alarming', sot.service.service_type)
self.assertTrue(sot.allow_create)
self.assertTrue(sot.allow_retrieve)
self.assertTrue(sot.allow_update)

View File

@@ -13,7 +13,7 @@
import mock
import testtools
from openstack.telemetry.v2 import alarm_change
from openstack.telemetry.alarm.v2 import alarm_change
IDENTIFIER = 'IDENTIFIER'
EXAMPLE = {
@@ -35,7 +35,7 @@ class TestAlarmChange(testtools.TestCase):
self.assertEqual('alarm_change', sot.resource_key)
self.assertIsNone(sot.resources_key)
self.assertEqual('/alarms/%(alarm_id)s/history', sot.base_path)
self.assertEqual('metering', sot.service.service_type)
self.assertEqual('alarming', sot.service.service_type)
self.assertFalse(sot.allow_create)
self.assertFalse(sot.allow_retrieve)
self.assertFalse(sot.allow_update)

View File

@@ -0,0 +1,54 @@
# 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 openstack.telemetry.alarm.v2 import _proxy
from openstack.telemetry.alarm.v2 import alarm
from openstack.telemetry.alarm.v2 import alarm_change
from openstack.tests.unit import test_proxy_base
class TestAlarmProxy(test_proxy_base.TestProxyBase):
def setUp(self):
super(TestAlarmProxy, self).setUp()
self.proxy = _proxy.Proxy(self.session)
def test_alarm_change_find(self):
self.verify_find(self.proxy.find_alarm_change,
alarm_change.AlarmChange)
def test_alarm_changes(self):
larm = alarm.Alarm.existing(alarm_id='larm')
expected_kwargs = {'path_args': {'alarm_id': 'larm'}}
self.verify_list(self.proxy.alarm_changes, alarm_change.AlarmChange,
method_args=[larm], paginated=False,
expected_kwargs=expected_kwargs)
def test_alarm_create_attrs(self):
self.verify_create(self.proxy.create_alarm, alarm.Alarm)
def test_alarm_delete(self):
self.verify_delete(self.proxy.delete_alarm, alarm.Alarm, False)
def test_alarm_delete_ignore(self):
self.verify_delete(self.proxy.delete_alarm, alarm.Alarm, True)
def test_alarm_find(self):
self.verify_find(self.proxy.find_alarm, alarm.Alarm)
def test_alarm_get(self):
self.verify_get(self.proxy.get_alarm, alarm.Alarm)
def test_alarms(self):
self.verify_list(self.proxy.alarms, alarm.Alarm, paginated=False)
def test_alarm_update(self):
self.verify_update(self.proxy.update_alarm, alarm.Alarm)

View File

@@ -11,8 +11,6 @@
# under the License.
from openstack.telemetry.v2 import _proxy
from openstack.telemetry.v2 import alarm
from openstack.telemetry.v2 import alarm_change
from openstack.telemetry.v2 import capability
from openstack.telemetry.v2 import meter
from openstack.telemetry.v2 import resource
@@ -26,38 +24,6 @@ class TestTelemetryProxy(test_proxy_base.TestProxyBase):
super(TestTelemetryProxy, self).setUp()
self.proxy = _proxy.Proxy(self.session)
def test_alarm_change_find(self):
self.verify_find(self.proxy.find_alarm_change,
alarm_change.AlarmChange)
def test_alarm_changes(self):
larm = alarm.Alarm.existing(alarm_id='larm')
expected_kwargs = {'path_args': {'alarm_id': 'larm'}}
self.verify_list(self.proxy.alarm_changes, alarm_change.AlarmChange,
method_args=[larm], paginated=False,
expected_kwargs=expected_kwargs)
def test_alarm_create_attrs(self):
self.verify_create(self.proxy.create_alarm, alarm.Alarm)
def test_alarm_delete(self):
self.verify_delete(self.proxy.delete_alarm, alarm.Alarm, False)
def test_alarm_delete_ignore(self):
self.verify_delete(self.proxy.delete_alarm, alarm.Alarm, True)
def test_alarm_find(self):
self.verify_find(self.proxy.find_alarm, alarm.Alarm)
def test_alarm_get(self):
self.verify_get(self.proxy.get_alarm, alarm.Alarm)
def test_alarms(self):
self.verify_list(self.proxy.alarms, alarm.Alarm, paginated=False)
def test_alarm_update(self):
self.verify_update(self.proxy.update_alarm, alarm.Alarm)
def test_capability_find(self):
self.verify_find(self.proxy.find_capability, capability.Capability)

View File

@@ -111,6 +111,8 @@ class TestConnection(base.TestCase):
conn = connection.Connection(authenticator=auth, profile=prof)
self.assertEqual(auth, conn.authenticator)
self.assertEqual(prof, conn.profile)
self.assertEqual('openstack.telemetry.alarm.v2._proxy',
conn.alarm.__class__.__module__)
self.assertEqual('openstack.cluster.v1._proxy',
conn.cluster.__class__.__module__)
self.assertEqual('openstack.compute.v2._proxy',

View File

@@ -19,6 +19,7 @@ class TestProfile(base.TestCase):
def test_init(self):
prof = profile.Profile()
expected = [
'alarming',
'clustering',
'compute',
'database',
@@ -51,10 +52,12 @@ class TestProfile(base.TestCase):
def test_set(self):
prof = profile.Profile()
prof.set_version('compute', 'v2')
self.assertEqual('v2', prof.get_filter('compute').version)
prof.set_version('alarming', 'v2')
self.assertEqual('v2', prof.get_filter('alarming').version)
prof.set_version('clustering', 'v1')
self.assertEqual('v1', prof.get_filter('clustering').version)
prof.set_version('compute', 'v2')
self.assertEqual('v2', prof.get_filter('compute').version)
prof.set_version('database', 'v3')
self.assertEqual('v3', prof.get_filter('database').version)
prof.set_version('identity', 'v4')