diff --git a/repos/system_upgrade/el7toel8/actors/checkossfs/actor.py b/repos/system_upgrade/el7toel8/actors/checkossfs/actor.py index e96aa682dc88bd996506ce55d6af792d4029e22c..8f1b076aca5e8a8c61fd60572ef9356f90316626 100644 --- a/repos/system_upgrade/el7toel8/actors/checkossfs/actor.py +++ b/repos/system_upgrade/el7toel8/actors/checkossfs/actor.py @@ -1,9 +1,13 @@ +import subprocess + from leapp.actors import Actor from leapp.models import StorageInfo from leapp.reporting import Report, create_report from leapp import reporting from leapp.tags import ChecksPhaseTag, IPUWorkflowTag - +from leapp.libraries.stdlib import api +from leapp.dialogs import Dialog +from leapp.dialogs.components import BooleanComponent class CheckOSSfs(Actor): """ @@ -16,6 +20,23 @@ class CheckOSSfs(Actor): consumes = (StorageInfo,) produces = (Report,) tags = (ChecksPhaseTag, IPUWorkflowTag,) + + dialogs = ( + Dialog( + scope='cancle_ossfs_mount_in_fstab', + reason='Confirmation', + components=( + BooleanComponent( + key='confirm', + label='Cancle ossfs mount in fstab? ' + 'If no, the upgrade process will be interrupted.', + description='Deprecated OSSFS mount present in /etc/fstab.', + default=True, + reason='OSSFS is currently not supported by the inplace upgrade.' + ), + ) + ), + ) def process(self): details = "OSSFS is currently not supported by the inplace upgrade.\n" \ @@ -40,20 +61,31 @@ class CheckOSSfs(Actor): if systemdmount.fs_type.find('ossfs') != -1 : # mountpoint is not available in the model systemd_ossfs_mounts.append(" - {}\n".format(systemdmount.node)) + + if ossfs_mounts: + details += "- OSSFS shares currently mounted:\n" + details += ''.join(ossfs_mounts) - if any((fstab_ossfs_mounts, ossfs_mounts, systemd_ossfs_mounts)): - if fstab_ossfs_mounts: - details += "- OSSFS shares found in /etc/fstab:\n" - details += ''.join(fstab_ossfs_mounts) - - if ossfs_mounts: - details += "- OSSFS shares currently mounted:\n" - details += ''.join(ossfs_mounts) + if systemd_ossfs_mounts: + details += "- OSSFS mounts configured with systemd-mount:\n" + details += ''.join(systemd_ossfs_mounts) - if systemd_ossfs_mounts: - details += "- OSSFS mounts configured with systemd-mount:\n" - details += ''.join(systemd_ossfs_mounts) + if fstab_ossfs_mounts: + details += "- OSSFS shares found in /etc/fstab:\n" + details += ''.join(fstab_ossfs_mounts) + api.current_logger().info(details) + command = "sed -i '/ossfs/ s/^/#/' /etc/fstab" + answer = self.get_answers(self.dialogs[0]) + if answer.get('confirm') == True: + try: + subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT) + except subprocess.CalledProcessError as e: + api.current_logger().error('comment out OSSFS mount failed: {}'.format(e)) + else: + api.current_logger().info('comment out OSSFS mount succeeded: {}'.format(command)) + return + fstab_related_resource = [reporting.RelatedResource('file', '/etc/fstab')] if fstab_ossfs_mounts else [] create_report([