コード例 #1
0
ファイル: execution.py プロジェクト: www3838438/zoe
    def get(self, execution_id):
        """GET a single execution by its ID."""
        uid, role = get_auth(self)

        e = self.api_endpoint.execution_by_id(uid, role, execution_id)

        self.write(e.serialize())
コード例 #2
0
    def get(self, service_id) -> dict:
        """HTTP GET method."""
        uid, role = get_auth(self)

        service = self.api_endpoint.service_by_id(uid, role, service_id)

        self.write(service.serialize())
コード例 #3
0
ファイル: service.py プロジェクト: nuaays/zoe
    def get(self, service_id) -> dict:
        """HTTP GET method."""
        uid, role = get_auth(self)

        service = self.api_endpoint.service_by_id(uid, role, service_id)

        self.write(service.serialize())
コード例 #4
0
    def get(self, service_id):
        """HTTP GET method."""

        uid, role = get_auth(self)

        log_gen = self.api_endpoint.service_logs(uid, role, service_id, stream=True)

        while True:
            try:
                log_line = yield THREAD_POOL.submit(next, log_gen)
            except StopIteration:
                break

            self.write(log_line)

            try:
                yield self.flush()
            except tornado.iostream.StreamClosedError:
                break

            if self.connection_closed:
                break

        log.debug('Finished log stream for service {}'.format(service_id))
        self.finish()
コード例 #5
0
ファイル: userinfo.py プロジェクト: www3838438/zoe
    def get(self):
        """HTTP GET method."""
        uid, role = get_auth(self)

        ret = {'uid': uid, 'role': role}

        self.write(ret)
コード例 #6
0
ファイル: service.py プロジェクト: nuaays/zoe
    def get(self, service_id):
        """HTTP GET method."""

        uid, role = get_auth(self)

        log_gen = self.api_endpoint.service_logs(uid,
                                                 role,
                                                 service_id,
                                                 stream=True)

        while True:
            try:
                log_line = yield THREAD_POOL.submit(next, log_gen)
            except StopIteration:
                break

            self.write(log_line)

            try:
                yield self.flush()
            except tornado.iostream.StreamClosedError:
                break

            if self.connection_closed:
                break

        log.debug('Finished log stream for service {}'.format(service_id))
        self.finish()
コード例 #7
0
    def get(self, execution_id):
        """GET a single execution by its ID."""
        uid, role = get_auth(self)

        e = self.api_endpoint.execution_by_id(uid, role, execution_id)

        self.write(e.serialize())
コード例 #8
0
ファイル: query.py プロジェクト: KWresearch/zoe
    def post(self):
        uid, role = get_auth(request)

        try:
            data = request.get_json()
        except BadRequest:
            raise ZoeRestAPIException('Error decoding JSON data')

        if 'what' not in data:
            raise ZoeRestAPIException('"what" is required in query object')

        what = data['what']
        if 'filters' not in data:
            filters = {}
        else:
            filters = data['filters']

        if not isinstance(filters, dict):
            raise ZoeRestAPIException('query filters should be a dictionary of {attribute: requested_value} entries')

        if what == 'stats_scheduler':
            # TODO
            ret = None
        elif what == 'execution':
            if role != 'admin':
                filters['user_id'] = uid
            execs = self.api_endpoint.execution_list(uid, role, **filters)
            return [x.serialize() for x in execs]
        else:
            raise ZoeRestAPIException('unknown query {}'.format(what))

        return ret
コード例 #9
0
ファイル: query.py プロジェクト: townie/zoe
    def post(self):
        uid, role = get_auth(request)

        try:
            data = request.get_json()
        except BadRequest:
            raise ZoeRestAPIException('Error decoding JSON data')

        if 'what' not in data:
            raise ZoeRestAPIException('"what" is required in query object')

        what = data['what']
        if 'filters' not in data:
            filters = {}
        else:
            filters = data['filters']

        if not isinstance(filters, dict):
            raise ZoeRestAPIException(
                'query filters should be a dictionary of {attribute: requested_value} entries'
            )

        if what == 'stats_scheduler':
            # TODO
            ret = None
        elif what == 'execution':
            if role != 'admin':
                filters['user_id'] = uid
            execs = self.api_endpoint.execution_list(uid, role, **filters)
            return [x.serialize() for x in execs]
        else:
            raise ZoeRestAPIException('unknown query {}'.format(what))

        return ret
