Exemplo n.º 1
0
    def get_data(self):
        boards = []

        # Admin
        if policy.check((("iot", "iot:list_all_boards"), ), self.request):
            try:
                boards = iotronic.board_list(self.request, None, None)

            except Exception:
                exceptions.handle(self.request,
                                  _('Unable to retrieve boards list.'))

        # Admin_iot_project
        elif policy.check((("iot", "iot:list_project_boards"), ),
                          self.request):
            try:
                boards = iotronic.board_list(self.request, None, None)

            except Exception:
                exceptions.handle(self.request,
                                  _('Unable to retrieve user boards list.'))

        # Other users
        else:
            try:
                boards = iotronic.board_list(self.request, None, None)

            except Exception:
                exceptions.handle(self.request,
                                  _('Unable to retrieve user boards list.'))

        for board in boards:
            board_services = iotronic.services_on_board(
                self.request, board.uuid, True)

            # board.__dict__.update(dict(services=board_services))
            board._info.update(dict(services=board_services))
        return boards
Exemplo n.º 2
0
    def get_initial(self):
        service = self.get_object()

        # Populate boards
        boards = iotronic.board_list(self.request, "online", None, None)
        boards.sort(key=lambda b: b.name)

        board_list = []
        for board in boards:
            board_list.append((board.uuid, _(board.name)))

        return {'uuid': service.uuid,
                'name': service.name,
                'board_list': board_list}
Exemplo n.º 3
0
    def get_data(self, request, context, *args, **kwargs):
        boards = []
        result = {'list': []}

        # Admin_iot_project
        if policy.check((("iot", "iot:list_project_boards"), ), self.request):
            try:
                boards = iotronic.board_list(self.request, None, None)
                # LOG.debug('MAP data INFO: %s', boards)

                for i in range(len(boards)):
                    result["list"].append(boards[i]._info)

            except Exception:
                exceptions.handle(self.request,
                                  _('Unable to retrieve project boards list.'))

        # LOG.debug('MAP board list: %s', json.dumps(result))
        context["boards"] = json.dumps(result)
        return context