Makes monasca plugin as supported

Adds python-monascaclient into requirments.txt
and makes the monasca plugin as supported.

Closes-bug: #1581379
Change-Id: I3793b06cab25d7a108bb140791f3f672fd9154a1
This commit is contained in:
Kanagaraj Manickam 2015-12-03 15:40:49 +05:30 committed by Kanagaraj Manickam
parent 0105e8f153
commit a9b5cc401b
7 changed files with 22 additions and 91 deletions

View File

@ -11,28 +11,23 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_utils import importutils
from monascaclient import client
from monascaclient import exc as monasca_exc
from heat.common import exception as heat_exc
from heat.engine.clients import client_plugin
from heat.engine import constraints
client = importutils.try_import('monascaclient.client')
monasca_exc = importutils.try_import('monascaclient.exc')
CLIENT_NAME = 'monasca'
class MonascaClientPlugin(client_plugin.ClientPlugin):
exceptions_module = [monasca_exc]
service_types = [MONITORING] = ['monitoring']
VERSION = '2_0'
@staticmethod
def is_available():
return client is not None
def _create(self):
args = self._get_client_args(service_name=CLIENT_NAME,
service_type=self.MONITORING)

View File

@ -12,7 +12,6 @@
# under the License.
from heat.common.i18n import _
from heat.engine import clients
from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource
@ -22,8 +21,9 @@ from heat.engine import support
class MonascaAlarmDefinition(resource.Resource):
"""Heat Template Resource for Monasca Alarm definition.
This plug-in requires python-monascaclient>=1.0.22. So to enable this
plug-in, install this client library and restart the heat-engine.
Monasca Alarm definition helps to define the required expression for
a given alarm situation. This plugin helps to create, update and
delete the alarm definition.
Alarm definitions is necessary to describe and manage alarms in a
one-to-many relationship in order to avoid having to manually declare each
@ -32,8 +32,11 @@ class MonascaAlarmDefinition(resource.Resource):
"""
support_status = support.SupportStatus(
version='5.0.0',
status=support.UNSUPPORTED)
version='7.0.0',
previous_status=support.SupportStatus(
version='5.0.0',
status=support.UNSUPPORTED
))
default_client_name = 'monasca'
@ -201,10 +204,3 @@ def resource_mapping():
return {
'OS::Monasca::AlarmDefinition': MonascaAlarmDefinition
}
def available_resource_mapping():
if not clients.has_client(MonascaAlarmDefinition.default_client_name):
return {}
return resource_mapping()

View File

@ -12,7 +12,6 @@
# under the License.
from heat.common.i18n import _
from heat.engine import clients
from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource
@ -22,15 +21,18 @@ from heat.engine import support
class MonascaNotification(resource.Resource):
"""Heat Template Resource for Monasca Notification.
This plug-in requires python-monascaclient>=1.0.22. So to enable this
plug-in, install this client library and restart the heat-engine.
A resource which is used to notificate if there is some alarm.
Monasca Notification helps to declare the hook points, which will be
invoked once alarm is generated. This plugin helps to create, update and
delete the notification.
"""
support_status = support.SupportStatus(
version='5.0.0',
status=support.UNSUPPORTED)
version='7.0.0',
previous_status=support.SupportStatus(
version='5.0.0',
status=support.UNSUPPORTED
))
default_client_name = 'monasca'
@ -114,10 +116,3 @@ def resource_mapping():
return {
'OS::Monasca::Notification': MonascaNotification
}
def available_resource_mapping():
if not clients.has_client(MonascaNotification.default_client_name):
return {}
return resource_mapping()

View File

@ -90,12 +90,6 @@ class MonascaClientPluginTest(common.HeatTestCase):
)
# TODO(skraynev): remove it when monasca client will be
# merged in global requirements
class NotFound(Exception):
pass
class MonascaClientPluginNotificationTest(common.HeatTestCase):
sample_uuid = '477e8273-60a7-4c41-b683-fdb0bc7cd152'
@ -110,10 +104,6 @@ class MonascaClientPluginNotificationTest(common.HeatTestCase):
def setUp(self):
super(MonascaClientPluginNotificationTest, self).setUp()
self._client = mock.MagicMock()
client_plugin.monasca_exc = mock.Mock()
# TODO(skraynev): remove it when monasca client will be
# merged in global requirements
client_plugin.monasca_exc.NotFound = NotFound
self.client_plugin = client_plugin.MonascaClientPlugin(
context=mock.MagicMock()
)

