X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=juju%2Fmodel.py;h=5ca74221c240d17dd7322cab572ed09719dd7aef;hb=1b2df922f29c611671f1fb05164016d23a55dfc8;hp=d63f6d0400c440d109dab041c9990cd765a592e9;hpb=8b3c96e8630f643f85f599aa5175a900ace48311;p=osm%2FN2VC.git diff --git a/juju/model.py b/juju/model.py index d63f6d0..5ca7422 100644 --- a/juju/model.py +++ b/juju/model.py @@ -159,14 +159,12 @@ class ModelState(object): def get_entity( self, entity_type, entity_id, history_index=-1, connected=True): - """Return an object instance representing the entity created or - updated by ``delta`` + """Return an object instance for the given entity_type and id. + + By default the object state matches the most recent state from + Juju. To get an instance of the object in an older state, pass + history_index, an index into the history deque for the entity. - """ - """ - log.debug( - 'Getting %s:%s at index %s', - entity_type, entity_id, history_index) """ if history_index < 0 and history_index != -1: @@ -351,6 +349,16 @@ class Model(object): self._watch_received = asyncio.Event(loop=loop) self._charmstore = CharmStore(self.loop) + async def connect(self, *args, **kw): + """Connect to an arbitrary Juju model. + + args and kw are passed through to Connection.connect() + + """ + self.connection = await connection.Connection.connect(*args, **kw) + self._watch() + await self._watch_received.wait() + async def connect_current(self): """Connect to the current Juju model. @@ -578,7 +586,7 @@ class Model(object): action_id = action_id[7:] def predicate(delta): - return delta.data['status'] in ('completed', 'error') + return delta.data['status'] in ('completed', 'failed') return await self._wait('action', action_id, 'change', predicate)