def test_save_env_file(self): env = {'EnvironmentName': 'my-environment∂'} fileoperations.save_env_file(env) self.assertEqual( 'EnvironmentName: "my-environment\\u2202"', open(os.path.join('.elasticbeanstalk', 'my-environment∂.env.yml')).read().strip())
def update_environment_configuration(app_name, env_name, nohang, timeout=None): # get environment setting api_model = elasticbeanstalk.describe_configuration_settings( app_name, env_name) # Convert the raw api return to yaml format env_settings = EnvironmentSettings(api_model) usr_model = env_settings.convert_api_to_usr_model() # Save the yaml in a temp file file_location = fileoperations.save_env_file(usr_model) fileoperations.open_file_for_editing(file_location) platform_arn = None # Update and delete file try: usr_model = fileoperations.get_environment_from_file(env_name) changes, remove = env_settings.collect_changes(usr_model) if api_model['PlatformArn'] != usr_model['PlatformArn']: platform_arn = usr_model['PlatformArn'] fileoperations.delete_env_file(env_name) except InvalidSyntaxError: io.log_error(prompts['update.invalidsyntax']) return if not changes and not remove and not platform_arn: # no changes made, exit io.log_warning('No changes made. Exiting.') return if fileoperations.env_yaml_exists(): io.echo(strings['config.envyamlexists']) commonops.update_environment(env_name, changes, nohang, remove=remove, timeout=timeout, solution_stack_name=None, platform_arn=platform_arn)
def update_environment_configuration(app_name, env_name, nohang, timeout=None): # get environment setting api_model = elasticbeanstalk.describe_configuration_settings( app_name, env_name ) # Convert the raw api return to yaml format env_settings = EnvironmentSettings(api_model) usr_model = env_settings.convert_api_to_usr_model() # Save the yaml in a temp file file_location = fileoperations.save_env_file(usr_model) fileoperations.open_file_for_editing(file_location) platform_arn = None # Update and delete file try: usr_model = fileoperations.get_environment_from_file(env_name) changes, remove = env_settings.collect_changes(usr_model) if api_model['PlatformArn'] != usr_model['PlatformArn']: platform_arn = usr_model['PlatformArn'] fileoperations.delete_env_file(env_name) except InvalidSyntaxError: io.log_error(prompts['update.invalidsyntax']) return if not changes and not remove and not platform_arn: # no changes made, exit io.log_warning('No changes made. Exiting.') return if fileoperations.env_yaml_exists(): io.echo(strings['config.envyamlexists']) commonops.update_environment(env_name, changes, nohang, remove=remove, timeout=timeout, solution_stack_name=None, platform_arn=platform_arn)
def save_env_file(api_model): usr_model = configuration.convert_api_to_usr_model(api_model) file_location = fileoperations.save_env_file(usr_model) return file_location
def save_env_file(api_model): usr_model = configuration.convert_api_to_usr_model(api_model) file_location = fileoperations.save_env_file(usr_model) return file_location