add current-apps script
This commit is contained in:
2
setup.py
2
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',
|
||||
]
|
||||
},
|
||||
|
||||
35
zaza/model.py
Normal file
35
zaza/model.py
Normal file
@@ -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()
|
||||
Reference in New Issue
Block a user