1 .. libjuju documentation master file, created by
2 sphinx-quickstart on Thu May 19 11:21:38 2016.
3 You can adapt this file completely to your liking, but it should at least
4 contain the root `toctree` directive.
6 A Python library for Juju
7 =========================
9 NOTE: This is pre-release software. The implementation is usable but
12 Please report bugs at https://github.com/juju/python-libjuju/issues.
25 * Asynchronous - uses asyncio and async/await features of python 3.5
26 * Websocket-level bindings are programmatically generated (indirectly) from the
27 Juju golang code, ensuring full api coverage
28 * Provides an OO layer which encapsulates much of the websocket api and
29 provides familiar nouns and verbs (e.g. Model.deploy(), Application.add_unit(),
36 git clone https://github.com/juju/python-libjuju.git
38 python setup.py install # make sure python is 3.5+
43 Here's a simple example that shows basic usage of the library. The example
44 connects to the currently active Juju model, deploys a single unit of the
45 ubuntu charm, then exits.
47 More examples can be found in the `examples/` directory of the source tree,
48 and in the documentation.
58 from juju.model import Model
62 # Create a Model instance. We need to connect our Model to a Juju api
63 # server before we can use it.
66 # Connect to the currently active Juju model
67 await model.connect_current()
69 # Deploy a single unit of the ubuntu charm, using revision 0 from the
70 # stable channel of the Charm Store.
71 ubuntu_app = await model.deploy(
73 application_name='ubuntu',
78 # Disconnect from the api server and cleanup.
81 # Stop the asyncio event loop.
86 # Set logging level to debug so we can see verbose output from the
88 logging.basicConfig(level=logging.DEBUG)
90 # Quiet logging from the websocket library. If you want to see
91 # everything sent over the wire, set this to DEBUG.
92 ws_logger = logging.getLogger('websockets.protocol')
93 ws_logger.setLevel(logging.INFO)
95 # Create the asyncio event loop
96 loop = asyncio.get_event_loop()
98 # Queue up our `run()` coroutine for execution
99 loop.create_task(run())
101 # Start the event loop
105 if __name__ == '__main__':
117 API Docs <api/modules>