コード例 #10
0
ファイル: execution.py プロジェクト: KWresearch/zoe
    def get(self):
        """
        Returns a list of all active executions.

        :return:
        """
        uid, role = get_auth(request)

        execs = self.api_endpoint.execution_list(uid, role)
        return [e.serialize() for e in execs]
コード例 #11
0
ファイル: execution.py プロジェクト: nuaays/zoe
    def get(self):
        """
        Returns a list of all active executions.

        :return:
        """
        uid, role = get_auth(self)

        execs = self.api_endpoint.execution_list(uid, role)
        self.write(dict([(e.id, e.serialize()) for e in execs]))
コード例 #12
0
    def get(self):
        """
        Returns a list of all active executions.

        :return:
        """
        uid, role = get_auth(self)

        execs = self.api_endpoint.execution_list(uid, role)
        self.write(dict([(e.id, e.serialize()) for e in execs]))
コード例 #13
0
    def get(self):
        """
        Returns a list of all active executions.

        :return:
        """
        uid, role = get_auth(request)

        execs = self.api_endpoint.execution_list(uid, role)
        return [e.serialize() for e in execs]
コード例 #14
0
    def delete(self, execution_id: int):
        """
        Delete an execution.

        :param execution_id: the execution to be deleted
        """
        uid, role = get_auth(self)

        success, message = self.api_endpoint.execution_delete(uid, role, execution_id)
        if not success:
            raise zoe_api.exceptions.ZoeRestAPIException(message, 400)

        self.set_status(204)
コード例 #15
0
ファイル: execution.py プロジェクト: www3838438/zoe
    def get(self, execution_id: int):
        """
        Get a list of execution endpoints.

        :param execution_id: the execution to be deleted
        """
        uid, role = get_auth(self)

        execution = self.api_endpoint.execution_by_id(uid, role, execution_id)
        services_, endpoints = self.api_endpoint.execution_endpoints(
            uid, role, execution)

        self.write({'endpoints': endpoints})
コード例 #16
0
    def get(self):
        """HTTP GET method."""
        uid, role = get_auth(self)

        cookie_val = uid + '.' + role

        self.set_secure_cookie('zoe', cookie_val)

        ret = {
            'uid': uid,
            'role': role
        }

        self.write(ret)
コード例 #17
0
ファイル: execution.py プロジェクト: KWresearch/zoe
    def delete(self, execution_id: int):
        """
        This method is called when a user wants to stop an execution. To actually delete the execution,
        the user has to delete the 'parent' application.
        :param execution_id: the execution to be deleted
        :return:
        """
        uid, role = get_auth(request)

        success, message = self.api_endpoint.execution_terminate(uid, role, execution_id)
        if not success:
            raise zoe_api.exceptions.ZoeRestAPIException(message, 400)

        return '', 204
コード例 #18
0
ファイル: execution.py プロジェクト: www3838438/zoe
    def delete(self, execution_id: int):
        """
        Delete an execution.

        :param execution_id: the execution to be deleted
        """
        uid, role = get_auth(self)

        success, message = self.api_endpoint.execution_delete(
            uid, role, execution_id)
        if not success:
            raise zoe_api.exceptions.ZoeRestAPIException(message, 400)

        self.set_status(204)
コード例 #19
0
    def delete(self, execution_id: int):
        """
        This method is called when a user wants to stop an execution. To actually delete the execution,
        the user has to delete the 'parent' application.
        :param execution_id: the execution to be deleted
        :return:
        """
        uid, role = get_auth(request)

        success, message = self.api_endpoint.execution_terminate(
            uid, role, execution_id)
        if not success:
            raise zoe_api.exceptions.ZoeRestAPIException(message, 400)

        return '', 204
コード例 #20
0
ファイル: execution.py プロジェクト: KWresearch/zoe
    def post(self):
        """
        Starts an execution, given an application description. Takes a JSON object.
        :return: the new execution_id
        """
        uid, role = get_auth(request)

        try:
            data = request.get_json()
        except BadRequest:
            raise zoe_api.exceptions.ZoeRestAPIException('Error decoding JSON data')

        application_description = data['application']
        exec_name = data['name']

        new_id = self.api_endpoint.execution_start(uid, role, exec_name, application_description)

        return {'execution_id': new_id}, 201
