X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=juju%2Fmodel.py;h=b97798acae9293a2feb218a6cc12e29a262260be;hb=1d134bb4ff5362ae956a7692ea4621ca7b8d59b0;hp=e56ad66720ba777bcf54b2075c65e4517d8937f5;hpb=789ae9e7085f8fa16a8320cc318494d4bff75e43;p=osm%2FN2VC.git diff --git a/juju/model.py b/juju/model.py index e56ad66..b97798a 100644 --- a/juju/model.py +++ b/juju/model.py @@ -390,6 +390,16 @@ class Model(object): self._watch_received = asyncio.Event(loop=self.loop) self._charmstore = CharmStore(self.loop) + async def __aenter__(self): + await self.connect_current() + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.disconnect() + + if exc_type is not None: + return False + async def connect(self, *args, **kw): """Connect to an arbitrary Juju model.