コード例 #1
0
 def get_all_by_owner_id(cls, context, owner_id):
     db_stacks = db_api.stack_get_all_by_owner_id(context, owner_id)
     for db_stack in db_stacks:
         try:
             yield cls._from_db_object(context, cls(context), db_stack)
         except exception.NotFound:
             pass
コード例 #2
0
ファイル: stack.py プロジェクト: MarcDufresne/heat
 def get_all_by_owner_id(cls, context, owner_id):
     db_stacks = db_api.stack_get_all_by_owner_id(context, owner_id)
     for db_stack in db_stacks:
         try:
             yield cls._from_db_object(context, cls(context), db_stack)
         except exception.NotFound:
             pass
コード例 #3
0
ファイル: stack.py プロジェクト: Cindia-blue/heat
 def get_all_by_owner_id(cls, context, owner_id):
     db_stacks = db_api.stack_get_all_by_owner_id(context, owner_id)
     stacks = map(
         lambda db_stack: cls._from_db_object(
             context,
             cls(context),
             db_stack),
         db_stacks)
     return stacks
コード例 #4
0
ファイル: stack.py プロジェクト: rdo-management/heat
 def get_all_by_owner_id(cls, context, owner_id):
     db_stacks = db_api.stack_get_all_by_owner_id(context, owner_id)
     stacks = map(
         lambda db_stack: cls._from_db_object(
             context,
             cls(context),
             db_stack),
         db_stacks)
     return stacks
コード例 #5
0
ファイル: service.py プロジェクト: B-Rich/heat
        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
コード例 #6
0
ファイル: service.py プロジェクト: HuaiJiang/heat
        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
コード例 #7
0
    def check_stack_watches(self, sid):
        # Retrieve the stored credentials & create context
        # Require tenant_safe=False to the stack_get to defeat tenant
        # scoping otherwise we fail to retrieve the stack
        logger.debug(_("Periodic watcher task for stack %s") % sid)
        admin_context = context.get_admin_context()
        stack = db_api.stack_get(admin_context, sid, tenant_safe=False)
        if not stack:
            logger.error(
                _("Unable to retrieve stack %s for periodic task") % sid)
            return
        stack_context = EngineService.load_user_creds(stack.user_creds_id)

        # recurse into any nested stacks.
        children = db_api.stack_get_all_by_owner_id(admin_context, sid)
        for child in children:
            self.check_stack_watches(child.id)

        # Get all watchrules for this stack and evaluate them
        try:
            wrs = db_api.watch_rule_get_all_by_stack(stack_context, sid)
        except Exception as ex:
            logger.warn(
                _('periodic_task db error (%(msg)s) %(ex)s') % {
                    'msg': 'watch rule removed?',
                    'ex': str(ex)
                })
            return

        def run_alarm_action(actions, details):
            for action in actions:
                action(details=details)

            stk = parser.Stack.load(stack_context, stack=stack)
            for res in stk.itervalues():
                res.metadata_update()

        for wr in wrs:
            rule = watchrule.WatchRule.load(stack_context, watch=wr)
            actions = rule.evaluate()
            if actions:
                self.thread_group_mgr.start(sid, run_alarm_action, actions,
                                            rule.get_details())
コード例 #8
0
    def check_stack_watches(self, sid):
        # Retrieve the stored credentials & create context
        # Require tenant_safe=False to the stack_get to defeat tenant
        # scoping otherwise we fail to retrieve the stack
        LOG.debug("Periodic watcher task for stack %s" % sid)
        admin_context = context.get_admin_context()
        db_stack = db_api.stack_get(admin_context,
                                    sid,
                                    tenant_safe=False,
                                    eager_load=True)
        if not db_stack:
            LOG.error(_LE("Unable to retrieve stack %s for periodic task"),
                      sid)
            return
        stk = stack.Stack.load(admin_context,
                               stack=db_stack,
                               use_stored_context=True)

        # recurse into any nested stacks.
        children = db_api.stack_get_all_by_owner_id(admin_context, sid)
        for child in children:
            self.check_stack_watches(child.id)

        # Get all watchrules for this stack and evaluate them
        try:
            wrs = db_api.watch_rule_get_all_by_stack(admin_context, sid)
        except Exception as ex:
            LOG.warn(_LW('periodic_task db error watch rule removed? %(ex)s'),
                     ex)
            return

        def run_alarm_action(stk, actions, details):
            for action in actions:
                action(details=details)
            for res in stk.itervalues():
                res.metadata_update()

        for wr in wrs:
            rule = watchrule.WatchRule.load(stk.context, watch=wr)
            actions = rule.evaluate()
            if actions:
                self.thread_group_mgr.start(sid, run_alarm_action, stk,
                                            actions, rule.get_details())