コード例 #21
0
ファイル: execution.py プロジェクト: www3838438/zoe
    def get(self):
        """
        Returns a list of all active executions.

        The list can be filtered by passing a non-empty JSON dictionary. Any combination of the following filters is supported:

        * status: one of submitted, scheduled, starting, error, running, cleaning up, terminated
        * name: execution mane
        * user_id: user_id owning the execution (admin only)
        * limit: limit the number of returned entries
        * earlier_than_submit: all execution that where submitted earlier than this timestamp
        * earlier_than_start: all execution that started earlier than this timestamp
        * earlier_than_end: all execution that ended earlier than this timestamp
        * later_than_submit: all execution that where submitted later than this timestamp
        * later_than_start: all execution that started later than this timestamp
        * later_than_end: all execution that started later than this timestamp

        All timestamps should be passed as number of seconds since the epoch (UTC timezone).

        example:  curl -u 'username:password' -X GET 'http://bf5:8080/api/0.6/execution?limit=1&status=terminated'

        :return:
        """
        uid, role = get_auth(self)

        filt_dict = {}

        filters = [('status', str), ('name', str), ('user_id', str),
                   ('limit', int), ('earlier_than_submit', int),
                   ('earlier_than_start', int), ('earlier_than_end', int),
                   ('later_than_submit', int), ('later_than_start', int),
                   ('later_than_end', int)]
        for filt in filters:
            if filt[0] in self.request.arguments:
                if filt[1] == str:
                    filt_dict[filt[0]] = self.request.arguments[
                        filt[0]][0].decode('utf-8')
                else:
                    filt_dict[filt[0]] = filt[1](
                        self.request.arguments[filt[0]][0])

        execs = self.api_endpoint.execution_list(uid, role, **filt_dict)

        self.write(dict([(e.id, e.serialize()) for e in execs]))
コード例 #22
0
    def post(self):
        """
        Starts an execution, given an application description. Takes a JSON object.

        :return: the new execution_id
        """
        uid, role = get_auth(self)

        try:
            data = tornado.escape.json_decode(self.request.body)
        except ValueError:
            raise zoe_api.exceptions.ZoeRestAPIException("Error decoding JSON data")

        application_description = data["application"]
        exec_name = data["name"]

        new_id = self.api_endpoint.execution_start(uid, role, exec_name, application_description)

        self.set_status(201)
        self.write({"execution_id": new_id})
コード例 #23
0
    def post(self):
        """
        Starts an execution, given an application description. Takes a JSON object.
        :return: the new execution_id
        """
        uid, role = get_auth(request)

        try:
            data = request.get_json()
        except BadRequest:
            raise zoe_api.exceptions.ZoeRestAPIException(
                'Error decoding JSON data')

        application_description = data['application']
        exec_name = data['name']

        new_id = self.api_endpoint.execution_start(uid, role, exec_name,
                                                   application_description)

        return {'execution_id': new_id}, 201
コード例 #24
0
ファイル: service.py プロジェクト: www3838438/zoe
    def get(self, service_id):
        """HTTP GET method."""

        uid, role = get_auth(self)

        log_obj = self.api_endpoint.service_logs(uid, role, service_id)

        while not self.connection_closed:
            try:
                log_line = yield THREAD_POOL.submit(next, log_obj)
            except StopIteration:
                yield tornado.gen.sleep(0.2)
                continue

            self.write(log_line)

            try:
                yield self.flush()
            except tornado.iostream.StreamClosedError:
                break
コード例 #25
0
ファイル: execution.py プロジェクト: nuaays/zoe
    def post(self):
        """
        Starts an execution, given an application description. Takes a JSON object.
        :return: the new execution_id
        """
        uid, role = get_auth(self)

        try:
            data = tornado.escape.json_decode(self.request.body)
        except ValueError:
            raise zoe_api.exceptions.ZoeRestAPIException(
                'Error decoding JSON data')

        application_description = data['application']
        exec_name = data['name']

        new_id = self.api_endpoint.execution_start(uid, role, exec_name,
                                                   application_description)

        self.set_status(201)
        self.write({'execution_id': new_id})
コード例 #26
0
    def get(self, service_id):
        uid, role = get_auth(request)

        s = self.api_endpoint.service_by_id(uid, role, service_id)

        return s.serialize()
コード例 #27
0
ファイル: execution.py プロジェクト: KWresearch/zoe
    def get(self, execution_id):
        uid, role = get_auth(request)

        e = self.api_endpoint.execution_by_id(uid, role, execution_id)

        return e.serialize()
コード例 #28
0
    def get(self, execution_id):
        uid, role = get_auth(request)

        e = self.api_endpoint.execution_by_id(uid, role, execution_id)

        return e.serialize()