Example #1
0
    def _start_watch_task(self, stack_id, cnxt):
        wrs = db_api.watch_rule_get_all_by_stack(cnxt, stack_id)

        # reset the last_evaluated so we don't fire off alarms when
        # the engine has not been running.
        now = timeutils.utcnow()
        for wr in wrs:
            db_api.watch_rule_update(cnxt, wr.id, {'last_evaluated': now})

        if len(wrs) > 0:
            self._timer_in_thread(
                stack_id, self._periodic_watcher_task, sid=stack_id)
Example #2
0
    def _start_watch_task(self, stack_id, cnxt):
        wrs = db_api.watch_rule_get_all_by_stack(cnxt, stack_id)

        now = timeutils.utcnow()
        start_watch_thread = False
        for wr in wrs:
            # reset the last_evaluated so we don't fire off alarms when
            # the engine has not been running.
            db_api.watch_rule_update(cnxt, wr.id, {"last_evaluated": now})

            if wr.state != rpc_api.WATCH_STATE_CEILOMETER_CONTROLLED:
                start_watch_thread = True

        if start_watch_thread:
            self._timer_in_thread(stack_id, self._periodic_watcher_task, sid=stack_id)
Example #3
0
    def _start_watch_task(self, stack_id, cnxt):
        wrs = db_api.watch_rule_get_all_by_stack(cnxt, stack_id)

        now = timeutils.utcnow()
        start_watch_thread = False
        for wr in wrs:
            # reset the last_evaluated so we don't fire off alarms when
            # the engine has not been running.
            db_api.watch_rule_update(cnxt, wr.id, {'last_evaluated': now})

            if wr.state != rpc_api.WATCH_STATE_CEILOMETER_CONTROLLED:
                start_watch_thread = True

        if start_watch_thread:
            self._timer_in_thread(stack_id,
                                  self._periodic_watcher_task,
                                  sid=stack_id)
Example #4
0
    def store(self):
        '''
        Store the watchrule in the database and return its ID
        If self.id is set, we update the existing rule
        '''

        wr_values = {
            'name': self.name,
            'rule': self.rule,
            'state': self.state,
            'stack_id': self.stack_id
        }

        if not self.id:
            wr = db_api.watch_rule_create(self.context, wr_values)
            self.id = wr.id
        else:
            db_api.watch_rule_update(self.context, self.id, wr_values)
Example #5
0
    def store(self):
        '''
        Store the watchrule in the database and return its ID
        If self.id is set, we update the existing rule
        '''

        wr_values = {
            'name': self.name,
            'rule': self.rule,
            'state': self.state,
            'stack_id': self.stack_id
        }

        if not self.id:
            wr = db_api.watch_rule_create(self.context, wr_values)
            self.id = wr.id
        else:
            db_api.watch_rule_update(self.context, self.id, wr_values)
Example #6
0
        def stack_has_a_watchrule(sid):
            wrs = db_api.watch_rule_get_all_by_stack(cnxt, sid)

            now = timeutils.utcnow()
            start_watch_thread = False
            for wr in wrs:
                # reset the last_evaluated so we don't fire off alarms when
                # the engine has not been running.
                db_api.watch_rule_update(cnxt, wr.id, {'last_evaluated': now})

                if wr.state != rpc_api.WATCH_STATE_CEILOMETER_CONTROLLED:
                    start_watch_thread = True

            children = db_api.stack_get_all_by_owner_id(cnxt, sid)
            for child in children:
                if stack_has_a_watchrule(child.id):
                    start_watch_thread = True

            return start_watch_thread
Example #7
0
        def stack_has_a_watchrule(sid):
            wrs = db_api.watch_rule_get_all_by_stack(cnxt, sid)

            now = timeutils.utcnow()
            start_watch_thread = False
            for wr in wrs:
                # reset the last_evaluated so we don't fire off alarms when
                # the engine has not been running.
                db_api.watch_rule_update(cnxt, wr.id, {'last_evaluated': now})

                if wr.state != rpc_api.WATCH_STATE_CEILOMETER_CONTROLLED:
                    start_watch_thread = True

            children = db_api.stack_get_all_by_owner_id(cnxt, sid)
            for child in children:
                if stack_has_a_watchrule(child.id):
                    start_watch_thread = True

            return start_watch_thread
Example #8
0
 def update_by_id(cls, context, watch_id, values):
     db_api.watch_rule_update(context, watch_id, values)
Example #9
0
 def update_by_id(cls, context, watch_id, values):
     db_api.watch_rule_update(context, watch_id, values)