コード例 #9
0
ファイル: service.py プロジェクト: arimus/heat
    def check_stack_watches(self, sid):
        # Retrieve the stored credentials & create context
        # Require tenant_safe=False to the stack_get to defeat tenant
        # scoping otherwise we fail to retrieve the stack
        logger.debug(_("Periodic watcher task for stack %s") % sid)
        admin_context = context.get_admin_context()
        stack = db_api.stack_get(admin_context, sid, tenant_safe=False,
                                 eager_load=True)
        if not stack:
            logger.error(_("Unable to retrieve stack %s for periodic task") %
                         sid)
            return
        stack_context = EngineService.load_user_creds(stack.user_creds_id)

        # recurse into any nested stacks.
        children = db_api.stack_get_all_by_owner_id(admin_context, sid)
        for child in children:
            self.check_stack_watches(child.id)

        # Get all watchrules for this stack and evaluate them
        try:
            wrs = db_api.watch_rule_get_all_by_stack(stack_context, sid)
        except Exception as ex:
            logger.warn(_('periodic_task db error watch rule removed? %(ex)s')
                        % ex)
            return

        def run_alarm_action(actions, details):
            for action in actions:
                action(details=details)

            stk = parser.Stack.load(stack_context, stack=stack)
            for res in stk.itervalues():
                res.metadata_update()

        for wr in wrs:
            rule = watchrule.WatchRule.load(stack_context, watch=wr)
            actions = rule.evaluate()
            if actions:
                self.thread_group_mgr.start(sid, run_alarm_action, actions,
                                            rule.get_details())
コード例 #10
0
ファイル: service.py プロジェクト: varunarya10/heat
    def _check_stack_watches(self, sid):
        # Retrieve the stored credentials & create context
        # Require admin=True to the stack_get to defeat tenant
        # scoping otherwise we fail to retrieve the stack
        logger.debug("Periodic watcher task for stack %s" % sid)
        admin_context = context.get_admin_context()
        stack = db_api.stack_get(admin_context, sid, admin=True)
        if not stack:
            logger.error("Unable to retrieve stack %s for periodic task" % sid)
            return
        stack_context = self._load_user_creds(stack.user_creds_id)

        # recurse into any nested stacks.
        children = db_api.stack_get_all_by_owner_id(admin_context, sid)
        for child in children:
            self._check_stack_watches(child.id)

        # Get all watchrules for this stack and evaluate them
        try:
            wrs = db_api.watch_rule_get_all_by_stack(stack_context, sid)
        except Exception as ex:
            logger.warn('periodic_task db error (%s) %s' %
                        ('watch rule removed?', str(ex)))
            return

        def run_alarm_action(actions, details):
            for action in actions:
                action(details=details)

            stk = parser.Stack.load(stack_context, stack=stack)
            for res in stk:
                res.metadata_update()

        for wr in wrs:
            rule = watchrule.WatchRule.load(stack_context, watch=wr)
            actions = rule.evaluate()
            if actions:
                self._start_in_thread(sid, run_alarm_action, actions,
                                      rule.get_details())
コード例 #11
0
ファイル: stack.py プロジェクト: noako/heat
 def get_all_by_owner_id(cls, context, owner_id):
     db_stacks = db_api.stack_get_all_by_owner_id(context, owner_id)
     stacks = [cls._from_db_object(context, cls(context), db_stack)
               for db_stack in db_stacks]
     return stacks
コード例 #12
0
 def get_all_by_owner_id(cls, context, owner_id):
     db_stacks = db_api.stack_get_all_by_owner_id(context, owner_id)
     stacks = [cls._from_db_object(context, cls(context), db_stack)
               for db_stack in db_stacks]
     return stacks