from juju.controller import Controller
import asyncio
from logging import getLogger
+import uuid
LOG = getLogger(__name__)
await controller.connect_current()
try:
- model = await controller.add_model("quux")
+ model_name = "addmodeltest-{}".format(uuid.uuid4())
+ print("Adding model {}".format(model_name))
+ model = await controller.add_model(model_name)
print('Deploying ubuntu')
application = await model.deploy(
for unit in application.units))
print("Verifying that we can ssh into the created model")
- ret = utils.execute_process('juju', 'ssh', 'ls /', log=LOG)
+ ret = await utils.execute_process(
+ 'juju', 'ssh', '-m', model_name, 'ubuntu/0', 'ls /', log=LOG)
assert ret
print('Removing ubuntu')
print("Destroying model")
await controller.destroy_model(model.info.uuid)
+ except Exception as e:
+ LOG.exception(
+ "Test failed! Model {} may not be cleaned up".format(model_name))
+
finally:
print('Disconnecting from controller')
await model.disconnect()
await controller.disconnect()
-loop.run(main())
+if __name__ == '__main__':
+ loop.run(main())