def SetUp(self, disk_name, project, turbinia_zone, sketch_id, run_all_jobs): """Sets up the object attributes. Args: disk_name (str): name of the disk to process. project (str): name of the GPC project containing the disk to process. turbinia_zone (str): GCP zone in which the Turbinia server is running. sketch_id (int): The Timesketch sketch id run_all_jobs (bool): Whether to run all jobs instead of a faster subset. """ # TODO: Consider the case when multiple disks are provided by the previous # module or by the CLI. if project is None or turbinia_zone is None: self.state.AddError( 'project or turbinia_zone are not all specified, bailing out', critical=True) return self.disk_name = disk_name self.project = project self.turbinia_zone = turbinia_zone self.sketch_id = sketch_id self.run_all_jobs = run_all_jobs try: turbinia_config.LoadConfig() self.turbinia_region = turbinia_config.TURBINIA_REGION self.instance = turbinia_config.PUBSUB_TOPIC if turbinia_config.TURBINIA_PROJECT != self.project: self.state.AddError( 'Specified project {0!s} does not match Turbinia configured ' 'project {1!s}. Use gcp_turbinia_import recipe to copy the disk ' 'into the same project.'.format( self.project, turbinia_config.TURBINIA_PROJECT), critical=True) return self._output_path = tempfile.mkdtemp() self.client = turbinia_client.TurbiniaClient() except TurbiniaException as exception: # TODO: determine if exception should be converted into a string as # elsewhere in the codebase. self.state.AddError(exception, critical=True) return
def setup(self, disk_name, project, turbinia_zone): """Sets up the object attributes. Args: disk_name (string): Name of the disk to process project (string): The project containing the disk to process turbinia_zone (string): The zone containing the disk to process """ # TODO: Consider the case when multiple disks are provided by the previous # module or by the CLI. if self.state.input and not disk_name: _, disk = self.state.input[0] disk_name = disk.name print('Using disk {0:s} from previous collector'.format(disk_name)) if disk_name is None or project is None or turbinia_zone is None: self.state.add_error( 'disk_name, project or turbinia_zone are not all specified, bailing ' 'out', critical=True) return self.disk_name = disk_name self.project = project self.turbinia_zone = turbinia_zone try: turbinia_config.LoadConfig() self.turbinia_region = turbinia_config.TURBINIA_REGION self.instance = turbinia_config.PUBSUB_TOPIC if turbinia_config.PROJECT != self.project: self.state.add_error( 'Specified project {0:s} does not match Turbinia configured ' 'project {1:s}. Use gcp_turbinia_import recipe to copy the disk ' 'into the same project.'.format(self.project, turbinia_config.PROJECT), critical=True) return self._output_path = tempfile.mkdtemp() self.client = turbinia_client.TurbiniaClient() except TurbiniaException as e: self.state.add_error(e, critical=True) return
def TurbiniaSetUp(self, project, turbinia_zone, sketch_id, run_all_jobs): """Sets up the object attributes. Args: project (str): name of the GCP project containing the disk to process. turbinia_zone (str): GCP zone in which the Turbinia server is running. sketch_id (int): The Timesketch sketch ID. run_all_jobs (bool): Whether to run all jobs instead of a faster subset. """ self.project = project self.turbinia_zone = turbinia_zone self.sketch_id = sketch_id self.run_all_jobs = run_all_jobs turbinia_config.LoadConfig(config_file=self.turbinia_config_file) if not self.project: self.project = turbinia_config.TURBINIA_PROJECT if not self.turbinia_zone: self.turbinia_zone = turbinia_config.TURBINIA_ZONE if self.project is None or self.turbinia_zone is None: self.ModuleError( 'project or turbinia_zone are not all specified, bailing out', critical=True) return self.turbinia_region = turbinia_config.TURBINIA_REGION self.instance = turbinia_config.INSTANCE_ID if turbinia_config.TURBINIA_PROJECT != self.project: self.ModuleError( 'Specified project {0!s} does not match Turbinia configured ' 'project {1!s}. Use gcp_turbinia_disk_copy_ts recipe to copy the ' 'disk into the same project.'.format( self.project, turbinia_config.TURBINIA_PROJECT), critical=True) return self._output_path = tempfile.mkdtemp() self.client = turbinia_client.TurbiniaClient()