View File

@ -14,7 +14,6 @@
import mock
from heat.engine.clients.os import monasca as client_plugin
from heat.engine import resource
from heat.engine.resources.openstack.monasca import alarm_definition
from heat.engine import stack
from heat.engine import template
@ -45,27 +44,13 @@ sample_template = {
RESOURCE_TYPE = 'OS::Monasca::AlarmDefinition'
class MonascaAlarmDefinition(alarm_definition.MonascaAlarmDefinition):
"""This class overrides the is_service_available to return True.
Monasca service is not available by default. So, this class overrides
the is_service_available to return True.
"""
@classmethod
def is_service_available(cls, context):
return True
class MonascaAlarmDefinitionTest(common.HeatTestCase):
def setUp(self):
super(MonascaAlarmDefinitionTest, self).setUp()
self.ctx = utils.dummy_context()
# As monascaclient is not part of requirements.txt, RESOURCE_TYPE is
# not registered by default. For testing, its registered here
resource._register_class(RESOURCE_TYPE,
MonascaAlarmDefinition)
self.stack = stack.Stack(
self.ctx, 'test_stack',
template.Template(sample_template)
@ -209,14 +194,6 @@ class MonascaAlarmDefinitionTest(common.HeatTestCase):
self.assertIsNone(self.test_resource.handle_delete())
def test_resource_handle_delete_not_found(self):
# TODO(skraynev): remove it when monasca client will be
# merged in global requirements
class NotFound(Exception):
pass
client_plugin.monasca_exc = mock.Mock()
client_plugin.monasca_exc.NotFound = NotFound
self.test_resource.resource_id = '477e8273-60a7-4c41-b683-fdb0bc7cd151'
mock_alarm_delete = self.test_client.alarm_definitions.delete
mock_alarm_delete.side_effect = client_plugin.monasca_exc.NotFound

View File

@ -14,7 +14,6 @@
import mock
from heat.engine.clients.os import monasca as client_plugin
from heat.engine import resource
from heat.engine.resources.openstack.monasca import notification
from heat.engine import stack
from heat.engine import template
@ -39,27 +38,13 @@ sample_template = {
RESOURCE_TYPE = 'OS::Monasca::Notification'
class MonascaNotification(notification.MonascaNotification):
"""This class overrides the is_service_available to return True.
Monasca service is not available by default. So, this class overrides
the is_service_available to return True.
"""
@classmethod
def is_service_available(cls, context):
return True
class MonascaNotificationTest(common.HeatTestCase):
def setUp(self):
super(MonascaNotificationTest, self).setUp()
self.ctx = utils.dummy_context()
# As monascaclient is not part of requirements.txt, RESOURCE_TYPE is
# not registered by default. For testing, its registered here
resource._register_class(RESOURCE_TYPE,
MonascaNotification)
self.stack = stack.Stack(
self.ctx, 'test_stack',
template.Template(sample_template)
@ -153,14 +138,6 @@ class MonascaNotificationTest(common.HeatTestCase):
self.assertIsNone(self.test_resource.handle_delete())
def test_resource_handle_delete_not_found(self):
# TODO(skraynev): remove it when monasca client will be
# merged in global requirements
class NotFound(Exception):
pass
client_plugin.monasca_exc = mock.Mock()
client_plugin.monasca_exc.NotFound = NotFound
self.test_resource.resource_id = '477e8273-60a7-4c41-b683-fdb0bc7cd151'
mock_notification_delete = self.test_client.notifications.delete
mock_notification_delete.side_effect = (

View File

@ -40,6 +40,7 @@ python-keystoneclient!=1.8.0,!=2.1.0,>=1.6.0 # Apache-2.0
python-magnumclient>=2.0.0 # Apache-2.0
python-manilaclient>=1.3.0 # Apache-2.0
python-mistralclient>=1.0.0 # Apache-2.0
python-monascaclient>=1.0.30 # Apache-2.0
python-neutronclient>=4.2.0 # Apache-2.0
python-novaclient!=2.33.0,>=2.29.0 # Apache-2.0
python-openstackclient>=2.1.0 # Apache-2.0