def satellite6_capsule_zstream_upgrade(cap_host): """Upgrades Capsule to its latest zStream version :param string cap_host: Capsule hostname onto which the capsule upgrade will run Note: For zstream upgrade both 'To' and 'From' version should be same FROM_VERSION Current satellite version which will be upgraded to latest version TO_VERSION Next satellite version to which satellite will be upgraded """ logger.highlight('\n========== CAPSULE UPGRADE =================\n') from_version = os.environ.get('FROM_VERSION') to_version = os.environ.get('TO_VERSION') if not from_version == to_version: logger.warning('zStream Upgrade on Capsule cannot be performed as ' 'FROM and TO versions are not same!') sys.exit(1) major_ver = distro_info()[1] if os.environ.get('CAPSULE_URL'): disable_old_repos('rhel-{0}-server-satellite-capsule-{1}-rpms'.format( major_ver, from_version)) # Check what repos are set if os.environ.get("FOREMAN_MAINTAIN_CAPSULE_UPGRADE") == 'true': upgrade_using_foreman_maintain(sat_host=False) else: nonfm_upgrade(satellite_upgrade=False) # Rebooting the capsule for kernel update if any reboot(160) host_ssh_availability_check(cap_host) # Check if Capsule upgrade is success upgrade_validation()
def satellite_capsule_zstream_upgrade(cap_host): """Upgrades Capsule to its latest zStream version :param string cap_host: Capsule hostname onto which the capsule upgrade will run Note: For zstream upgrade both 'To' and 'From' version should be same FROM_VERSION Current satellite version which will be upgraded to latest version TO_VERSION Next satellite version to which satellite will be upgraded """ logger.highlight('\n========== CAPSULE UPGRADE =================\n') from_version = settings.upgrade.from_version to_version = settings.upgrade.to_version if not from_version == to_version: logger.highlight( 'zStream Upgrade on Capsule cannot be performed as FROM and TO ' 'versions are not same. Aborting...') sys.exit(1) major_ver = settings.upgrade.os[-1] ak_name = settings.upgrade.capsule_ak[settings.upgrade.os] run(f'subscription-manager register --org="Default_Organization" ' f'--activationkey={ak_name} --force') logger.info( f"Activation key {ak_name} registered capsule's all available repository" ) run("subscription-manager repos --list") capsule_repos = [ RHEL_CONTENTS["tools"]["label"], RHEL_CONTENTS["capsule"]["label"], RHEL_CONTENTS["maintenance"]["label"] ] with fabric_settings(warn_only=True): if settings.upgrade.distribution == "cdn": enable_disable_repo(enable_repos_name=capsule_repos) else: enable_disable_repo(disable_repos_name=capsule_repos) ansible_repos = [ f"rhel-{major_ver}-server-ansible-" f"{settings.upgrade.ansible_repo_version}-rpms" ] enable_disable_repo(enable_repos_name=ansible_repos) # Check what repos are set # setup_foreman_maintain_repo() if settings.upgrade.foreman_maintain_capsule_upgrade: upgrade_using_foreman_maintain(sat_host=False) else: nonfm_upgrade(satellite_upgrade=False) # Rebooting the capsule for kernel update if any if settings.upgrade.satellite_capsule_setup_reboot: reboot(160) host_ssh_availability_check(cap_host) # Check if Capsule upgrade is success upgrade_validation()
def satellite6_capsule_upgrade(cap_host, sat_host): """Upgrades capsule from existing version to latest version. :param string cap_host: Capsule hostname onto which the capsule upgrade will run :param string sat_host : Satellite hostname from which capsule certs are to be generated The following environment variables affect this command: CAPSULE_URL Optional, defaults to available capsule version in CDN. URL for capsule of latest compose to upgrade. FROM_VERSION Capsule current version, to disable repos while upgrading. e.g '6.1','6.0' TO_VERSION Capsule version to upgrade to and enable repos while upgrading. e.g '6.1','6.2' """ logger.highlight('\n========== CAPSULE UPGRADE =================\n') from_version = os.environ.get('FROM_VERSION') setup_capsule_firewall() major_ver = distro_info()[1] ak_name = os.environ.get('CAPSULE_AK') if os.environ.get( 'CAPSULE_AK') else os.environ.get('RHEV_CAPSULE_AK') run('subscription-manager register --org="Default_Organization" ' '--activationkey={0} --force'.format(ak_name)) disable_old_repos('rhel-{0}-server-satellite-capsule-{1}-rpms'.format( major_ver, from_version)) # setup foreman-maintain setup_foreman_maintain_repo() # Check what repos are set if os.environ.get("FOREMAN_MAINTAIN_CAPSULE_UPGRADE") == 'true': upgrade_using_foreman_maintain(sat_host=False) else: nonfm_upgrade(satellite_upgrade=False, cap_host=cap_host, sat_host=sat_host) # Rebooting the capsule for kernel update if any reboot(160) host_ssh_availability_check(cap_host) # Check if Capsule upgrade is success upgrade_validation()
def satellite6_upgrade(zstream=False): """This function is used to perform the satellite upgrade of two type based on their passed parameter. :param zstream: if upgrade_type==None: - Upgrades Satellite Server from old version to latest The following environment variables affect this command: BASE_URL Optional, defaults to available satellite version in CDN. URL for the compose repository FROM_VERSION Current satellite version which will be upgraded to latest version TO_VERSION Satellite version to upgrade to and enable repos while upgrading. e.g '6.1','6.2', '6.3' FOREMAN_MAINTAIN_SATELLITE_UPGRADE use foreman-maintain for satellite upgrade else: - Upgrades Satellite Server to its latest zStream version Note: For zstream upgrade both 'To' and 'From' version should be same FROM_VERSION Current satellite version which will be upgraded to latest version TO_VERSION Next satellite version to which satellite will be upgraded FOREMAN_MAINTAIN_SATELLITE_UPGRADE use foreman-maintain for satellite upgrade """ logger.highlight('\n========== SATELLITE UPGRADE =================\n') to_version = os.environ.get('TO_VERSION') from_version = os.environ.get('FROM_VERSION') if zstream: if not from_version == to_version: logger.warning( 'zStream Upgrade on Satellite cannot be performed as ' 'FROM and TO versions are not same!') sys.exit(1) base_url = None if not os.environ.get('BASE_URL') else os.environ.get( 'BASE_URL') major_ver = distro_info()[1] disable_repo_name = ["*"] enable_repos_name = [ 'rhel-{0}-server-rpms'.format(major_ver), 'rhel-server-rhscl-{0}-rpms'.format(major_ver) ] if bz_bug_is_open(1850934): run('echo "apache::mod::proxy::proxy_timeout: 120" >> ' '/etc/foreman-installer/custom-hiera.yaml') # This statement will execute only until downstream release not become beta. if os.environ.get('DOWNSTREAM_FM_UPGRADE') == 'true' or \ os.environ.get('FOREMAN_MAINTAIN_SATELLITE_UPGRADE') == 'false': # Following disables the old satellite repo and extra repos enabled # during subscribe e.g Load balancer Repo enable_disable_repo(disable_repo_name, enable_repos_name) os.environ[ "whitelisted_param"] = ", repositories-validate, repositories-setup" else: os.environ["whitelisted_param"] = '' if os.environ.get('FOREMAN_MAINTAIN_SATELLITE_UPGRADE') == 'true' \ and os.environ.get('OS') == 'rhel7': foreman_maintain_upgrade(base_url) else: # To install the package using foreman-maintain and it is applicable # above 6.7 version. setup_satellite_firewall() if not zstream: run('rm -rf /etc/yum.repos.d/rhel-{optional,released}.repo') logger.info('Updating system packages ... ') foreman_packages_installation_check(state="unlock") setup_foreman_maintain() update_packages(quiet=True) if base_url is None: enable_disable_repo([], [ 'rhel-{0}-server-satellite-{1}-rpms'.format( major_ver, to_version) ]) # Remove old custom sat repo repository_cleanup('sat') else: repository_setup("sat6", "satellite 6", base_url, 1, 0) nonfm_upgrade() foreman_packages_installation_check(state="lock") # Rebooting the satellite for kernel update if any reboot(180) host_ssh_availability_check(env.get('satellite_host')) # Test the Upgrade is successful upgrade_validation(True)
def satellite_upgrade(zstream=False): """This function is used to perform the satellite upgrade of two type based on their passed parameter. :param zstream: if upgrade_type==None: - Upgrades Satellite Server from old version to latest The following environment variables affect this command: SAT_UPGRADE_BASE_URL Optional, defaults to available satellite version in CDN. URL for the compose repository FROM_VERSION Current satellite version which will be upgraded to latest version TO_VERSION Satellite version to upgrade to and enable repos while upgrading. e.g '6.1','6.2', '6.3' FOREMAN_MAINTAIN_SATELLITE_UPGRADE use foreman-maintain for satellite upgrade else: - Upgrades Satellite Server to its latest zStream version Note: For zstream upgrade both 'To' and 'From' version should be same FROM_VERSION Current satellite version which will be upgraded to latest version TO_VERSION Next satellite version to which satellite will be upgraded FOREMAN_MAINTAIN_SATELLITE_UPGRADE use foreman-maintain for satellite upgrade """ logger.highlight('\n========== SATELLITE UPGRADE =================\n') if zstream: if not settings.upgrade.from_version == settings.upgrade.to_version: logger.highlight('zStream Upgrade on Satellite cannot be performed as FROM and TO' ' versions are not same. Aborting...') sys.exit(1) major_ver = settings.upgrade.os[-1] common_sat_cap_repos = [ RHEL_CONTENTS["rhscl"]["label"], RHEL_CONTENTS["server"]["label"] ] # disable all the repos enable_disable_repo(disable_repos_name=["*"]) if settings.upgrade.downstream_fm_upgrade or settings.upgrade.to_version == "6.11": settings.upgrade.whitelist_param = ", repositories-validate, repositories-setup" enable_disable_repo(enable_repos_name=common_sat_cap_repos) # maintenance repository update for satellite upgrade maintenance_repo_update() # It is required to enable the tools and server for non-fm upgrade because in # fm both the repos enabled by the fm tool. if not settings.upgrade.foreman_maintain_satellite_upgrade: enable_disable_repo(enable_repos_name=common_sat_cap_repos) if settings.upgrade.distribution == 'cdn': enable_disable_repo( enable_repos_name=[f'rhel-{major_ver}-server-satellite-maintenance-6-rpms'] ) else: for repo in CUSTOM_SAT_REPO: if float(settings.upgrade.to_version) >= 6.11 and repo == "sattools": continue if float(settings.upgrade.to_version) < 6.11 and \ (repo == "satutils" or repo == "satclient"): continue repository_setup( CUSTOM_SAT_REPO[repo]["repository"], CUSTOM_SAT_REPO[repo]["repository_name"], CUSTOM_SAT_REPO[repo]["base_url"], CUSTOM_SAT_REPO[repo]["enable"], CUSTOM_SAT_REPO[repo]["gpg"] ) foreman_maintain_package_update() if settings.upgrade.from_version == '6.9': # To fix the memory related issues for BZ#1989378 post_migration_failure_fix(100001) pulp_migration_status = pulp2_pulp3_migration() if not pulp_migration_status: logger.highlight("Pulp migration failed. Aborting") sys.exit(1) if settings.upgrade.foreman_maintain_satellite_upgrade: upgrade_using_foreman_maintain() else: # To install the package using foreman-maintain and it is applicable # above 6.7 version. setup_satellite_firewall() if not zstream: run('rm -rf /etc/yum.repos.d/rhel-{optional,released}.repo') logger.info('Updating system packages ... ') foreman_packages_installation_check(state="unlock") setup_satellite_repo() foreman_maintain_package_update() update_packages(quiet=True) if settings.upgrade.distribution == "cdn": enable_disable_repo(enable_repos_name=[f'rhel-{major_ver}-server-satellite' f'-{settings.upgrade.to_version}-rpms']) nonfm_upgrade() foreman_packages_installation_check(state="lock") # Rebooting the satellite for kernel update if any if settings.upgrade.satellite_capsule_setup_reboot: reboot(180) host_ssh_availability_check(env.get('satellite_host')) # Test the Upgrade is successful upgrade_validation() if settings.upgrade.mongodb_upgrade: mongo_db_engine_upgrade() if settings.upgrade.satellite_backup: satellite_backup()
def satellite_capsule_upgrade(cap_host, sat_host): """Upgrades capsule from existing version to latest version. :param string cap_host: Capsule hostname onto which the capsule upgrade will run :param string sat_host : Satellite hostname from which capsule certs are to be generated The following environment variables affect this command: CAPSULE_URL Optional, defaults to available capsule version in CDN. URL for capsule of latest compose to upgrade. FROM_VERSION Capsule current version, to disable repos while upgrading. e.g '6.1','6.0' TO_VERSION Capsule version to upgrade to and enable repos while upgrading. e.g '6.1','6.2' """ logger.highlight('\n========== CAPSULE UPGRADE =================\n') # Check the capsule sync before upgrade. logger.info("Check the capsule sync after satellite upgrade to verify sync operation " "with n-1 combination") execute(capsule_sync, cap_host, host=sat_host) wait_untill_capsule_sync(cap_host) from_version = settings.upgrade.from_version to_version = settings.upgrade.to_version setup_capsule_firewall() major_ver = settings.upgrade.os[-1] ak_name = settings.upgrade.capsule_ak[settings.upgrade.os] run(f'subscription-manager register --org="Default_Organization" ' f'--activationkey={ak_name} --force') logger.info(f"Activation key {ak_name} registered capsule's all available repository") run("subscription-manager repos --list") maintenance_repo = [RHEL_CONTENTS["maintenance"]["label"]] capsule_repos = [ RHEL_CONTENTS["tools"]["label"], RHEL_CONTENTS["capsule"]["label"], ] with fabric_settings(warn_only=True): if settings.upgrade.distribution == "cdn": enable_disable_repo(enable_repos_name=capsule_repos + maintenance_repo) else: enable_disable_repo(disable_repos_name=maintenance_repo) if from_version != to_version: with fabric_settings(warn_only=True): enable_disable_repo(disable_repos_name=capsule_repos) with fabric_settings(warn_only=True): enable_disable_repo(enable_repos_name=[ f"rhel-{major_ver}-server-ansible-{settings.upgrade.ansible_repo_version}-rpms"]) if settings.upgrade.foreman_maintain_capsule_upgrade: foreman_maintain_package_update() if settings.upgrade.from_version == '6.10': # capsule certs regeneration required prior 6.11 ystream capsule upgrade BZ#2049893 execute(capsule_certs_update, cap_host, host=sat_host) upgrade_using_foreman_maintain(sat_host=False) else: nonfm_upgrade(satellite_upgrade=False, cap_host=cap_host, sat_host=sat_host) # Rebooting the capsule for kernel update if any reboot(160) host_ssh_availability_check(cap_host) # Check if Capsule upgrade is success upgrade_validation(upgrade_type="capsule", satellite_services_action="restart") # Check the capsule sync after upgrade. logger.info("check the capsule sync after capsule upgrade") execute(capsule_sync, cap_host, host=sat_host) wait_untill_capsule_sync(cap_host)
def satellite6_upgrade(zstream=False): """This function is used to perform the satellite upgrade of two type based on their passed parameter. :param zstream: if upgrade_type==None: - Upgrades Satellite Server from old version to latest The following environment variables affect this command: BASE_URL Optional, defaults to available satellite version in CDN. URL for the compose repository FROM_VERSION Current satellite version which will be upgraded to latest version TO_VERSION Satellite version to upgrade to and enable repos while upgrading. e.g '6.1','6.2', '6.3' PERFORM_FOREMAN_MAINTAIN_UPGRADE use foreman-maintain for satellite upgrade else: - Upgrades Satellite Server to its latest zStream version Note: For zstream upgrade both 'To' and 'From' version should be same FROM_VERSION Current satellite version which will be upgraded to latest version TO_VERSION Next satellite version to which satellite will be upgraded PERFORM_FOREMAN_MAINTAIN_UPGRADE use foreman-maintain for satellite upgrade """ logger.highlight('\n========== SATELLITE UPGRADE =================\n') to_version = os.environ.get('TO_VERSION') from_version = os.environ.get('FROM_VERSION') if zstream: if not from_version == to_version: logger.warning( 'zStream Upgrade on Satellite cannot be performed as ' 'FROM and TO versions are not same!') sys.exit(1) base_url = os.environ.get('BASE_URL') major_ver = distro_info()[1] disable_repo_name = ["*"] enable_repos_name = [ 'rhel-{0}-server-rpms'.format(major_ver), 'rhel-server-rhscl-{0}-rpms'.format(major_ver) ] if os.environ.get('PERFORM_FOREMAN_MAINTAIN_UPGRADE') == 'true' \ and os.environ.get('OS') == 'rhel7': foreman_maintain_upgrade(base_url) else: setup_satellite_firewall() if not zstream: run('rm -rf /etc/yum.repos.d/rhel-{optional,released}.repo') logger.info('Updating system packages ... ') setup_foreman_maintain() update_packages(quiet=True) # Following disables the old satellite repo and extra repos enabled # during subscribe e.g Load balancer Repo enable_disable_repo(disable_repo_name, enable_repos_name) if base_url is None: enable_disable_repo([], [ 'rhel-{0}-server-satellite-{1}-rpms'.format( major_ver, to_version) ]) # Remove old custom sat repo repository_cleanup('sat') else: repository_setup("sat6", "satellite 6", base_url, 1, 0) nonfm_upgrade() # Rebooting the satellite for kernel update if any reboot(180) host_ssh_availability_check(env.get('satellite_host')) # Test the Upgrade is successful upgrade_validation(True)