blob: b46a09c6150b6a45ac01fd7c5115099c6735d664 [file] [log] [blame]
Adam Israelb0943662018-08-02 15:32:00 -04001"""
2This is a very basic example that connects to the currently selected model
3and prints the number of applications deployed to it.
4"""
5import logging
6
7from juju import loop
8from juju.model import Model
9
10log = logging.getLogger(__name__)
11
12
13async def main():
14 model = Model()
15 try:
16 # connect to the current model with the current user, per the Juju CLI
17 await model.connect()
18 print('There are {} applications'.format(len(model.applications)))
19 finally:
20 if model.is_connected():
21 print('Disconnecting from model')
22 await model.disconnect()
23
24
25if __name__ == '__main__':
26 logging.basicConfig(level=logging.INFO)
27 loop.run(main())