Skip to content

Commit

Permalink
Cloud provider fix (#1194)
Browse files Browse the repository at this point in the history
* fixes for cloud provider not properly being set

* fix broken tests

* lower case cloud provider

* lowercase local
  • Loading branch information
wajihyassine authored Nov 29, 2022
1 parent 24746e5 commit 5c05cde
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion turbinia/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def log_and_report(message, trace):
log.error(trace)
# If GCP Error Reporting is enabled.
config.LoadConfig()
if config.CLOUD_PROVIDER and config.STACKDRIVER_TRACEBACK:
if config.CLOUD_PROVIDER.lower() == 'gcp' and config.STACKDRIVER_TRACEBACK:
# Only load google_cloud if needed
from turbinia.lib import google_cloud
client = google_cloud.setup_stackdriver_traceback(config.TURBINIA_PROJECT)
Expand Down
2 changes: 1 addition & 1 deletion turbinia/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
RETRY_SLEEP = 60

config.LoadConfig()
if config.CLOUD_PROVIDER:
if config.CLOUD_PROVIDER.lower() == 'gcp':
from libcloudforensics.providers.gcp.internal import function as gcp_function
if config.TASK_MANAGER.lower() == 'celery':
from turbinia.state_manager import RedisStateManager
Expand Down
1 change: 1 addition & 0 deletions turbinia/client_gcp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def setUp(self, _, __): #pylint: disable=arguments-differ
config.LoadConfig()
config.TASK_MANAGER = 'PSQ'
config.STATE_MANAGER = 'Datastore'
config.CLOUD_PROVIDER = 'GCP'

# Reload module using the config settings above.
# This is needed due to the conditional imports in client.py
Expand Down
6 changes: 3 additions & 3 deletions turbinia/config/turbinia_config_tmpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
# separate when running with the same Cloud projects or backend servers.
INSTANCE_ID = 'turbinia-instance1'

# Which Cloud provider to use. Valid options are None and 'GCP'. Use 'GCP'
# for GCP or hybrid installations, and None for local installations.
CLOUD_PROVIDER = 'GCP'
# Which Cloud provider to use. Valid options are 'Local' and 'GCP'. Use 'GCP'
# for GCP or hybrid installations, and 'Local' for local installations.
CLOUD_PROVIDER = 'Local'

# Which state manager to use. Valid options are 'Datastore' or 'Redis'. Use
# 'Datastore' for Cloud (GCP) or hybrid installations, and 'Redis' for local
Expand Down
2 changes: 1 addition & 1 deletion turbinia/evidence.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from turbinia.processors import resource_manager

config.LoadConfig()
if config.CLOUD_PROVIDER:
if config.CLOUD_PROVIDER.lower() == 'gcp':
from turbinia.processors import google_cloud

log = logging.getLogger('turbinia')
Expand Down
4 changes: 2 additions & 2 deletions turbinia/turbiniactl.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ def process_args(args):
if args.debug_tasks:
config.DEBUG_TASKS = True

if config.CLOUD_PROVIDER:
if config.CLOUD_PROVIDER.lower() == 'gcp':
from turbinia.lib import google_cloud
from libcloudforensics.providers.gcp import forensics as gcp_forensics

Expand Down Expand Up @@ -613,7 +613,7 @@ def process_args(args):
all_args=all_args)
elif args.command in ('googleclouddisk', 'googleclouddiskembedded'):
# Fail if this is a local instance
if not config.CLOUD_PROVIDER and not args.force_evidence:
if config.CLOUD_PROVIDER.lower() == 'local' and not args.force_evidence:
msg = (
'The evidence type {0:s} is Cloud only, and this instance of '
'Turbinia is not a cloud instance.'.format(args.command))
Expand Down
4 changes: 3 additions & 1 deletion turbinia/turbiniactl_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ def testUnequalCloudDiskArgs(self, mockParser, mock_copyDisk, _):
"""Test unequal number of args for cloud disk evidence type."""
config.SHARED_FILESYSTEM = False
config.TASK_MANAGER = 'PSQ'
config.CLOUD_PROVIDER = 'GCP'
mockArgs = argparse.Namespace(
all_fields=False, command='googleclouddisk', config_file=None,
copy_only=False, debug=False, debug_tasks=False, decryption_keys=[],
Expand Down Expand Up @@ -387,6 +388,7 @@ def testUnequalCloudDiskEmbeddedArgs(self, mock_copyDisk, _):
# Fail when zones don't match
config.SHARED_FILESYSTEM = False
config.TASK_MANAGER = 'PSQ'
config.CLOUD_PROVIDER = 'GCP'
self.assertRaises(
TurbiniaException, turbiniactl.process_args, [
'googleclouddiskembedded', '--disk_name', 'disk1,disk2,disk3',
Expand Down Expand Up @@ -439,7 +441,7 @@ def testUnequalCloudDiskEmbeddedArgs(self, mock_copyDisk, _):
self.assertTrue(turbiniactl.process_evidence.called)

# Raise error when running locally
config.CLOUD_PROVIDER = ''
config.CLOUD_PROVIDER = 'local'
with self.assertRaisesRegex(TurbiniaException, 'Cloud only'):
turbiniactl.process_args([
'googleclouddiskembedded', '--disk_name', 'disk1,disk2,disk3',
Expand Down

0 comments on commit 5c05cde

Please sign in to comment.