~ubuntu-branches/ubuntu/trusty/heat/trusty-security

« back to all changes in this revision

Viewing changes to heat/engine/resources/cloud_watch.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Yolanda Robla, Chuck Short
  • Date: 2013-07-22 16:22:29 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130722162229-zzvfu40id94ii0hc
Tags: 2013.2~b2-0ubuntu1
[ Yolanda Robla ]
* debian/tests: added autopkg tests

[ Chuck Short ]
* New upstream release
* debian/control:
  - Add python-pbr to build-depends.
  - Add python-d2to to build-depends.
  - Dropped python-argparse.
  - Add python-six to build-depends.
  - Dropped python-sendfile.
  - Dropped python-nose.
  - Added testrepository.
  - Added python-testtools.
* debian/rules: Run testrepository instead of nosetets.
* debian/patches/removes-lxml-version-limitation-from-pip-requires.patch: Dropped
  no longer needed.
* debian/patches/fix-package-version-detection-when-building-doc.patch: Dropped
  no longer needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
20
20
 
21
21
from heat.openstack.common import log as logging
22
22
 
73
73
                                                     'Count/Second', None]}}
74
74
 
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')
76
84
 
77
85
    def handle_create(self):
78
86
        wr = watchrule.WatchRule(context=self.context,
81
89
                                 stack_id=self.stack.id)
82
90
        wr.store()
83
91
 
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
 
95
        if prop_diff:
 
96
            self.properties = Properties(self.properties_schema,
 
97
                                         json_snippet.get('Properties', {}),
 
98
                                         self.stack.resolve_runtime_data,
 
99
                                         self.name)
 
100
            loader = watchrule.WatchRule.load
 
101
            wr = loader(self.context,
 
102
                        watch_name=self.physical_resource_name())
 
103
 
 
104
            wr.rule = self.parsed_template('Properties')
 
105
            wr.store()
86
106
 
87
107
    def handle_delete(self):
88
108
        try:
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())
 
111
            wr.destroy()
91
112
        except exception.NotFound:
92
113
            pass
93
114
 
 
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)
 
119
 
 
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)
 
125
 
94
126
    def FnGetRefId(self):
95
127
        return unicode(self.physical_resource_name())
96
128
 
 
129
    def physical_resource_name(self):
 
130
        return '%s-%s' % (self.stack.name, self.name)
 
131
 
97
132
 
98
133
def resource_mapping():
99
134
    return {