Esempio n. 1
0
def remove_original_subscription_manager():
    loggerinst.info(
        "Removing installed subscription-manager/katello-ca-consumer packages."
    )
    # python3-subscription-manager-rhsm, dnf-plugin-subscription-manager, subscription-manager-rhsm-certificates, etc.
    submgr_pkgs = pkghandler.get_installed_pkg_objects(
        "*subscription-manager*")
    # Satellite-server related package
    submgr_pkgs += pkghandler.get_installed_pkg_objects("katello-ca-consumer*")
    if not submgr_pkgs:
        loggerinst.info(
            "No packages related to subscription-manager installed.")
        return
    loggerinst.info(
        "Upon continuing, we will uninstall the following subscription-manager/katello-ca-consumer packages:\n"
    )
    pkghandler.print_pkg_info(submgr_pkgs)
    utils.ask_to_continue()
    submgr_pkg_names = [pkg.name for pkg in submgr_pkgs]

    if system_info.id == "centos" and system_info.version.major == 8 and system_info.version.minor == 5:
        if _SUBMGR_PKG_REMOVED_IN_CL_85 in submgr_pkg_names:
            # The package listed in _SUBMGR_PKG_REMOVED_IN_CL_85 has been
            # removed from CentOS Linux 8.5 and causes conversion to fail if
            # it's installed on that system because it's not possible to back it up.
            # https://bugzilla.redhat.com/show_bug.cgi?id=2046292
            backup.remove_pkgs([_SUBMGR_PKG_REMOVED_IN_CL_85],
                               backup=False,
                               critical=False)
            submgr_pkg_names.remove(_SUBMGR_PKG_REMOVED_IN_CL_85)

    # Remove any oter subscription-manager packages present on the system
    backup.remove_pkgs(submgr_pkg_names, critical=False)
Esempio n. 2
0
def package_analysis():
    """Go through the installed packages, report which packages are missing
    in RHEL repos and return in which RHEL repos the rest can be found.
    """
    loggerinst = logging.getLogger(__name__)

    repo_data_files = get_repo_data_files()
    if repo_data_files:
        loggerinst.info("Reading offline snapshot of RHEL repositories"
                        " for %s variant" % tool_opts.variant)
        loggerinst.info("\n".join(repo_data_files) + "\n")
        rhel_repos_content = read_repo_files(repo_data_files)
        repos_needed = match_repo_pkgs_to_installed(rhel_repos_content)
        loggerinst.info("Repositories needed: %s" % "\n".join(repos_needed) +
                        "\n")
        loggerinst.info("Listing non-%s and non-Red Hat packages ... " %
                        system_info.name)
    else:
        loggerinst.debug("Offline snapshot of RHEL repositories not found.")
        repos_needed = [system_info.default_repository_id]
    third_party_pkgs = pkghandler.get_third_party_pkgs()
    if third_party_pkgs:
        loggerinst.warning("Only packages signed by %s are to be"
                           " reinstalled. Red Hat support won't be provided"
                           " for the following third party packages:\n" %
                           system_info.name)
        pkghandler.print_pkg_info(third_party_pkgs)
        utils.ask_to_continue()
    else:
        loggerinst.info("No third party packages installed.")
    return repos_needed
Esempio n. 3
0
def remove_original_subscription_manager():
    loggerinst.info("Removing non-RHEL subscription-manager packages.")
    # python3-subscription-manager-rhsm, dnf-plugin-subscription-manager, subscription-manager-rhsm-certificates, etc.
    submgr_pkgs = pkghandler.get_installed_pkgs_w_different_fingerprint(
        system_info.fingerprints_rhel, "*subscription-manager*")
    if not submgr_pkgs:
        loggerinst.info("No packages related to subscription-manager installed.")
        return
    loggerinst.info("Upon continuing, we will uninstall the following subscription-manager pkgs:\n")
    pkghandler.print_pkg_info(submgr_pkgs)
    utils.ask_to_continue()
    submgr_pkg_names = [pkg.name for pkg in submgr_pkgs]
    utils.remove_pkgs(submgr_pkg_names, critical=False)
Esempio n. 4
0
 def test_print_pkg_info_dnf(self):
     pkgs = TestPkgHandler.prepare_pkg_obj_for_print_with_dnf()
     result = pkghandler.print_pkg_info(pkgs)
     self.assertTrue(
         re.search(r"^pkg1-0\.1-1\.x86_64\s+Oracle\s+anaconda$", result,
                   re.MULTILINE))
     self.assertTrue(
         re.search(r"^pkg2-0\.1-1\.x86_64\s+N/A\s+@@System$", result,
                   re.MULTILINE))
     self.assertTrue(
         re.search(r"^gpg-pubkey-0\.1-1\.x86_64\s+N/A\s+test$", result,
                   re.MULTILINE))
Esempio n. 5
0
 def test_print_pkg_info(self):
     pkgs = TestPkgHandler.prepare_pkg_obj_for_print()
     result = pkghandler.print_pkg_info(pkgs)
     self.assertTrue(
         re.search(r"^Package\s+Packager\s+Repository$", result,
                   re.MULTILINE))
     self.assertTrue(
         re.search(r"^pkg1-0\.1-1\.x86_64\s+Oracle\s+anaconda$", result,
                   re.MULTILINE))
     self.assertTrue(
         re.search(r"^pkg2-0\.1-1\.x86_64\s+N/A\s+N/A$", result,
                   re.MULTILINE))
     self.assertTrue(
         re.search(r"^gpg-pubkey-0\.1-1\.x86_64\s+N/A\s+test$", result,
                   re.MULTILINE))