projects
/
osm
/
N2VC.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make observers async; make model.reset() blocking
[osm/N2VC.git]
/
examples
/
deploy.py
diff --git
a/examples/deploy.py
b/examples/deploy.py
index
5c1aae5
..
a1ae503
100644
(file)
--- a/
examples/deploy.py
+++ b/
examples/deploy.py
@@
-1,5
+1,5
@@
"""
"""
-
Run this one against a model that has at least one unit deployed
.
+
Deploy a charm, wait until it's idle, then destroy the unit and application
.
"""
import asyncio
"""
import asyncio
@@
-9,11
+9,6
@@
from juju.model import Model, ModelObserver
from juju.client.connection import Connection
from juju.client.connection import Connection
-loop = asyncio.get_event_loop()
-conn = loop.run_until_complete(Connection.connect_current())
-model = Model(conn)
-
-
class MyModelObserver(ModelObserver):
def on_unit_add(self, delta, old, new, model):
logging.info(
class MyModelObserver(ModelObserver):
def on_unit_add(self, delta, old, new, model):
logging.info(
@@
-39,6
+34,8
@@
class MyModelObserver(ModelObserver):
async def run():
async def run():
+ conn = await Connection.connect_current()
+ model = Model(conn)
model.add_observer(MyModelObserver())
await model.deploy(
'ubuntu-0',
model.add_observer(MyModelObserver())
await model.deploy(
'ubuntu-0',
@@
-48,6
+45,7
@@
async def run():
)
await model.watch()
)
await model.watch()
+
logging.basicConfig(level=logging.INFO)
logging.basicConfig(level=logging.INFO)
-loop
.create_task(run()
)
-loop.run_
forever(
)
+loop
= asyncio.get_event_loop(
)
+loop.run_
until_complete(run()
)