-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
actors: add FirewalldCollectDirectConfig
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
repos/system_upgrade/el9toel10/actors/firewalldcollectdirectconfig/actor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()) |
26 changes: 26 additions & 0 deletions
26
...l10/actors/firewalldcollectdirectconfig/libraries/private_firewalldcollectdirectconfig.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |