1 #!/usr/bin/env python3.5
6 1. Connects to the current model
7 2. Creates two machines and a lxd container
8 3. Deploys charm to the lxd container
14 from juju
.model
import Model
22 await model
.connect_current()
25 # add a new default machine
26 machine1
= await model
.add_machine()
27 # add a machine with constraints, disks, and series
28 machine2
= await model
.add_machine(
39 # add a lxd container to machine2
40 machine3
= await model
.add_machine(
41 'lxd:{}'.format(machine2
.id))
43 # deploy charm to the lxd container
44 application
= await model
.deploy(
46 application_name
='ubuntu',
52 await model
.block_until(
53 lambda: all(unit
.workload_status
== 'active'
54 for unit
in application
.units
))
56 await application
.remove()
58 await machine3
.destroy(force
=True)
59 await machine2
.destroy(force
=True)
60 await machine1
.destroy(force
=True)
62 await model
.disconnect()
65 if __name__
== '__main__':
66 logging
.basicConfig(level
=logging
.DEBUG
)
67 ws_logger
= logging
.getLogger('websockets.protocol')
68 ws_logger
.setLevel(logging
.INFO
)