blob: e6c306a1aeedea0f7bd335d10576b95b18aa39e2 [file] [log] [blame]
Adam Israeldcdf82b2017-08-15 15:26:43 -04001"""
2This example:
3
41. Connects to the current model
52. Deploy a charm and waits until it reports itself active
63. Destroys the unit and application
7
8"""
9from juju import loop
10from juju.model import Model
11
12
13async def main():
14 model = Model()
15 print('Connecting to model')
16 await model.connect_current()
17
18 try:
19 print('Deploying ubuntu')
20 application = await model.deploy(
21 'ubuntu-10',
22 application_name='ubuntu',
23 series='trusty',
24 channel='stable',
25 )
26
27 print('Waiting for active')
28 await model.block_until(
29 lambda: all(unit.workload_status == 'active'
30 for unit in application.units))
31
32 print('Removing ubuntu')
33 await application.remove()
34 finally:
35 print('Disconnecting from model')
36 await model.disconnect()
37
38
39if __name__ == '__main__':
40 loop.run(main())