CLI: implement deployment list command

kolla-mesos deployment list

partial blueprint per-service-cli

Change-Id: I4a7928c89ca8a5af57d7a99362c6a5041c70685a
This commit is contained in:
Andrey Pavlov 2016-03-16 16:56:45 +03:00
parent 000b508b53
commit a6ce1448d1
3 changed files with 23 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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