示例#1
0
    def _backend_setup(self, server=True, *args, **kwargs):
        """
    Args:
      server (bool): Whether this is the client or a server

    Raises:
      TurbiniaException: When there are errors creating PSQ Queue
    """

        log.debug(
            'Setting up PSQ Task Manager requirements on project {0:s}'.format(
                config.TURBINIA_PROJECT))
        self.server_pubsub = turbinia_pubsub.TurbiniaPubSub(
            config.PUBSUB_TOPIC)
        if server:
            self.server_pubsub.setup_subscriber()
        else:
            self.server_pubsub.setup_publisher()
        psq_publisher = pubsub.PublisherClient()
        psq_subscriber = pubsub.SubscriberClient()
        datastore_client = datastore.Client(project=config.TURBINIA_PROJECT)
        try:
            self.psq = psq.Queue(
                psq_publisher,
                psq_subscriber,
                config.TURBINIA_PROJECT,
                name=config.PSQ_TOPIC,
                storage=psq.DatastoreStorage(datastore_client))
        except exceptions.GoogleCloudError as e:
            msg = 'Error creating PSQ Queue: {0:s}'.format(str(e))
            log.error(msg)
            raise turbinia.TurbiniaException(msg)
 def setUp(self):
     request = getTurbiniaRequest()
     self.pubsub = pubsub.TurbiniaPubSub('fake_topic')
     pub_sub_message = MockPubSubMessage(request.to_json(), 'msg id')
     # pylint: disable=protected-access
     self.pubsub._queue.put(pub_sub_message)
     self.pubsub.topic_path = 'faketopicpath'
示例#3
0
 def setUp(self):
     request = getTurbiniaRequest()
     self.pubsub = pubsub.TurbiniaPubSub('fake_topic')
     results = MockPubSubResults(ack_id='1234',
                                 message=MockPubSubMessage(
                                     request.to_json(), 'msg id'))
     self.pubsub.subscription = mock.MagicMock()
     self.pubsub.subscription.pull.return_value = results
示例#4
0
 def _backend_setup(self):
   log.debug(
       'Setting up PSQ Task Manager requirements on project {0:s}'.format(
           config.PROJECT))
   self.server_pubsub = turbinia_pubsub.TurbiniaPubSub(config.PUBSUB_TOPIC)
   self.server_pubsub.setup()
   psq_pubsub_client = pubsub.Client(project=config.PROJECT)
   datastore_client = datastore.Client(project=config.PROJECT)
   try:
     self.psq = psq.Queue(
         psq_pubsub_client,
         config.PSQ_TOPIC,
         storage=psq.DatastoreStorage(datastore_client))
   except GaxError as e:
     msg = 'Error creating PSQ Queue: {0:s}'.format(str(e))
     log.error(msg)
     raise turbinia.TurbiniaException(msg)