def is_azure_pkg(pkg): """Whitelist Azure config package.""" upg_path = rhui.get_upg_path() src_pkg = rhui.RHUI_CLOUD_MAP[upg_path].get('azure', {}).get('src_pkg') src_pkg_sap = rhui.RHUI_CLOUD_MAP[upg_path].get('azure-sap', {}).get('src_pkg') target_pkg = rhui.RHUI_CLOUD_MAP[upg_path].get( 'azure', {}).get('target_pkg') target_pkg_sap = rhui.RHUI_CLOUD_MAP[upg_path].get( 'azure-sap', {}).get('target_pkg') return pkg.name in [ src_pkg, src_pkg_sap, target_pkg, target_pkg_sap ]
def _get_rh_available_repoids(context, indata): """ RH repositories are provided either by RHSM or are stored in the expected repo file provided by RHUI special packages (every cloud provider has itw own rpm). """ upg_path = rhui.get_upg_path() rh_repoids = _get_rhsm_available_repoids(context) if indata and indata.rhui_info: cloud_repo = os.path.join( '/etc/yum.repos.d/', rhui.RHUI_CLOUD_MAP[upg_path][ indata.rhui_info.provider]['leapp_pkg_repo']) rhui_repoids = _get_rhui_available_repoids(context, cloud_repo) rh_repoids.update(rhui_repoids) return rh_repoids
def _get_all_rhui_pkgs(): """ Return the list of rhui packages Currently, do not care about what rhui we have, release, etc. Just take all packages. We need them just for the purpose of filtering what files we have to remove (see _prep_repository_access) and it's ok for us to use whatever rhui rpms (the relevant rpms catch the problem, the others are just taking bytes in memory...). It's a hot-fix. We are going to refactor the library later completely.. """ upg_path = rhui.get_upg_path() pkgs = [] for rhui_map in rhui.RHUI_CLOUD_MAP[upg_path].values(): for key in rhui_map.keys(): if not key.endswith('pkg'): continue pkgs.append(rhui_map[key]) return pkgs
def is_azure_agent_installed(): """Check whether 'WALinuxAgent' package is installed.""" upg_path = rhui.get_upg_path() agent_pkg = rhui.RHUI_CLOUD_MAP[upg_path].get('azure', {}).get('agent_pkg', '') return has_package(InstalledRPM, agent_pkg)
def process(self): upg_path = rhui.get_upg_path() for provider, info in rhui.RHUI_CLOUD_MAP[upg_path].items(): if has_package(InstalledRPM, info['src_pkg']): is_azure_sap = False azure_sap_pkg = rhui.RHUI_CLOUD_MAP[upg_path]['azure-sap'][ 'src_pkg'] azure_nonsap_pkg = rhui.RHUI_CLOUD_MAP[upg_path]['azure'][ 'src_pkg'] # we need to do this workaround in order to overcome our RHUI handling limitation # in case there are more client packages on the source system if 'azure' in info['src_pkg'] and has_package( InstalledRPM, azure_sap_pkg): is_azure_sap = True provider = 'azure-sap' info = rhui.RHUI_CLOUD_MAP[upg_path]['azure-sap'] if not rhsm.skip_rhsm(): create_report([ reporting.Title( 'Upgrade initiated with RHSM on public cloud with RHUI infrastructure' ), reporting.Summary( 'Leapp detected this system is on public cloud with RHUI infrastructure ' 'but the process was initiated without "--no-rhsm" command line option ' 'which implies RHSM usage (valid subscription is needed).' ), reporting.Severity(reporting.Severity.INFO), reporting.Tags([reporting.Tags.PUBLIC_CLOUD]), ]) return # AWS RHUI package is provided and signed by RH but the Azure one not if not has_package(InstalledRPM, info['leapp_pkg']): create_report([ reporting.Title('Package "{}" is missing'.format( info['leapp_pkg'])), reporting.Summary( 'On {} using RHUI infrastructure, a package "{}" is needed for' 'in-place upgrade'.format(provider.upper(), info['leapp_pkg'])), reporting.Severity(reporting.Severity.HIGH), reporting.RelatedResource('package', info['leapp_pkg']), reporting.Flags([reporting.Flags.INHIBITOR]), reporting.Tags( [reporting.Tags.PUBLIC_CLOUD, reporting.Tags.RHUI]), reporting.Remediation(commands=[[ 'yum', 'install', '-y', info['leapp_pkg'] ]]) ]) return # there are several "variants" related to the *AWS* provider (aws, aws-sap) if provider.startswith('aws'): # We have to disable Amazon-id plugin in the initramdisk phase as the network # is down at the time self.produce( DNFPluginTask(name='amazon-id', disable_in=['upgrade'])) # if RHEL7 and RHEL8 packages differ, we cannot rely on simply updating them if info['src_pkg'] != info['target_pkg']: self.produce( RpmTransactionTasks(to_install=[info['target_pkg']])) self.produce( RpmTransactionTasks(to_remove=[info['src_pkg']])) if is_azure_sap: self.produce( RpmTransactionTasks(to_remove=[azure_nonsap_pkg])) self.produce(RHUIInfo(provider=provider)) self.produce( RequiredTargetUserspacePackages( packages=[info['target_pkg']])) return