Ejemplo n.º 1
0
 def get_all(cls, context, *args, **kwargs):
     db_stacks = db_api.stack_get_all(context, *args, **kwargs)
     for db_stack in db_stacks:
         try:
             yield cls._from_db_object(context, cls(context), db_stack)
         except exception.NotFound:
             pass
Ejemplo n.º 2
0
    def list_stacks(self, cnxt, limit=None, marker=None, sort_keys=None,
                    sort_dir=None, filters=None, tenant_safe=True,
                    show_deleted=False):
        """
        The list_stacks method returns attributes of all stacks.  It supports
        pagination (``limit`` and ``marker``), sorting (``sort_keys`` and
        ``sort_dir``) and filtering (``filters``) of the results.

        :param cnxt: RPC context
        :param limit: the number of stacks to list (integer or string)
        :param marker: the ID of the last item in the previous page
        :param sort_keys: an array of fields used to sort the list
        :param sort_dir: the direction of the sort ('asc' or 'desc')
        :param filters: a dict with attribute:value to filter the list
        :param tenant_safe: if true, scope the request by the current tenant
        :param show_deleted: if true, show soft-deleted stacks
        :returns: a list of formatted stacks
        """
        def format_stack_details(stacks):
            for s in stacks:
                try:
                    stack = parser.Stack.load(cnxt, stack=s,
                                              resolve_data=False)
                except exception.NotFound:
                    # The stack may have been deleted between listing
                    # and formatting
                    pass
                else:
                    yield api.format_stack(stack)

        stacks = db_api.stack_get_all(cnxt, limit, sort_keys, marker,
                                      sort_dir, filters, tenant_safe,
                                      show_deleted) or []
        return list(format_stack_details(stacks))
Ejemplo n.º 3
0
 def get_all(cls, context, *args, **kwargs):
     db_stacks = db_api.stack_get_all(context, *args, **kwargs)
     for db_stack in db_stacks:
         try:
             yield cls._from_db_object(context, cls(context), db_stack)
         except exception.NotFound:
             pass
Ejemplo n.º 4
0
 def get_all(cls,
             context,
             limit=None,
             sort_keys=None,
             marker=None,
             sort_dir=None,
             filters=None,
             show_deleted=False,
             show_nested=False,
             show_hidden=False,
             tags=None,
             tags_any=None,
             not_tags=None,
             not_tags_any=None):
     db_stacks = db_api.stack_get_all(context,
                                      limit=limit,
                                      sort_keys=sort_keys,
                                      marker=marker,
                                      sort_dir=sort_dir,
                                      filters=filters,
                                      show_deleted=show_deleted,
                                      show_nested=show_nested,
                                      show_hidden=show_hidden,
                                      tags=tags,
                                      tags_any=tags_any,
                                      not_tags=not_tags,
                                      not_tags_any=not_tags_any)
     for db_stack in db_stacks:
         try:
             yield cls._from_db_object(context, cls(context), db_stack)
         except exception.NotFound:
             pass
Ejemplo n.º 5
0
    def list_stacks(self, cnxt, limit=None, marker=None, sort_keys=None,
                    sort_dir=None, filters=None, tenant_safe=True):
        """
        The list_stacks method returns attributes of all stacks.  It supports
        pagination (``limit`` and ``marker``), sorting (``sort_keys`` and
        ``sort_dir``) and filtering (``filters``) of the results.

        :param cnxt: RPC context
        :param limit: the number of stacks to list (integer or string)
        :param marker: the ID of the last item in the previous page
        :param sort_keys: an array of fields used to sort the list
        :param sort_dir: the direction of the sort ('asc' or 'desc')
        :param filters: a dict with attribute:value to filter the list
        :param tenant_safe: if true, scope the request by the current tenant
        :returns: a list of formatted stacks
        """

        def format_stack_details(stacks):
            for s in stacks:
                try:
                    stack = parser.Stack.load(cnxt, stack=s,
                                              resolve_data=False)
                except exception.NotFound:
                    # The stack may have been deleted between listing
                    # and formatting
                    pass
                else:
                    yield api.format_stack(stack)

        stacks = db_api.stack_get_all(cnxt, limit, sort_keys, marker,
                                      sort_dir, filters, tenant_safe) or []
        return list(format_stack_details(stacks))
