diff --git a/repos/system_upgrade/el9toel10/actors/firewalldcollectdirectconfig/actor.py b/repos/system_upgrade/el9toel10/actors/firewalldcollectdirectconfig/actor.py new file mode 100644 index 0000000000..1c758b3256 --- /dev/null +++ b/repos/system_upgrade/el9toel10/actors/firewalldcollectdirectconfig/actor.py @@ -0,0 +1,19 @@ +from leapp.actors import Actor +from leapp.libraries.actor.private_firewalldcollectdirectconfig import read_config +from leapp.models import FirewalldDirectConfig +from leapp.tags import FactsPhaseTag, IPUWorkflowTag + + +class FirewalldCollectDirectConfig(Actor): + """ + This actor reads firewalld's configuration and produces Model + FirewalldDirectConfig. + """ + + name = 'firewalld_collect_direct_config' + consumes = () + produces = (FirewalldDirectConfig,) + tags = (FactsPhaseTag, IPUWorkflowTag) + + def process(self): + self.produce(read_config()) diff --git a/repos/system_upgrade/el9toel10/actors/firewalldcollectdirectconfig/libraries/private_firewalldcollectdirectconfig.py b/repos/system_upgrade/el9toel10/actors/firewalldcollectdirectconfig/libraries/private_firewalldcollectdirectconfig.py new file mode 100644 index 0000000000..bcb041685c --- /dev/null +++ b/repos/system_upgrade/el9toel10/actors/firewalldcollectdirectconfig/libraries/private_firewalldcollectdirectconfig.py @@ -0,0 +1,26 @@ +from leapp.models import FirewalldDirectConfig + +try: + from firewall.core.fw import Firewall +except ImportError: + pass + + +def read_config(): + try: + fw = Firewall(offline=True) + except NameError: + # import failure missing means firewalld is not installed. Just return + # the defaults. + return FirewalldDirectConfig() + + # This does not actually start firewalld. It just loads the configuration a + # la firewall-offline-cmd. + fw.start() + + conf = fw.config.get_direct().export_config() + + conf_dict = {} + conf_dict['has_permanent_configuration'] = any(conf) + + return FirewalldDirectConfig(**conf_dict)