diff --git a/setup.py b/setup.py index ca34e90..a9374e1 100644 --- a/setup.py +++ b/setup.py @@ -8,6 +8,7 @@ from setuptools.command.test import test as TestCommand version = "0.0.1.dev1" install_require = [ + 'juju' ] tests_require = [ @@ -71,6 +72,7 @@ setup( ], entry_points={ 'console_scripts': [ + 'current-apps = zaza.model:main', 'tempest-config = zaza.tempest_config:main', ] }, diff --git a/zaza/model.py b/zaza/model.py new file mode 100644 index 0000000..ee53676 --- /dev/null +++ b/zaza/model.py @@ -0,0 +1,35 @@ +import logging +import sys + +from juju import loop +from juju.model import Model + + +async def deployed(filter=None): + # Create a Model instance. We need to connect our Model to a Juju api + # server before we can use it. + model = Model() + # Connect to the currently active Juju model + await model.connect_current() + try: + # list currently deploeyd services + return list(model.applications.keys()) + finally: + # Disconnect from the api server and cleanup. + await model.disconnect() + + +def main(): + # logging.basicConfig(level=logging.INFO) + + # # If you want to see everything sent over the wire, set this to DEBUG. + # ws_logger = logging.getLogger('websockets.protocol') + # ws_logger.setLevel(logging.INFO) + + # Run the deploy coroutine in an asyncio event loop, using a helper + # that abstracts loop creation and teardown. + print("Current applications: {}".format( ", ".join(loop.run(deployed())))) + + +if __name__ == '__main__': + main() \ No newline at end of file