From: Thanh Ha Date: Fri, 4 Jan 2019 17:58:00 +0000 (-0500) Subject: Add command to list openstack containers X-Git-Tag: v0.20.0~3 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=b151b1aa0c7668e240599096383ea88b9673b175;p=releng%2Flftools.git Add command to list openstack containers Change-Id: I5586888ba7c418f92ddc90727f349f695cd6d67d Signed-off-by: Thanh Ha --- diff --git a/docs/commands/openstack.rst b/docs/commands/openstack.rst index fefa86e1..aeffa8f6 100644 --- a/docs/commands/openstack.rst +++ b/docs/commands/openstack.rst @@ -32,6 +32,18 @@ list .. program-output:: lftools openstack --os-cloud docs image list --help +object +------ + +Command for managing objects. + +.. program-output:: lftools openstack --os-cloud docs object --help + +list-containers +^^^^^^^^^^^^^^^ + +.. program-output:: lftools openstack --os-cloud docs object list-containers --help + stack ----- diff --git a/lftools/openstack/cmd.py b/lftools/openstack/cmd.py index 522eca04..8437dd0f 100644 --- a/lftools/openstack/cmd.py +++ b/lftools/openstack/cmd.py @@ -16,6 +16,7 @@ __author__ = 'Thanh Ha' import click from lftools.openstack import image as os_image +from lftools.openstack import object as os_object from lftools.openstack import server as os_server from lftools.openstack import stack as os_stack from lftools.openstack import volume as os_volume @@ -109,6 +110,23 @@ image.add_command(share) image.add_command(upload) +@openstack.group() +@click.pass_context +def object(ctx): + """Command for manipulating objects.""" + pass + + +@click.command() +@click.pass_context +def list_containers(ctx): + """List available containers.""" + os_object.list_containers(ctx.obj['os_cloud']) + + +object.add_command(list_containers) + + @openstack.group() @click.pass_context def server(ctx): diff --git a/lftools/openstack/object.py b/lftools/openstack/object.py new file mode 100644 index 00000000..864aa6fd --- /dev/null +++ b/lftools/openstack/object.py @@ -0,0 +1,24 @@ +# -*- code: utf-8 -*- +# SPDX-License-Identifier: EPL-1.0 +############################################################################## +# Copyright (c) 2019 The Linux Foundation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +############################################################################## +"""Object related sub-commands for openstack command.""" + +__author__ = 'Thanh Ha' + +import shade + + +def list_containers(os_cloud): + """List volumes found according to parameters.""" + cloud = shade.openstack_cloud(cloud=os_cloud) + containers = cloud.list_containers() + + for container in containers: + print(container) diff --git a/releasenotes/notes/openstack-object-list-containers-ef156a5351bc6d5f.yaml b/releasenotes/notes/openstack-object-list-containers-ef156a5351bc6d5f.yaml new file mode 100644 index 00000000..484a5972 --- /dev/null +++ b/releasenotes/notes/openstack-object-list-containers-ef156a5351bc6d5f.yaml @@ -0,0 +1,10 @@ +--- +features: + - | + Add command to list openstack containers. + + Usage: + + .. code-block:: bash + + lftools openstack --os-cloud example object list-containers