def install(target_basedir): """ Installs our plugin to the DNF plugins. """ try: shutil.copy2(api.get_file_path(DNF_PLUGIN_NAME), os.path.join(target_basedir, DNF_PLUGIN_PATH.lstrip('/'))) except EnvironmentError as e: api.current_logger().debug('Failed to install DNF plugin', exc_info=True) raise StopActorExecutionError( message='Failed to install DNF plugin. Error: {}'.format(str(e)))
def get_src_filepath(filename): src_filepath = api.get_file_path(filename) if src_filepath is None: raise StopActorExecutionError( 'Could not find {0} in the following paths: {1}'.format( filename, ' '.join(api.files_paths())), details={ 'hint': 'You may want to try to reinstall' ' the "leapp-repository" package' }) return src_filepath
def _get_product_certificate_path(): """ Retrieves the required / used product certificate for RHSM. """ sys_var = get_os_variant() var_prodcert = {'server': '479.pem'} if sys_var not in var_prodcert: raise StopActorExecutionError( message=('Failed to to retrieve Product Cert file.' 'Product cert file not available for System Variant \'{}\'.'.format(sys_var)) ) return api.get_file_path(var_prodcert[sys_var])
def test_actor_all_files_paths(leapp_forked, repository, actor_name): # noqa; pylint: disable=unused-argument with _with_loaded_actor(repository, actor_name) as (definition, actor): # API consistency verification assert api.files_paths() == actor.files_paths assert api.common_files_paths() == actor.common_files_paths assert api.actor_files_paths() == actor.actor_files_paths # Ensure environment and actor api results are the same assert ':'.join(actor.actor_files_paths) == os.getenv('LEAPP_FILES') assert ':'.join( actor.common_files_paths) == os.getenv('LEAPP_COMMON_FILES') assert ':'.join(actor.actor_tools_paths) == os.getenv('LEAPP_TOOLS') assert ':'.join( actor.common_tools_paths) == os.getenv('LEAPP_COMMON_TOOLS') # Here we must ensure that the sorted list of entries are correct assert sorted(actor.files_paths) == sorted( os.getenv('LEAPP_FILES').split(':') + os.getenv('LEAPP_COMMON_FILES').split(':')) assert sorted(actor.tools_paths) == sorted( os.getenv('LEAPP_TOOLS').split(':') + os.getenv('LEAPP_COMMON_TOOLS').split(':')) # Ensure LEAPP_FILES/actor_files_paths are really actor private for directory in actor.actor_files_paths: assert directory.startswith(definition.full_path) # Ensure the duplicate is resolvable from the actor private files and the right file assert actor.get_actor_file_path('duplicate') with open(actor.get_actor_file_path('duplicate')) as f: assert f.read().strip() == actor_name + '-actor' # Do the same thing with the API assert api.get_actor_file_path('duplicate') with open(api.get_actor_file_path('duplicate')) as f: assert f.read().strip() == actor_name + '-actor' # Ensure the duplicate is resolvable from the repository files and the right file assert actor.get_common_file_path('duplicate') with open(actor.get_common_file_path('duplicate')) as f: assert f.read().strip() == 'repository' # Do the same thing with the API assert api.get_common_file_path('duplicate') with open(api.get_common_file_path('duplicate')) as f: assert f.read().strip() == 'repository' # Ensure tools files api assert api.get_common_tool_path('directory/exec_script') assert check_output(api.get_common_tool_path( 'directory/exec_script')).decode('utf-8').strip() == 'repository' assert not api.get_common_tool_path('directory/nonexec_script') assert api.get_actor_tool_path('directory/exec_script') assert check_output(api.get_actor_tool_path('directory/exec_script'))\ .decode('utf-8').strip() == actor_name + '-actor' assert not api.get_actor_tool_path('directory/nonexec_script') # Ensure some file is resolvable from the repository files or the actor private files assert actor.get_file_path('duplicate') assert actor.get_file_path('duplicate') == api.get_file_path( 'duplicate') check_path = 'directory/{}-actor'.format(actor_name) assert actor.get_file_path(check_path) assert api.get_file_path(check_path) == actor.get_file_path(check_path) assert actor.get_file_path('directory/repository') assert api.get_file_path( 'directory/repository') == actor.get_file_path( 'directory/repository') assert not actor.get_common_file_path( 'directory/{}-actor'.format(actor_name)) assert not api.get_common_file_path( 'directory/{}-actor'.format(actor_name)) assert not actor.get_actor_file_path('directory/repository') assert not api.get_actor_file_path('directory/repository')