Skip to content

Commit 20384dc

Browse files
Fix the linter issues
Add another exmaple to show machine deployment with resources.
1 parent b880396 commit 20384dc

3 files changed

Lines changed: 39 additions & 3 deletions

File tree

examples/charmhub_deploy_k8s.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""
2+
This example:
3+
4+
1. Connects to the current model
5+
2. Deploy a charm and waits until it reports itself active
6+
3. Destroys the unit and application
7+
8+
"""
9+
from juju import loop
10+
from juju.model import Model
11+
12+
13+
async def main():
14+
model = Model()
15+
print('Connecting to model')
16+
await model.connect()
17+
18+
try:
19+
print('Deploying ')
20+
application = await model.deploy(
21+
'ch:juju-qa-test',
22+
application_name='juju-qa-test2',
23+
channel='2.0/edge',
24+
)
25+
26+
print('Waiting for active')
27+
await model.block_until(
28+
lambda: all(unit.workload_status == 'active'
29+
for unit in application.units))
30+
31+
finally:
32+
print('Disconnecting from model')
33+
await model.disconnect()
34+
35+
if __name__ == '__main__':
36+
loop.run(main())
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ async def main():
1818
try:
1919
print('Deploying ')
2020
application = await model.deploy(
21-
'ch:snappass-test',
22-
application_name='snappass'
21+
'ch:juju-qa-test',
22+
application_name='juju-qa-test',
23+
channel='2.0/edge',
2324
)
2425

2526
print('Waiting for active')

juju/model.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1717,7 +1717,6 @@ async def _add_charmhub_resources(self, application,
17171717
if resource['name'] in overrides:
17181718
resource['revision'] = overrides[resource['name']]
17191719

1720-
17211720
resources_facade = client.ResourcesFacade.from_connection(
17221721
self.connection())
17231722
response = await resources_facade.AddPendingResources(

0 commit comments

Comments
 (0)