def print_non_interactive_opts(): """Print command line options to be used for the next run of the tool to avoid the need of any interactive input during the system conversion. """ loggerinst = logging.getLogger(__name__) loggerinst.info("For the non-interactive use of the tool, run the" " following command:") global tool_opts # pylint: disable=C0103 cmd = utils.get_executable_name() if tool_opts.disable_submgr: cmd += " --disable-submgr " for repo in tool_opts.disablerepo: cmd += " --disablerepo=%s " % repo for repo in tool_opts.enablerepo: cmd += " --enablerepo=%s " % repo else: if tool_opts.username: cmd += " -u %s" % tool_opts.username if tool_opts.password_file: pswd_opt = " -f %s" % tool_opts.password_file else: pswd_opt = " -p *****" cmd += pswd_opt if tool_opts.activation_key: cmd += " -k %s" % tool_opts.activation_key if tool_opts.org: cmd += " -o %s" % tool_opts.org cmd += " %s" % tool_opts.pool cmd += " -y" loggerinst.info(cmd + "\n\n")
def rename_repo_files(): """Rename non-Red Hat .repo files in /etc/yum.repos.d/ so the repositories in them are not used by yum command. """ loggerinst = logging.getLogger(__name__) repo_files_renamed = False exe_name = utils.get_executable_name() for filename in os.listdir("/etc/yum.repos.d/"): if filename.endswith(".repo") and filename != "redhat.repo": filepath_old = os.path.join("/etc/yum.repos.d/", filename) filepath_new = "%s.%s_renamed" % (filepath_old, exe_name) shutil.move(filepath_old, filepath_new) loggerinst.info("Renamed: %s -> %s" % (filepath_old, filepath_new)) repo_files_renamed = True if not repo_files_renamed: loggerinst.info("No .repo file renamed.") return
def rollback_renamed_repo_files(): """Rollback all non-Red Hat .repo files in /etc/yum.repos.d/ that were renamed. """ loggerinst = logging.getLogger(__name__) loggerinst.task("Rollback: Rollback all non-Red Hat .repo files renamed in" " /etc/yum.repos.d/") exe_name = utils.get_executable_name() file_restored = False for filename in os.listdir("/etc/yum.repos.d/"): if filename.endswith(".%s_renamed" % exe_name): filepath_old = os.path.join("/etc/yum.repos.d/", filename) filepath_new = os.path.splitext(filepath_old)[0] shutil.move(filepath_old, filepath_new) loggerinst.info("Renamed: %s -> %s" % (filepath_old, filepath_new)) file_restored = True if not file_restored: loggerinst.info("No .repo files to rollback")