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 await controller
.connect_current()
25 model_name
= "addmodeltest-{}".format(uuid
.uuid4())
26 print("Adding model {}".format(model_name
))
27 model
= await controller
.add_model(model_name
)
29 print('Deploying ubuntu')
30 application
= await model
.deploy(
32 application_name
='ubuntu',
37 print('Waiting for active')
38 await asyncio
.sleep(10)
39 await model
.block_until(
40 lambda: all(unit
.workload_status
== 'active'
41 for unit
in application
.units
))
43 print("Verifying that we can ssh into the created model")
44 ret
= await utils
.execute_process(
45 'juju', 'ssh', '-m', model_name
, 'ubuntu/0', 'ls /', log
=LOG
)
48 print('Removing ubuntu')
49 await application
.remove()
51 print("Destroying model")
52 await controller
.destroy_model(model
.info
.uuid
)
56 "Test failed! Model {} may not be cleaned up".format(model_name
))
59 print('Disconnecting from controller')
61 await model
.disconnect()
62 await controller
.disconnect()
65 if __name__
== '__main__':