diff --git a/kolla_mesos/cli/deployment.py b/kolla_mesos/cli/deployment.py index 3497d1bf..4d4295c7 100644 --- a/kolla_mesos/cli/deployment.py +++ b/kolla_mesos/cli/deployment.py @@ -11,6 +11,7 @@ # limitations under the License. from cliff import command +from cliff import lister from cliff import show from oslo_config import cfg from oslo_log import log @@ -54,3 +55,13 @@ class Show(show.ShowOne): def take_action(self, parsed_args): conf_opts = deployment.get_deployment() return cli_utils.dict2columns(conf_opts, id_col='deployment_id') + + +class List(lister.Lister): + """List all existing deployments.""" + + def take_action(self, parsed_args): + cols = ['Deployment ID'] + ids = deployment.list_deployments() + values = [[id] for id in ids] + return cols, values diff --git a/kolla_mesos/deployment.py b/kolla_mesos/deployment.py index ed2713dc..5c214369 100644 --- a/kolla_mesos/deployment.py +++ b/kolla_mesos/deployment.py @@ -67,3 +67,14 @@ def get_deployment(): # TODO(asalkeld) if horizon is running and ready, get the url. conf_opts['horizon'] = '' return conf_opts + + +def list_deployments(): + ids = [] + with zk_utils.connection() as zk: + children = zk.get_children('/kolla') + for child in children: + if child not in ['groups', 'variables', 'common', + 'config', 'commands']: + ids.append(child) + return ids diff --git a/setup.cfg b/setup.cfg index f3a89ae2..11d87acb 100644 --- a/setup.cfg +++ b/setup.cfg @@ -56,6 +56,7 @@ kolla_mesos.cli = deployment kill = kolla_mesos.cli.deployment:Kill deployment cleanup = kolla_mesos.cli.deployment:Cleanup deployment show = kolla_mesos.cli.deployment:Show + deployment list = kolla_mesos.cli.deployment:List oslo.config.opts = kolla_mesos = kolla_mesos.opts:list_opts