Add an option to disable cloud watch lite

This also adds a deprecation warning.
This also changes the default to use Ceilometer.

Release message:
Anyone deploying Heat should not be using OS::Heat::CWLiteAlarm, but
OS::Ceilometer::Alarm.
CWLiteAlarm should be explictly disabled in /etc/heat/heat.conf by
setting "enable_cloud_watch_lite=false". This will stop Heat from
running a period task check for alarms.

DocImpact
Change-Id: I2a10c14772bdafc001e211d7e94502ac1f6b32b1
Closes-bug: #1322128
This commit is contained in:
Angus Salkeld 2014-09-25 08:26:36 +10:00
parent 7555fc9f04
commit 33eb87b3e2
9 changed files with 53 additions and 9 deletions

View File

@ -55,6 +55,7 @@ if __name__ == '__main__':
srv = engine.EngineService(cfg.CONF.host, rpc_api.ENGINE_TOPIC) srv = engine.EngineService(cfg.CONF.host, rpc_api.ENGINE_TOPIC)
launcher = service.launch(srv, workers=cfg.CONF.num_engine_workers) launcher = service.launch(srv, workers=cfg.CONF.num_engine_workers)
if cfg.CONF.enable_cloud_watch_lite:
# We create the periodic tasks here, which mean they are created # We create the periodic tasks here, which mean they are created
# only in the parent process when num_engine_workers>1 is specified # only in the parent process when num_engine_workers>1 is specified
srv.create_periodic_tasks() srv.create_periodic_tasks()

View File

@ -3,7 +3,7 @@ resource_registry:
# allow older templates with Quantum in them. # allow older templates with Quantum in them.
"OS::Quantum*": "OS::Neutron*" "OS::Quantum*": "OS::Neutron*"
# Choose your implementation of AWS::CloudWatch::Alarm # Choose your implementation of AWS::CloudWatch::Alarm
#"AWS::CloudWatch::Alarm": "file:///etc/heat/templates/AWS_CloudWatch_Alarm.yaml" "AWS::CloudWatch::Alarm": "file:///etc/heat/templates/AWS_CloudWatch_Alarm.yaml"
"AWS::CloudWatch::Alarm": "OS::Heat::CWLiteAlarm" #"AWS::CloudWatch::Alarm": "OS::Heat::CWLiteAlarm"
"OS::Metering::Alarm": "OS::Ceilometer::Alarm" "OS::Metering::Alarm": "OS::Ceilometer::Alarm"
"AWS::RDS::DBInstance": "file:///etc/heat/templates/AWS_RDS_DBInstance.yaml" "AWS::RDS::DBInstance": "file:///etc/heat/templates/AWS_RDS_DBInstance.yaml"

View File

@ -70,6 +70,10 @@
# stack locking. (integer value) # stack locking. (integer value)
#engine_life_check_timeout=2 #engine_life_check_timeout=2
# Enable the legacy OS::Heat::CWLiteAlarm resource. (boolean
# value)
#enable_cloud_watch_lite=true
# Deprecated. (string value) # Deprecated. (string value)
#onready=<None> #onready=<None>

View File

@ -137,6 +137,9 @@ engine_opts = [
default=2, default=2,
help=_('RPC timeout for the engine liveness check that is used' help=_('RPC timeout for the engine liveness check that is used'
' for stack locking.')), ' for stack locking.')),
cfg.BoolOpt('enable_cloud_watch_lite',
default=True,
help=_('Enable the legacy OS::Heat::CWLiteAlarm resource.')),
cfg.StrOpt('onready', cfg.StrOpt('onready',
help=_('Deprecated.'))] help=_('Deprecated.'))]

View File

