示例#1
0
文件: build.py 项目: CermakM/osiris
    def get(self, page):
        """Paginate build information documents stored in Ceph."""
        schema = BuildInfoPaginationSchema()
        paginated_data: BuildInfoPagination = build_aggregator.paginate_build_data(
            page)

        return request_ok(payload=schema.dump(paginated_data))
示例#2
0
文件: build.py 项目: CermakM/osiris
    def get(self, build_id):
        """Return logs stored by the given build."""
        build_log, = build_aggregator.retrieve_build_data(build_id,
                                                          log_only=True)

        # TODO: return the whole doc or just the build log?
        return request_ok(payload=build_log)
示例#3
0
文件: config.py 项目: fridex/osiris
    def get(self):
        """Get current client configuration."""
        schema = ConfigSchema()

        client = get_oc_client()
        client_config = client.ocp_client.configuration
        client_config.token = client.token

        errors = dict()

        try:
            _, context = list_kube_config_contexts()

            client_config.context = context['name']
            client_config.cluster = context['context']['cluster']
            client_config.namespace = context['context']['namespace']
            client_config.username, _ = context['context']['user'].split('/')

        except (FileNotFoundError, KeyError) as exc:
            errors['context'] = str(exc)

            if client.in_cluster:
                client_config.namespace = Path(
                    "/run/secrets/kubernetes.io/serviceaccount/namespace"
                ).read_text()
            else:
                client_config.namespace = client.middletier_namespace

        return request_ok(payload=schema.dump(client_config.__dict__),
                          errors=errors)
示例#4
0
文件: build.py 项目: fridex/osiris
    def get(self, build_id):
        """Return complete information stored about given build."""

        schema = BuildInfoSchema()
        _, build_info = build_aggregator.retrieve_build_data(build_id)

        return request_ok(payload=schema.dump(build_info))
示例#5
0
文件: probes.py 项目: fridex/osiris
    def get(self):  # pragma: no cover
        """Readiness check."""
        if build_aggregator.is_connected():

            return request_ok()
        # TODO: what else should be checked? Check auth as well?
        else:

            return request_unavailable()
示例#6
0
文件: build.py 项目: CermakM/osiris
    def put(self, build_id):
        """Store logs for the given build in Ceph."""
        build_log, build_info = build_aggregator.retrieve_build_data(build_id)

        if build_log is not None and not int(request.args.get('force', 1)):

            return bad_request(
                errors={
                    'BuildLogExists':
                    f"Build log `{build_id}` already exists"
                    " and `force` is not specified."
                })

        build_doc, _ = BuildInfoSchema().dump(build_info)

        build_log_schema = BuildLogSchema()
        build_log, validation_errors = build_log_schema.load(request.json)

        if not build_info.build_complete():
            resp = bad_request(errors={
                'BuildNotCompleted':
                "Build has not been completed yet.",
            },
                               validation_errors=validation_errors)

        else:
            if 'build_id' not in build_log['metadata']:
                build_log['metadata']['build_id'] = build_id

            build_doc['build_log'] = build_log

            build_aggregator.store_build_data(build_doc)

            resp = request_ok()

        return resp
示例#7
0
文件: build.py 项目: CermakM/osiris
    def get(self, build_id):
        """Return status of the given build."""
        _, build_info = build_aggregator.retrieve_build_data(build_id)

        return request_ok(payload={'build_status': build_info.build_status})
示例#8
0
文件: probes.py 项目: fridex/osiris
 def get(self):  # pragma: no cover
     """Health check."""
     return request_ok()