Exemple #1
0
    def list_stacks(self, cnxt, limit=None, marker=None, sort_keys=None,
                    sort_dir=None, filters=None):
        """
        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
        :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_by_tenant(cnxt, limit, sort_keys, marker,
                                                sort_dir, filters) or []
        return list(format_stack_details(stacks))
Exemple #2
0
    def list_stacks(self, cnxt, limit=None, marker=None, sort_keys=None,
                    sort_dir=None, filters=None):
        """
        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
        :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_by_tenant(cnxt, limit, sort_keys, marker,
                                                sort_dir, filters) or []
        return list(format_stack_details(stacks))
Exemple #3
0
    def list_stacks(self, context):
        """
        The list_stacks method returns attributes of all stacks.
        arg1 -> RPC context.
        """
        stacks = db_api.stack_get_all_by_tenant(context) or []

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

        return {'stacks': [format_stack_detail(s) for s in stacks]}
Exemple #4
0
    def list_stacks(self, context):
        """
        The list_stacks method returns attributes of all stacks.
        arg1 -> RPC context.
        """
        stacks = db_api.stack_get_all_by_tenant(context) or []

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

        return {"stacks": [format_stack_detail(s) for s in stacks]}
    def show_stack(self, cnxt, stack_identity):
        """
        Return detailed information about one or all stacks.
        arg1 -> RPC cnxt.
        arg2 -> 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_by_tenant(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]
Exemple #6
0
    def show_stack(self, cnxt, stack_identity):
        """
        Return detailed information about one or all stacks.
        arg1 -> RPC cnxt.
        arg2 -> 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_by_tenant(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]
Exemple #7
0
    def list_stacks(self, context):
        """
        The list_stacks method returns attributes of all stacks.
        arg1 -> RPC context.
        """

        def format_stack_details(stacks):
            for s in stacks:
                try:
                    stack = parser.Stack.load(context, 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_by_tenant(context) or []
        return list(format_stack_details(stacks))
Exemple #8
0
    def list_stacks(self, cnxt):
        """
        The list_stacks method returns attributes of all stacks.
        arg1 -> RPC cnxt.
        """
        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_by_tenant(cnxt) or []
        return list(format_stack_details(stacks))