4 1. Creates a model on the current controller
5 2. Deploys a charm to it.
6 3. Attempts to ssh into the charm
10 from juju
import utils
11 from juju
.controller
import Controller
13 from logging
import getLogger
16 LOG
= getLogger(__name__
)
20 controller
= Controller()
21 print("Connecting to controller")
22 # connect to current controller with current user, per Juju CLI
23 await controller
.connect()
26 model_name
= "addmodeltest-{}".format(uuid
.uuid4())
27 print("Adding model {}".format(model_name
))
28 model
= await controller
.add_model(model_name
)
30 print('Deploying ubuntu')
31 application
= await model
.deploy(
33 application_name
='ubuntu',
38 print('Waiting for active')
39 await asyncio
.sleep(10)
40 await model
.block_until(
41 lambda: all(unit
.workload_status
== 'active'
42 for unit
in application
.units
))
44 print("Verifying that we can ssh into the created model")
45 ret
= await utils
.execute_process(
46 'juju', 'ssh', '-m', model_name
, 'ubuntu/0', 'ls /', log
=LOG
)
49 print('Removing ubuntu')
50 await application
.remove()
52 print("Destroying model")
53 await controller
.destroy_model(model
.info
.uuid
)
57 "Test failed! Model {} may not be cleaned up".format(model_name
))
60 print('Disconnecting from controller')
62 await model
.disconnect()
63 await controller
.disconnect()
66 if __name__
== '__main__':