Ejemplo n.º 6
0
    def start(self):
        super(EngineService, self).start()

        # Create a periodic_watcher_task per-stack
        admin_context = context.get_admin_context()
        stacks = db_api.stack_get_all(admin_context, tenant_safe=False)
        for s in stacks:
            self.stack_watch.start_watch_task(s.id, admin_context)
Ejemplo n.º 7
0
    def start(self):
        super(EngineService, self).start()

        # Create a periodic_watcher_task per-stack
        admin_context = context.get_admin_context()
        stacks = db_api.stack_get_all(admin_context, tenant_safe=False)
        for s in stacks:
            self.stack_watch.start_watch_task(s.id, admin_context)
Ejemplo n.º 8
0
 def load_all(cls, context, limit=None, marker=None, sort_keys=None,
              sort_dir=None, filters=None, tenant_safe=True,
              show_deleted=False, resolve_data=True):
     stacks = db_api.stack_get_all(context, limit, sort_keys, marker,
                                   sort_dir, filters, tenant_safe,
                                   show_deleted) or []
     for stack in stacks:
         yield cls._from_db(context, stack, resolve_data=resolve_data)
Ejemplo n.º 9
0
 def load_all(cls, context, limit=None, marker=None, sort_keys=None,
              sort_dir=None, filters=None, tenant_safe=True,
              show_deleted=False, resolve_data=True,
              show_nested=False):
     stacks = db_api.stack_get_all(context, limit, sort_keys, marker,
                                   sort_dir, filters, tenant_safe,
                                   show_deleted, show_nested) or []
     for stack in stacks:
         yield cls._from_db(context, stack, resolve_data=resolve_data)
Ejemplo n.º 10
0
 def get_all(cls, context, *args, **kwargs):
     db_stacks = db_api.stack_get_all(context, *args, **kwargs)
     stacks = map(
         lambda db_stack: cls._from_db_object(
             context,
             cls(context),
             db_stack),
         db_stacks)
     return stacks
Ejemplo n.º 11
0
 def get_all(cls, context, *args, **kwargs):
     db_stacks = db_api.stack_get_all(context, *args, **kwargs)
     stacks = map(
         lambda db_stack: cls._from_db_object(
             context,
             cls(context),
             db_stack),
         db_stacks)
     return stacks
Ejemplo n.º 12
0
    def start(self):
        super(EngineService, self).start()

        # Create dummy service task, because when there is nothing queued
        # on self.tg the process exits
        self.tg.add_timer(cfg.CONF.periodic_interval, self._service_task)

        # Create a periodic_watcher_task per-stack
        admin_context = context.get_admin_context()
        stacks = db_api.stack_get_all(admin_context)
        for s in stacks:
            self._timer_in_thread(s.id, s.name, self._periodic_watcher_task, sid=s.id)
Ejemplo n.º 13
0
    def start(self):
        super(EngineService, self).start()

        # Create dummy service task, because when there is nothing queued
        # on self.tg the process exits
        self.tg.add_timer(cfg.CONF.periodic_interval, self._service_task)

        # Create a periodic_watcher_task per-stack
        admin_context = context.get_admin_context()
        stacks = db_api.stack_get_all(admin_context)
        for s in stacks:
            self._start_watch_task(s.id, admin_context)
Ejemplo n.º 14
0
    def create_periodic_tasks(self):
        LOG.debug("Starting periodic watch tasks pid=%s" % os.getpid())
        # Note with multiple workers, the parent process hasn't called start()
        # so we need to create a ThreadGroupManager here for the periodic tasks
        if self.thread_group_mgr is None:
            self.thread_group_mgr = ThreadGroupManager()
        self.stack_watch = StackWatch(self.thread_group_mgr)

        # Create a periodic_watcher_task per-stack
        admin_context = context.get_admin_context()
        stacks = db_api.stack_get_all(admin_context, tenant_safe=False)
        for s in stacks:
            self.stack_watch.start_watch_task(s.id, admin_context)
Ejemplo n.º 15
0
    def create_periodic_tasks(self):
        LOG.debug("Starting periodic watch tasks pid=%s" % os.getpid())
        # Note with multiple workers, the parent process hasn't called start()
        # so we need to create a ThreadGroupManager here for the periodic tasks
        if self.thread_group_mgr is None:
            self.thread_group_mgr = ThreadGroupManager()
        self.stack_watch = StackWatch(self.thread_group_mgr)

        # Create a periodic_watcher_task per-stack
        admin_context = context.get_admin_context()
        stacks = db_api.stack_get_all(admin_context, tenant_safe=False)
        for s in stacks:
            self.stack_watch.start_watch_task(s.id, admin_context)
