16
16
from heat.common import exception
17
17
from heat.engine import watchrule
18
18
from heat.engine import resource
19
from heat.db import api as db_api
19
from heat.engine.properties import Properties
21
21
from heat.openstack.common import log as logging
73
73
'Count/Second', None]}}
75
75
strict_dependency = False
76
update_allowed_keys = ('Properties',)
77
# allow the properties that affect the watch calculation.
78
# note: when using in-instance monitoring you can only change the
79
# metric name if you re-configure the instance too.
80
update_allowed_properties = ('ComparisonOperator', 'AlarmDescription',
81
'EvaluationPeriods', 'Period', 'Statistic',
82
'AlarmActions', 'OKActions', 'Units'
83
'InsufficientDataActions', 'Threshold')
77
85
def handle_create(self):
78
86
wr = watchrule.WatchRule(context=self.context,
81
89
stack_id=self.stack.id)
84
def handle_update(self, json_snippet):
85
return self.UPDATE_REPLACE
92
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
93
# If Properties has changed, update self.properties, so we
94
# get the new values during any subsequent adjustment
96
self.properties = Properties(self.properties_schema,
97
json_snippet.get('Properties', {}),
98
self.stack.resolve_runtime_data,
100
loader = watchrule.WatchRule.load
101
wr = loader(self.context,
102
watch_name=self.physical_resource_name())
104
wr.rule = self.parsed_template('Properties')
87
107
def handle_delete(self):
89
db_api.watch_rule_delete(self.context,
90
self.physical_resource_name())
109
wr = watchrule.WatchRule.load(
110
self.context, watch_name=self.physical_resource_name())
91
112
except exception.NotFound:
115
def handle_suspend(self):
116
wr = watchrule.WatchRule.load(self.context,
117
watch_name=self.physical_resource_name())
118
wr.state_set(wr.SUSPENDED)
120
def handle_resume(self):
121
wr = watchrule.WatchRule.load(self.context,
122
watch_name=self.physical_resource_name())
123
# Just set to NODATA, which will be re-evaluated next periodic task
124
wr.state_set(wr.NODATA)
94
126
def FnGetRefId(self):
95
127
return unicode(self.physical_resource_name())
129
def physical_resource_name(self):
130
return '%s-%s' % (self.stack.name, self.name)
98
133
def resource_mapping():