forked from juju/python-libjuju
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the unit.run function to conform to the juju 3.0 way of interaction
... regardless of the version of the client and/or facade being used Fixes juju#707
- Loading branch information
Showing
5 changed files
with
81 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
from juju import jasyncio | ||
from juju.model import Model | ||
|
||
# logging.basicConfig(level='DEBUG') | ||
|
||
# Get a k8s controller | ||
# e.g. juju bootstrap microk8s test-k8s | ||
|
||
# Add a model | ||
# e.g. juju add-model test-actions | ||
|
||
# Then run this module | ||
# e.g. python examples/run_action.py | ||
|
||
|
||
async def _get_password(): | ||
model = Model() | ||
await model.connect() | ||
await model.deploy('zinc-k8s') | ||
await model.wait_for_idle(status="active") | ||
|
||
unit = model.applications['zinc-k8s'].units[0] | ||
action1 = await unit.run_action("get-admin-password") | ||
assert action1.status == 'pending' | ||
|
||
action2 = await action1.wait() | ||
assert action2.status == 'completed' | ||
|
||
print(action2.results["admin-password"]) | ||
|
||
# They are the same object | ||
assert action1 is action2 | ||
|
||
await model.disconnect() | ||
|
||
|
||
if __name__ == "__main__": | ||
jasyncio.run(_get_password()) |
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
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