-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
realm: add methods for realm utility
realm utility is a tool manage enrollment in realm. This PR is adding methods provided by realm utility.
- Loading branch information
1 parent
7bcb65e
commit 53d14a8
Showing
2 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
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
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,110 @@ | ||
"""Manage enrollment in realms""" | ||
|
||
from __future__ import annotations | ||
|
||
from pytest_mh import MultihostHost, MultihostUtility | ||
from pytest_mh.cli import CLIBuilder, CLIBuilderArgs | ||
from pytest_mh.conn import ProcessResult | ||
from pytest_mh.utils.fs import LinuxFileSystem | ||
|
||
__all__ = [ | ||
"realmdUtils", | ||
] | ||
|
||
|
||
class Realmd(MultihostUtility[MultihostHost]): | ||
""" | ||
Call commands from realmd | ||
""" | ||
|
||
def __init__(self, host: MultihostHost, fs: LinuxFileSystem) -> None: | ||
super().__init__(host) | ||
|
||
self.cli: CLIBuilder = self.host.cli | ||
"""Command line builder.""" | ||
|
||
self.fs: LinuxFileSystem = fs | ||
"""Filesystem utils.""" | ||
|
||
def discover( | ||
self, | ||
args: list[Any]| None = None, | ||
) -> ProcessResult: | ||
""" | ||
Call ``realm discover `` with given arguments. | ||
:param domain: Discover information about domains | ||
:type domain: str, | ||
:param args: additional arguments to pass to the discover operation | ||
:type args: list, | ||
""" | ||
if args is None: | ||
args = [] | ||
|
||
return self.host.conn.exec(["realm", "discover", *args]) | ||
|
||
def leave( | ||
self, | ||
args: list[Any] | None = None | ||
) -> ProcessResult: | ||
""" | ||
Call ``realm leave `` with given arguments. | ||
:param args: additional arguments to pass to the leave operation | ||
:type args: list, | ||
""" | ||
if args is None: | ||
args = [] | ||
|
||
return self.host.conn.exec(["realm", "leave", *args]) | ||
|
||
def join( | ||
self, | ||
domain: str, | ||
args: list[Any] | None = None, | ||
passwd: str | None = None, | ||
) -> ProcessResult: | ||
""" | ||
Call ``realm join `` with given arguments. | ||
:param domain: join information about domains | ||
:type domain: str, | ||
:param args: additional arguments to pass to the join operation | ||
:type args: list, | ||
""" | ||
if args is None: | ||
args = [] | ||
|
||
return self.host.conn.exec(["realm", "join", "--verbose", *args, domain], input=passwd) | ||
|
||
def list( | ||
self, | ||
args: list[Any] | None = None, | ||
) -> ProcessResult: | ||
""" | ||
Call ``realm list `` with given arguments. | ||
List all discovered, and configured realms | ||
:param args: additional arguments to pass to the list operation | ||
:type args: list, | ||
""" | ||
if args is None: | ||
args = [] | ||
|
||
return self.host.conn.exec(["realm", "list", *args]) | ||
|
||
def permit( | ||
self, | ||
args: list[Any] | None = None, | ||
) -> ProcessResult: | ||
""" | ||
Call ``realm permit `` with given arguments. | ||
Permit local login by users of the realm | ||
:param args: permit information about domains | ||
:type args: list, | ||
""" | ||
if args is None: | ||
args = [] | ||
|
||
return self.host.conn.exec(["realm", "permit", *args]) |