Ejemplo n.º 16
0
    def show_stack(self, cnxt, stack_identity):
        """
        Return detailed information about one or all stacks.

        :param cnxt: RPC context.
        :param stack_identity: Name of the stack you want to show, or None
            to show all
        """
        if stack_identity is not None:
            stacks = [self._get_stack(cnxt, stack_identity, show_deleted=True)]
        else:
            stacks = db_api.stack_get_all(cnxt) or []

        def format_stack_detail(s):
            stack = parser.Stack.load(cnxt, stack=s)
            return api.format_stack(stack)

        return [format_stack_detail(s) for s in stacks]
Ejemplo n.º 17
0
    def show_stack(self, cnxt, stack_identity):
        """
        Return detailed information about one or all stacks.

        :param cnxt: RPC context.
        :param stack_identity: Name of the stack you want to show, or None
            to show all
        """
        if stack_identity is not None:
            stacks = [self._get_stack(cnxt, stack_identity, show_deleted=True)]
        else:
            stacks = db_api.stack_get_all(cnxt) or []

        def format_stack_detail(s):
            stack = parser.Stack.load(cnxt, stack=s)
            return api.format_stack(stack)

        return [format_stack_detail(s) for s in stacks]
Ejemplo n.º 18
0
    def list_stacks(self, context, params):
        """
        The list_stacks method is the end point that actually implements
        the 'list' command of the heat API.
        arg1 -> RPC context.
        arg2 -> Dict of http request parameters passed in from API side.
        """
        logger.info("context is %s" % context)
        res = {"stacks": []}
        stacks = db_api.stack_get_all(None)
        if stacks == None:
            return res
        for s in stacks:
            ps = parser.Stack(s.name, s.raw_template.parsed_template.template, s.id, params)
            mem = {}
            mem["stack_id"] = s.id
            mem["stack_name"] = s.name
            mem["created_at"] = str(s.created_at)
            mem["template_description"] = ps.t.get("Description", "No description")
            mem["StackStatus"] = ps.t.get("stack_status", "unknown")
            res["stacks"].append(mem)

        return res
Ejemplo n.º 19
0
 def get_all(cls, context, limit=None, sort_keys=None, marker=None,
             sort_dir=None, filters=None,
             show_deleted=False, show_nested=False, show_hidden=False,
             tags=None, tags_any=None, not_tags=None,
             not_tags_any=None):
     db_stacks = db_api.stack_get_all(
         context,
         limit=limit,
         sort_keys=sort_keys,
         marker=marker,
         sort_dir=sort_dir,
         filters=filters,
         show_deleted=show_deleted,
         show_nested=show_nested,
         show_hidden=show_hidden,
         tags=tags,
         tags_any=tags_any,
         not_tags=not_tags,
         not_tags_any=not_tags_any)
     for db_stack in db_stacks:
         try:
             yield cls._from_db_object(context, cls(context), db_stack)
         except exception.NotFound:
             pass
Ejemplo n.º 20
0
Archivo: stack.py Proyecto: noako/heat
 def get_all(cls, context, *args, **kwargs):
     db_stacks = db_api.stack_get_all(context, *args, **kwargs)
     stacks = [cls._from_db_object(context, cls(context), db_stack)
               for db_stack in db_stacks]
     return stacks
Ejemplo n.º 21
0
 def metadata_list_stacks(self, context):
     """
     Return the names of the stacks registered with Heat.
     """
     stacks = db_api.stack_get_all(context)
     return [s.name for s in stacks]
Ejemplo n.º 22
0
 def get_all(cls, context, *args, **kwargs):
     db_stacks = db_api.stack_get_all(context, *args, **kwargs)
     stacks = [cls._from_db_object(context, cls(context), db_stack)
               for db_stack in db_stacks]
     return stacks
Ejemplo n.º 23
0
 def metadata_list_stacks(self, context):
     """
     Return the names of the stacks registered with Heat.
     """
     stacks = db_api.stack_get_all(context)
     return [s.name for s in stacks]