Merge "Add --all-tenants option into zun list"
This commit is contained in:
@@ -20,9 +20,11 @@ from zunclient import exceptions as exc
|
|||||||
from zunclient.i18n import _
|
from zunclient.i18n import _
|
||||||
|
|
||||||
|
|
||||||
def common_filters(marker=None, limit=None, sort_key=None, sort_dir=None):
|
def common_filters(marker=None, limit=None, sort_key=None,
|
||||||
|
sort_dir=None, all_tenants=False):
|
||||||
"""Generate common filters for any list request.
|
"""Generate common filters for any list request.
|
||||||
|
|
||||||
|
:param all_tenants: list containers in all tenants or not
|
||||||
:param marker: entity ID from which to start returning entities.
|
:param marker: entity ID from which to start returning entities.
|
||||||
:param limit: maximum number of entities to return.
|
:param limit: maximum number of entities to return.
|
||||||
:param sort_key: field to use for sorting.
|
:param sort_key: field to use for sorting.
|
||||||
@@ -30,6 +32,8 @@ def common_filters(marker=None, limit=None, sort_key=None, sort_dir=None):
|
|||||||
:returns: list of string filters.
|
:returns: list of string filters.
|
||||||
"""
|
"""
|
||||||
filters = []
|
filters = []
|
||||||
|
if all_tenants is True:
|
||||||
|
filters.append('all_tenants=1')
|
||||||
if isinstance(limit, int):
|
if isinstance(limit, int):
|
||||||
filters.append('limit=%s' % limit)
|
filters.append('limit=%s' % limit)
|
||||||
if marker is not None:
|
if marker is not None:
|
||||||
|
|||||||
@@ -41,9 +41,11 @@ class ContainerManager(base.Manager):
|
|||||||
return '/v1/containers'
|
return '/v1/containers'
|
||||||
|
|
||||||
def list(self, marker=None, limit=None, sort_key=None,
|
def list(self, marker=None, limit=None, sort_key=None,
|
||||||
sort_dir=None, detail=False):
|
sort_dir=None, detail=False, all_tenants=False):
|
||||||
"""Retrieve a list of containers.
|
"""Retrieve a list of containers.
|
||||||
|
|
||||||
|
:param all_tenants: Optional, list containers in all tenants
|
||||||
|
|
||||||
:param marker: Optional, the UUID of a containers, eg the last
|
:param marker: Optional, the UUID of a containers, eg the last
|
||||||
containers from a previous result set. Return
|
containers from a previous result set. Return
|
||||||
the next result set.
|
the next result set.
|
||||||
@@ -70,7 +72,8 @@ class ContainerManager(base.Manager):
|
|||||||
if limit is not None:
|
if limit is not None:
|
||||||
limit = int(limit)
|
limit = int(limit)
|
||||||
|
|
||||||
filters = utils.common_filters(marker, limit, sort_key, sort_dir)
|
filters = utils.common_filters(marker, limit, sort_key,
|
||||||
|
sort_dir, all_tenants)
|
||||||
|
|
||||||
path = ''
|
path = ''
|
||||||
if detail:
|
if detail:
|
||||||
|
|||||||
@@ -151,6 +151,10 @@ def do_create(cs, args):
|
|||||||
_show_container(cs.containers.create(**opts))
|
_show_container(cs.containers.create(**opts))
|
||||||
|
|
||||||
|
|
||||||
|
@utils.arg('--all-tenants',
|
||||||
|
action="store_true",
|
||||||
|
default=False,
|
||||||
|
help='List containers in all tenants')
|
||||||
@utils.arg('--marker',
|
@utils.arg('--marker',
|
||||||
metavar='<marker>',
|
metavar='<marker>',
|
||||||
default=None,
|
default=None,
|
||||||
@@ -170,6 +174,7 @@ def do_create(cs, args):
|
|||||||
def do_list(cs, args):
|
def do_list(cs, args):
|
||||||
"""Print a list of available containers."""
|
"""Print a list of available containers."""
|
||||||
opts = {}
|
opts = {}
|
||||||
|
opts['all_tenants'] = args.all_tenants
|
||||||
opts['marker'] = args.marker
|
opts['marker'] = args.marker
|
||||||
opts['limit'] = args.limit
|
opts['limit'] = args.limit
|
||||||
opts['sort_key'] = args.sort_key
|
opts['sort_key'] = args.sort_key
|
||||||
|
|||||||
Reference in New Issue
Block a user