-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5134335
commit afeb4e7
Showing
5 changed files
with
115 additions
and
91 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 |
---|---|---|
@@ -1,33 +1,30 @@ | ||
# Copyright 2023 Canonical Ltd. | ||
# Licensed under the Apache V2, see LICENCE file for details. | ||
|
||
""" | ||
This example: | ||
1. Connects to the current model | ||
2. Upgrades previously deployed ubuntu charm | ||
""" | ||
from juju import jasyncio | ||
from juju.model import Model | ||
|
||
|
||
async def main(): | ||
model = Model() | ||
print('Connecting to model') | ||
# connect to current model with current user, per Juju CLI | ||
await model.connect() | ||
|
||
try: | ||
print('Get deployed application') | ||
app = model.appplications["ubuntu"] | ||
|
||
print('Refresh/Upgrade Ubuntu charm with local charm') | ||
await app.refresh(path="path/to/local/ubuntu.charm") | ||
print('path="/home/jack/charms/ubuntu"') | ||
await depl(model, path="/home/jack/charms/ubuntu") | ||
print('switch="/home/jack/charms/ubuntu"') | ||
await depl(model, switch="/home/jack/charms/ubuntu") | ||
print('switch="local:/home/jack/charms/ubuntu"') | ||
await depl(model, switch="local:/home/jack/charms/ubuntu") | ||
finally: | ||
print('Disconnecting from model') | ||
await model.disconnect() | ||
|
||
async def depl(model, **kwargs): | ||
try: | ||
app = await model.deploy("ubuntu") | ||
await model.block_until(lambda: app.units[0].workload_status == 'active') | ||
await app.refresh(**kwargs) | ||
finally: | ||
await app.remove() | ||
await model.block_until(lambda: not len(model.applications)) | ||
|
||
if __name__ == '__main__': | ||
jasyncio.run(main()) |
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