-
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.
PreparePamUserDB: implement db conversion
Check the databases reported by ScanPamUserDB and convert them to GDBM format. It also includes the component test for the actor. Signed-off-by: Iker Pedrosa <[email protected]>
- Loading branch information
Showing
5 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
repos/system_upgrade/el9toel10/actors/preparepamuserdb/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,18 @@ | ||
from leapp.actors import Actor | ||
from leapp.libraries.actor import preparepamuserdb | ||
from leapp.models import PamUserDbLocation | ||
from leapp.tags import IPUWorkflowTag, RPMUpgradePhaseTag | ||
|
||
|
||
class PreparePamUserDb(Actor): | ||
""" | ||
Convert the pam_userdb databases to GDBM | ||
""" | ||
|
||
name = 'prepare_pam_user_db' | ||
consumes = (PamUserDbLocation,) | ||
produces = () | ||
tags = (RPMUpgradePhaseTag, IPUWorkflowTag) | ||
|
||
def process(self): | ||
preparepamuserdb.process() |
19 changes: 19 additions & 0 deletions
19
repos/system_upgrade/el9toel10/actors/preparepamuserdb/libraries/preparepamuserdb.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 @@ | ||
import subprocess | ||
|
||
from leapp.libraries.stdlib import api | ||
from leapp.models import PamUserDbLocation | ||
|
||
|
||
def process(): | ||
for msg in api.consume(PamUserDbLocation): | ||
locations = msg.locations | ||
|
||
for location in locations: | ||
cmd = f'db_converter --src {location}.db --dest {location}.gdbm' | ||
try: | ||
subprocess.call(cmd, shell=True) | ||
except subprocess.CalledProcessError as e: | ||
api.current_logger().error( | ||
'{} returned non-zero exit status: {}'.format(cmd, e.returncode) | ||
) | ||
return |
Binary file added
BIN
+12 KB
repos/system_upgrade/el9toel10/actors/preparepamuserdb/tests/files/db1.db
Binary file not shown.
Binary file added
BIN
+12 KB
repos/system_upgrade/el9toel10/actors/preparepamuserdb/tests/files/db2.db
Binary file not shown.
23 changes: 23 additions & 0 deletions
23
repos/system_upgrade/el9toel10/actors/preparepamuserdb/tests/test_preparepamuserdb.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,23 @@ | ||
import os | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from leapp.libraries.actor import preparepamuserdb | ||
from leapp.libraries.stdlib import api | ||
from leapp.models import PamUserDbLocation | ||
|
||
CUR_DIR = os.path.dirname(os.path.abspath(__file__)) | ||
|
||
|
||
def test_process_locations(current_actor_context): | ||
current_actor_context.feed( | ||
PamUserDbLocation( | ||
locations=[f'{CUR_DIR}/files/db1', f'{CUR_DIR}/files/db2'] | ||
) | ||
) | ||
current_actor_context.run() | ||
db1 = Path(f'{CUR_DIR}/files/db1.gdbm') | ||
assert db1.is_file() | ||
db2 = Path(f'{CUR_DIR}/files/db2.gdbm') | ||
assert db2.is_file() |