コード例 #1
0
ファイル: output.py プロジェクト: thomcost/cloud-custodian
    def get_handler(self):
        # gcp has three independent implementation of api bindings for python.
        # The one used by logging is not yet supported by our test recording.

        # TODO drop these grpc variants for the REST versions, and we can drop
        # protobuf/grpc deps, and also so we can record tests..
        # gcp has three different python sdks all independently maintained .. hmmm...
        # and random monkey shims on top of those :-(

        from google.cloud.logging import Client as LogClient
        from google.cloud.logging.handlers import CloudLoggingHandler
        from google.cloud.logging.resource import Resource

        log_group = self.ctx.options.log_group
        if log_group.endswith('*'):
            log_group = "%s%s" % (log_group[:-1], self.ctx.policy.name)

        project_id = local_session(
            self.ctx.session_factory).get_default_project()
        client = LogClient(project_id)

        return CloudLoggingHandler(client,
                                   log_group,
                                   resource=Resource(
                                       type='project',
                                       labels={'project_id': project_id}))
コード例 #2
0
    def get_handler(self):
        # TODO drop these grpc variants for the REST versions, and we can drop
        # protobuf/grpc deps, and also so we can record tests.

        log_group = self.get_log_group()
        project_id = local_session(self.ctx.session_factory).get_default_project()
        client = LogClient(project_id)
        return CloudLoggingHandler(
            client,
            log_group,
            labels={
                'policy': self.ctx.policy.name,
                'resource': self.ctx.policy.resource_type},
            resource=Resource(type='project', labels={'project_id': project_id}))
コード例 #3
0
ファイル: output.py プロジェクト: zerojuls/cloud-custodian
    def get_handler(self):
        # gcp has three independent implementation of api bindings for python.
        # The one used by logging is not yet supported by our test recording.

        log_group = self.ctx.options.log_group
        if log_group.endswith('*'):
            log_group = "%s%s" % (log_group[:-1], self.ctx.policy.name)

        project_id = local_session(
            self.ctx.session_factory).get_default_project()
        client = LogClient(project_id)

        return CloudLoggingHandler(client,
                                   log_group,
                                   resource=Resource(
                                       type='project',
                                       labels={'project_id': project_id}))