Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions src/core/src/bootstrap/Bootstrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ def __init__(self, argv, capture_stdout=True):
self.current_env = self.get_current_env()
self.argv = argv
self.auto_assessment_only = bool(self.get_value_from_argv(self.argv, Constants.ARG_AUTO_ASSESS_ONLY, "False") == "True")
self.log_file_path, self.real_record_path, self.events_folder, self.telemetry_supported = self.get_path_to_log_files_and_telemetry_dir(argv, self.auto_assessment_only)
self.recorder_enabled, self.emulator_enabled = self.get_recorder_emulator_flags(argv)
self.log_file_path, self.events_folder, self.telemetry_supported = self.get_path_to_log_files_and_telemetry_dir(argv, self.auto_assessment_only)

# Container initialization
print("Building bootstrap container configuration...")
self.configuration_factory = ConfigurationFactory(self.log_file_path, self.real_record_path, self.recorder_enabled, self.emulator_enabled, self.events_folder, self.telemetry_supported)
self.configuration_factory = ConfigurationFactory(self.log_file_path, self.events_folder, self.telemetry_supported)
self.container = Container()
self.container.build(self.configuration_factory.get_bootstrap_configuration(self.current_env))

Expand Down Expand Up @@ -74,10 +73,9 @@ def get_path_to_log_files_and_telemetry_dir(self, argv, auto_assessment_only):
log_folder = environment_settings[Constants.EnvSettings.LOG_FOLDER] # can throw exception and that's okay (since we can't recover from this)
exec_demarcator = ".aa" if auto_assessment_only else ""
log_file_path = os.path.join(log_folder, str(sequence_number) + exec_demarcator + ".core.log")
real_rec_path = os.path.join(log_folder, str(sequence_number) + exec_demarcator + ".core.rec")
events_folder = environment_settings[Constants.EnvSettings.EVENTS_FOLDER] # can throw exception and that's okay (since we can't recover from this)
telemetry_supported = environment_settings[Constants.EnvSettings.TELEMETRY_SUPPORTED]
return log_file_path, real_rec_path, events_folder, telemetry_supported
return log_file_path, events_folder, telemetry_supported

def reset_auto_assessment_log_file_if_needed(self):
""" Deletes the auto assessment log file when needed to prevent excessive growth """
Expand All @@ -87,17 +85,6 @@ def reset_auto_assessment_log_file_if_needed(self):
except Exception as error:
print("INFO: Error while checking/removing auto-assessment log file. [Path={0}][ExistsRecheck={1}]".format(self.log_file_path, str(os.path.exists(self.log_file_path))))

def get_recorder_emulator_flags(self, argv):
""" Determines if the recorder or emulator flags need to be changed from the defaults """
recorder_enabled = False
emulator_enabled = False
try:
recorder_enabled = bool(self.get_value_from_argv(argv, Constants.ARG_INTERNAL_RECORDER_ENABLED))
emulator_enabled = bool(self.get_value_from_argv(argv, Constants.ARG_INTERNAL_EMULATOR_ENABLED))
except Exception as error:
print("INFO: Default environment layer settings loaded.")
return recorder_enabled, emulator_enabled

@staticmethod
def get_value_from_argv(argv, key, default_value=Constants.DEFAULT_UNSPECIFIED_VALUE):
""" Discovers the value assigned to a given key based on the core contract on arguments """
Expand Down
16 changes: 6 additions & 10 deletions src/core/src/bootstrap/ConfigurationFactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ class ConfigurationFactory(object):
""" Class for generating module definitions. Configuration is list of key value pairs. Please DON'T change key name.
DI container relies on the key name to find and resolve dependencies. If you do need change it, please make sure to
update the key name in all places that reference it. """
def __init__(self, log_file_path, real_record_path, recorder_enabled, emulator_enabled, events_folder, telemetry_supported):
def __init__(self, log_file_path, events_folder, telemetry_supported):
self.vm_cloud_type = self.get_vm_cloud_type()
self.lifecycle_manager_component = self.get_lifecycle_manager_component(self.vm_cloud_type)

self.bootstrap_configurations = {
'prod_config': self.new_bootstrap_configuration(Constants.PROD, log_file_path, real_record_path, recorder_enabled, emulator_enabled, events_folder, telemetry_supported),
'dev_config': self.new_bootstrap_configuration(Constants.DEV, log_file_path, real_record_path, recorder_enabled, emulator_enabled, events_folder, telemetry_supported),
'test_config': self.new_bootstrap_configuration(Constants.TEST, log_file_path, real_record_path, recorder_enabled, emulator_enabled, events_folder, telemetry_supported)
'prod_config': self.new_bootstrap_configuration(Constants.PROD, log_file_path, events_folder, telemetry_supported),
'dev_config': self.new_bootstrap_configuration(Constants.DEV, log_file_path, events_folder, telemetry_supported),
'test_config': self.new_bootstrap_configuration(Constants.TEST, log_file_path, events_folder, telemetry_supported)
}

self.configurations = {
Expand Down Expand Up @@ -127,18 +127,14 @@ def get_configuration(self, env, package_manager_name):

# region - Configuration Builders
@staticmethod
def new_bootstrap_configuration(config_env, log_file_path, real_record_path, recorder_enabled, emulator_enabled, events_folder, telemetry_supported):
def new_bootstrap_configuration(config_env, log_file_path, events_folder, telemetry_supported):
""" Core configuration definition. """
configuration = {
'config_env': config_env,
'env_layer': {
'component': EnvLayer,
'component_args': [],
'component_kwargs': {
'real_record_path': real_record_path,
'recorder_enabled': recorder_enabled,
'emulator_enabled': emulator_enabled
}
'component_kwargs': {}
},
'file_logger': {
'component': FileLogger,
Expand Down
Loading