Improved Primitive support and better testing
This changeset addresses several issues.
- Improve primitive support so the status and output of an executed
primitive can be retrieved
- Merge latest upstream libjuju (required for new primive features)
- New testing framework
This is the start of a new testing framework with the ability to
create and configure LXD containers with SSH, to use while testing proxy
charms.
- Add support for using ssh keys with proxy charms
See Feature 1429. This uses the per-proxy charm/unit ssh keypair
Signed-off-by: Adam Israel <adam.israel@canonical.com>
diff --git a/modules/libjuju/examples/connect_current_model.py b/modules/libjuju/examples/connect_current_model.py
new file mode 100644
index 0000000..b46a09c
--- /dev/null
+++ b/modules/libjuju/examples/connect_current_model.py
@@ -0,0 +1,27 @@
+"""
+This is a very basic example that connects to the currently selected model
+and prints the number of applications deployed to it.
+"""
+import logging
+
+from juju import loop
+from juju.model import Model
+
+log = logging.getLogger(__name__)
+
+
+async def main():
+ model = Model()
+ try:
+ # connect to the current model with the current user, per the Juju CLI
+ await model.connect()
+ print('There are {} applications'.format(len(model.applications)))
+ finally:
+ if model.is_connected():
+ print('Disconnecting from model')
+ await model.disconnect()
+
+
+if __name__ == '__main__':
+ logging.basicConfig(level=logging.INFO)
+ loop.run(main())