@ -15,6 +15,7 @@ import copy
import glob import glob
import itertools import itertools
import os.path import os.path
import warnings
from oslo.config import cfg from oslo.config import cfg
import six import six
@ -22,6 +23,7 @@ import six
from heat.common import environment_format as env_fmt from heat.common import environment_format as env_fmt
from heat.common import exception from heat.common import exception
from heat.common.i18n import _ from heat.common.i18n import _
from heat.engine import support
from heat.openstack.common import log from heat.openstack.common import log
@ -215,6 +217,11 @@ class ResourceRegistry(object):
LOG.info(_('Registering %(path)s -> %(value)s') % { LOG.info(_('Registering %(path)s -> %(value)s') % {
'path': descriptive_path, 'path': descriptive_path,
'value': str(info.value)}) 'value': str(info.value)})
if isinstance(info, ClassResourceInfo):
if info.value.support_status.status != support.SUPPORTED:
warnings.warn(six.text_type(info.value.support_status.message))
info.user_resource = (self.global_registry is not None) info.user_resource = (self.global_registry is not None)
registry[name] = info registry[name] = info

View File

@ -11,10 +11,13 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo.config import cfg
from heat.common import exception from heat.common import exception
from heat.engine import constraints from heat.engine import constraints
from heat.engine import properties from heat.engine import properties
from heat.engine import resource from heat.engine import resource
from heat.engine import support
from heat.engine import watchrule from heat.engine import watchrule
@ -129,6 +132,11 @@ class CloudWatchAlarm(resource.Resource):
strict_dependency = False strict_dependency = False
support_status = support.SupportStatus(
status=support.DEPRECATED,
message=_('OS::Heat::CWLiteAlarm is deprecated, '
'use OS::Ceilometer::Alarm instead.'))
def handle_create(self): def handle_create(self):
wr = watchrule.WatchRule(context=self.context, wr = watchrule.WatchRule(context=self.context,
watch_name=self.physical_resource_name(), watch_name=self.physical_resource_name(),
@ -176,6 +184,10 @@ class CloudWatchAlarm(resource.Resource):
def resource_mapping(): def resource_mapping():
cfg.CONF.import_opt('enable_cloud_watch_lite', 'heat.common.config')
if cfg.CONF.enable_cloud_watch_lite:
return { return {
'OS::Heat::CWLiteAlarm': CloudWatchAlarm, 'OS::Heat::CWLiteAlarm': CloudWatchAlarm,
} }
else:
return {}

View File

@ -97,6 +97,11 @@ class HeatTestCase(testscenarios.WithScenarios,
if templ_path not in cur_path: if templ_path not in cur_path:
tri.template_name = cur_path.replace('/etc/heat/templates', tri.template_name = cur_path.replace('/etc/heat/templates',
templ_path) templ_path)
# use CWLiteAlarm for testing.
resources.global_env().registry.load(
{"AWS::CloudWatch::Alarm": "OS::Heat::CWLiteAlarm"})
utils.setup_dummy_db() utils.setup_dummy_db()
self.addCleanup(utils.reset_dummy_db) self.addCleanup(utils.reset_dummy_db)

View File

@ -2142,7 +2142,8 @@ class StackServiceTest(HeatTestCase):
def test_list_resource_types_deprecated(self): def test_list_resource_types_deprecated(self):
resources = self.eng.list_resource_types(self.ctx, "DEPRECATED") resources = self.eng.list_resource_types(self.ctx, "DEPRECATED")
self.assertEqual(['OS::Neutron::RouterGateway'], resources) self.assertEqual(['OS::Neutron::RouterGateway',
'OS::Heat::CWLiteAlarm'], resources)
def test_list_resource_types_supported(self): def test_list_resource_types_supported(self):
resources = self.eng.list_resource_types(self.ctx, "SUPPORTED") resources = self.eng.list_resource_types(self.ctx, "SUPPORTED")

View File

@ -30,6 +30,7 @@ from heat.engine import resource
from heat.engine import resources from heat.engine import resources
from heat.engine.resources import template_resource from heat.engine.resources import template_resource
from heat.engine import rsrc_defn from heat.engine import rsrc_defn
from heat.engine import support
from heat.tests.common import HeatTestCase from heat.tests.common import HeatTestCase
from heat.tests import generic_resource as generic_rsrc from heat.tests import generic_resource as generic_rsrc
from heat.tests import utils from heat.tests import utils
@ -108,6 +109,8 @@ class ProviderTemplateTest(HeatTestCase):
files = {'test_resource.template': json.dumps(provider)} files = {'test_resource.template': json.dumps(provider)}
class DummyResource(object): class DummyResource(object):
support_status = support.SupportStatus()
attributes_schema = {"Foo": attributes.Schema("A test attribute")} attributes_schema = {"Foo": attributes.Schema("A test attribute")}
properties_schema = { properties_schema = {
"Foo": {"Type": "String"}, "Foo": {"Type": "String"},
@ -186,6 +189,7 @@ class ProviderTemplateTest(HeatTestCase):
files = {'test_resource.template': json.dumps(provider)} files = {'test_resource.template': json.dumps(provider)}
class DummyResource(object): class DummyResource(object):
support_status = support.SupportStatus()
properties_schema = {} properties_schema = {}
attributes_schema = {"Foo": attributes.Schema("A test attribute")} attributes_schema = {"Foo": attributes.Schema("A test attribute")}
@ -214,6 +218,7 @@ class ProviderTemplateTest(HeatTestCase):
files = {'test_resource.template': json.dumps(provider)} files = {'test_resource.template': json.dumps(provider)}
class DummyResource(object): class DummyResource(object):
support_status = support.SupportStatus()
properties_schema = {} properties_schema = {}
attributes_schema = {"Foo": attributes.Schema("A test attribute")} attributes_schema = {"Foo": attributes.Schema("A test attribute")}
@ -244,6 +249,7 @@ class ProviderTemplateTest(HeatTestCase):
files = {'test_resource.template': json.dumps(provider)} files = {'test_resource.template': json.dumps(provider)}
class DummyResource(object): class DummyResource(object):
support_status = support.SupportStatus()
properties_schema = {"Foo": properties_schema = {"Foo":
properties.Schema(properties.Schema.STRING, properties.Schema(properties.Schema.STRING,
required=True)} required=True)}
@ -275,6 +281,7 @@ class ProviderTemplateTest(HeatTestCase):
files = {'test_resource.template': json.dumps(provider)} files = {'test_resource.template': json.dumps(provider)}
class DummyResource(object): class DummyResource(object):
support_status = support.SupportStatus()
properties_schema = {"Foo": properties_schema = {"Foo":
properties.Schema(properties.Schema.STRING, properties.Schema(properties.Schema.STRING,
required=True)} required=True)}
@ -306,6 +313,7 @@ class ProviderTemplateTest(HeatTestCase):
files = {'test_resource.template': json.dumps(provider)} files = {'test_resource.template': json.dumps(provider)}
class DummyResource(object): class DummyResource(object):
support_status = support.SupportStatus()
properties_schema = {} properties_schema = {}
attributes_schema = {} attributes_schema = {}
@ -336,6 +344,7 @@ class ProviderTemplateTest(HeatTestCase):
files = {'test_resource.template': json.dumps(provider)} files = {'test_resource.template': json.dumps(provider)}
class DummyResource(object): class DummyResource(object):
support_status = support.SupportStatus()
properties_schema = {"Foo": properties_schema = {"Foo":
properties.Schema(properties.Schema.MAP)} properties.Schema(properties.Schema.MAP)}
attributes_schema = {} attributes_schema = {}
@ -371,6 +380,7 @@ class ProviderTemplateTest(HeatTestCase):
files = {'test_resource.template': json.dumps(provider)} files = {'test_resource.template': json.dumps(provider)}
class DummyResource(object): class DummyResource(object):
support_status = support.SupportStatus()
properties_schema = {"Length": properties_schema = {"Length":
properties.Schema(properties.Schema.INTEGER)} properties.Schema(properties.Schema.INTEGER)}
attributes_schema = {} attributes_schema = {}
@ -402,6 +412,7 @@ class ProviderTemplateTest(HeatTestCase):
files = {'test_resource.template': json.dumps(provider)} files = {'test_resource.template': json.dumps(provider)}
class DummyResource(object): class DummyResource(object):
support_status = support.SupportStatus()
properties_schema = {"Foo": properties_schema = {"Foo":
properties.Schema(properties.Schema.BOOLEAN)} properties.Schema(properties.Schema.BOOLEAN)}
attributes_schema = {} attributes_schema = {}