Create a new model for each test run of examples/add_model.py.
authorPete Vander Giessen <petevg@gmail.com>
Fri, 27 Jan 2017 23:32:50 +0000 (18:32 -0500)
committerPete Vander Giessen <petevg@gmail.com>
Fri, 27 Jan 2017 23:33:37 +0000 (18:33 -0500)
examples/add_model.py

index efa325b..e703450 100644 (file)
@@ -11,6 +11,7 @@ from juju import utils
 from juju.controller import Controller
 import asyncio
 from logging import getLogger
+import uuid
 
 LOG = getLogger(__name__)
 
@@ -21,7 +22,8 @@ async def main():
     await controller.connect_current()
 
     try:
-        model_name = "quux"
+        model_name = "addmodeltest-{}".format(uuid.uuid4())
+        print("Adding model {}".format(model_name))
         model = await controller.add_model(model_name)
 
         print('Deploying ubuntu')
@@ -49,6 +51,10 @@ async def main():
         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()