-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`ipalib.API` instances like `ipalib.api` now provide a context manager that connects and disconnects the API object. Users no longer have to deal with different types of backends or finalize the API correctly. ```python import ipalib with ipalib.api as api: api.Commands.ping() ``` See: https://pagure.io/freeipa/issue/9443 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
- Loading branch information
1 parent
8b70ee1
commit 6aebfe7
Showing
3 changed files
with
110 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,19 @@ | ||
import os | ||
|
||
import ipalib | ||
from ipaplatform.paths import paths | ||
|
||
# authenticate with host keytab and custom ccache | ||
os.environ.update( | ||
KRB5_CLIENT_KTNAME=paths.KRB5_KEYTAB, | ||
) | ||
|
||
# custom options | ||
overrides = {"context": "example_cli"} | ||
ipalib.api.bootstrap(**overrides) | ||
|
||
with ipalib.api as api: | ||
user = api.Command.user_show("admin") | ||
print(user) | ||
|
||
assert not api.Backend.rpcclient.isconnected() |
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